Browse Source

Update to .NET 8 (#1043)

* Update to .NET 8

* Update docker.

* Fix jint.
pull/1044/head
Sebastian Stehle 3 years ago
committed by GitHub
parent
commit
47327ad4bc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      Dockerfile
  2. 9
      backend/.editorconfig
  3. 2
      backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs
  4. 2
      backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs
  5. 2
      backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaProducer.cs
  6. 2
      backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs
  7. 2
      backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs
  8. 12
      backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs
  9. 2
      backend/extensions/Squidex.Extensions/Samples/Middleware/DoubleLinkedContentMiddleware.cs
  10. 57
      backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj
  11. 22
      backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj
  12. 6
      backend/src/Migrations/Migrations.csproj
  13. 2
      backend/src/Migrations/OldEvents/AssetCreated.cs
  14. 2
      backend/src/Migrations/OldEvents/AssetUpdated.cs
  15. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppSettings.cs
  16. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs
  17. 6
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs
  18. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs
  19. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs
  20. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs
  21. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs
  22. 6
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs
  23. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldNames.cs
  24. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRules.cs
  25. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/FieldSurrogate.cs
  26. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs
  27. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs
  28. 10
      backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
  29. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddDefaultValues.cs
  30. 8
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs
  31. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs
  32. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs
  33. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/PredefinedPatternsFormatter.cs
  34. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionDefinition.cs
  35. 9
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs
  36. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs
  37. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleTypeProvider.cs
  38. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetCommandScriptVars.cs
  39. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs
  40. 124
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/AssetMetadataWrapper.cs
  41. 50
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/CustomClrConverter.cs
  42. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintUser.cs
  43. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  44. 14
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs
  45. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs
  46. 26
      backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
  47. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs
  48. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagsExport.cs
  49. 13
      backend/src/Squidex.Domain.Apps.Core.Operations/Templates/TemplateParseException.cs
  50. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/RootContext.cs
  51. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs
  52. 6
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs
  53. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs
  54. 8
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj
  55. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasIndexDefinition.cs
  56. 6
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/LuceneQueryVisitor.cs
  57. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs
  58. 10
      backend/src/Squidex.Domain.Apps.Entities/AppProvider.cs
  59. 4
      backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs
  60. 6
      backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs
  61. 4
      backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs
  62. 4
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs
  63. 6
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs
  64. 4
      backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs
  65. 4
      backend/src/Squidex.Domain.Apps.Entities/Assets/Commands/UploadAssetCommand.cs
  66. 4
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs
  67. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs
  68. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs
  69. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/Steps/ConvertTags.cs
  70. 6
      backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs
  71. 7
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupRestoreException.cs
  72. 4
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs
  73. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/State/BackupState.cs
  74. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/State/RestoreJob.cs
  75. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs
  76. 2
      backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs
  77. 2
      backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs
  78. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs
  79. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Counter/CounterService.cs
  80. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs
  81. 8
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentsBulkUpdateCommandMiddleware.cs
  82. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs
  83. 32
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs
  84. 20
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs
  85. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentUnionGraphType.cs
  86. 104
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs
  87. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentUnionGraphType.cs
  88. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Dynamic/DynamicSchemaBuilder.cs
  89. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/FieldMap.cs
  90. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedExtensions.cs
  91. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs
  92. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs
  93. 8
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichWithWorkflows.cs
  94. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveAssets.cs
  95. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveReferences.cs
  96. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs
  97. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs
  98. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs
  99. 2
      backend/src/Squidex.Domain.Apps.Entities/ContextHeaders.cs
  100. 2
      backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs

5
Dockerfile

@ -2,7 +2,7 @@
# Stage 1, Build Backend
#
FROM mcr.microsoft.com/dotnet/sdk:7.0 as backend
FROM mcr.microsoft.com/dotnet/sdk:8.0 as backend
ARG SQUIDEX__BUILD__VERSION=7.0.0
@ -67,7 +67,7 @@ RUN cp -a build /build/
#
# Stage 3, Build runtime
#
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim
ARG SQUIDEX__RUNTIME__VERSION=7.0.0
@ -95,6 +95,7 @@ ENV DIAGNOSTICS__COUNTERSTOOL=/tools/dotnet-counters
ENV DIAGNOSTICS__DUMPTOOL=/tools/dotnet-dump
ENV DIAGNOSTICS__GCDUMPTOOL=/tools/dotnet-gcdump
ENV DIAGNOSTICS__TRACETOOL=/tools/dotnet-trace
ENV ASPNETCORE_HTTP_PORTS=80
ENTRYPOINT ["dotnet", "Squidex.dll"]

9
backend/.editorconfig

@ -21,6 +21,12 @@ dotnet_diagnostic.RECS0117.severity = none
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1649.severity = none
# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = none
# IDE0305: Simplify collection initialization
dotnet_diagnostic.IDE0305.severity = none
# CA1707: Identifiers should not contain underscores
dotnet_diagnostic.CA1707.severity = none
@ -117,6 +123,9 @@ dotnet_diagnostic.RECS0154.severity = none
# SA1009: Closing parenthesis should be spaced correctly
dotnet_diagnostic.SA1009.severity = none
# SA1010: Opening square brackets should be spaced correctly
dotnet_diagnostic.SA1010.severity = none
# SA1011: Closing square brackets should be spaced correctly
dotnet_diagnostic.SA1011.severity = none

2
backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs

@ -144,7 +144,7 @@ public sealed class AlgoliaContent
public string ObjectID { get; set; }
[JsonExtensionData]
public Dictionary<string, object> More { get; set; } = new Dictionary<string, object>();
public Dictionary<string, object> More { get; set; } = [];
}
public sealed class AlgoliaJob

2
backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs

@ -149,7 +149,7 @@ public sealed class ElasticSearchContent
public string ContentId { get; set; }
[JsonExtensionData]
public Dictionary<string, object> More { get; set; } = new Dictionary<string, object>();
public Dictionary<string, object> More { get; set; } = [];
}
public sealed class ElasticSearchJob

2
backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaProducer.cs

@ -129,7 +129,7 @@ public sealed class KafkaProducer
if (job.Headers?.Count > 0)
{
message.Headers = new Headers();
message.Headers = [];
foreach (var header in job.Headers)
{

2
backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs

@ -149,7 +149,7 @@ public sealed class OpenSearchContent
public string ContentId { get; set; }
[JsonExtensionData]
public Dictionary<string, object> More { get; set; } = new Dictionary<string, object>();
public Dictionary<string, object> More { get; set; } = [];
}
public sealed class OpenSearchJob

2
backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs

@ -136,7 +136,7 @@ public sealed class TypesenseContent
public string Id { get; set; }
[JsonExtensionData]
public Dictionary<string, object> More { get; set; } = new Dictionary<string, object>();
public Dictionary<string, object> More { get; set; } = [];
}
public sealed class TypesenseJob

12
backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs

@ -22,17 +22,17 @@ public sealed class AzureMetadataSource : IAssetMetadataSource
private readonly ILogger<AzureMetadataSource> log;
private readonly ComputerVisionClient client;
private readonly char[] trimChars =
{
[
' ',
'_',
'-'
};
private readonly List<VisualFeatureTypes?> features = new List<VisualFeatureTypes?>
{
];
private readonly List<VisualFeatureTypes?> features =
[
VisualFeatureTypes.Categories,
VisualFeatureTypes.Description,
VisualFeatureTypes.Color
};
];
public int Order => int.MaxValue;
@ -58,7 +58,7 @@ public sealed class AzureMetadataSource : IAssetMetadataSource
{
var result = await client.AnalyzeImageInStreamAsync(stream, features, cancellationToken: ct);
command.Tags ??= new HashSet<string>();
command.Tags ??= [];
if (result.Color?.DominantColorForeground != null)
{

2
backend/extensions/Squidex.Extensions/Samples/Middleware/DoubleLinkedContentMiddleware.cs

@ -105,7 +105,7 @@ public sealed class DoubleLinkedContentMiddleware : ICustomCommandMiddleware
{
if (data != null && data.TryGetValue("reference", out ContentFieldData? fieldData))
{
return fieldData?.Values.OfType<JsonArray>().SelectMany(x => x).SingleOrDefault().ToString();
return fieldData?.Values.Select(x => x.Value).OfType<JsonArray>().SelectMany(x => x).SingleOrDefault().ToString();
}
return null;

57
backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj

@ -1,44 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Squidex.Domain.Apps.Core.Operations\Squidex.Domain.Apps.Core.Operations.csproj" />
<ProjectReference Include="..\..\src\Squidex.Web\Squidex.Web.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Algolia.Search" Version="6.14.0" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0-beta.3" />
<PackageReference Include="Azure.Search.Documents" Version="11.4.0" />
<PackageReference Include="Confluent.SchemaRegistry.Serdes.Avro" Version="2.3.0" />
<PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="Elasticsearch.Net" Version="7.17.5" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="4.4.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="3.6.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Algolia.Search" Version="6.15.0" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0" />
<PackageReference Include="Azure.Search.Documents" Version="11.5.0" />
<PackageReference Include="Confluent.SchemaRegistry.Serdes.Avro" Version="2.3.0" />
<PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="Elasticsearch.Net" Version="7.17.5" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.1.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="4.1.0" />
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="3.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.21.4" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.17.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="OpenSearch.Net" Version="1.3.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.5.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.395" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.22.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.18.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="OpenSearch.Net" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.395" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />

22
backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj

@ -1,27 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<NoWarn>NU1608</NoWarn>
<NoWarn>NU1608</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="10.3.4" />
<PackageReference Include="FluentValidation" Version="11.8.0" />
<PackageReference Include="FluentValidation.ValidatorAttribute" Version="8.6.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.38" />
<PackageReference Include="CommandDotNet" Version="5.0.1" />
<PackageReference Include="CommandDotNet.FluentValidation" Version="5.0.0" />
<PackageReference Include="CommandDotNet.IoC.MicrosoftDependencyInjection" Version="4.0.1" />
<PackageReference Include="ConsoleTables" Version="2.4.2" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.676">
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="CommandDotNet" Version="7.0.2" />
<PackageReference Include="CommandDotNet.FluentValidation" Version="6.0.2" />
<PackageReference Include="CommandDotNet.IoC.MicrosoftDependencyInjection" Version="5.0.1" />
<PackageReference Include="ConsoleTables" Version="2.6.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="ResXResourceReader.NetStandard" Version="1.0.1" />
<PackageReference Include="ResXResourceReader.NetStandard" Version="1.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>

6
backend/src/Migrations/Migrations.csproj

@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

2
backend/src/Migrations/OldEvents/AssetCreated.cs

@ -44,7 +44,7 @@ public sealed class AssetCreated : AssetEvent, IMigrated<IEvent>
{
var result = SimpleMapper.Map(this, new AssetCreatedV2());
result.Metadata = new AssetMetadata();
result.Metadata = [];
if (IsImage && PixelWidth != null && PixelHeight != null)
{

2
backend/src/Migrations/OldEvents/AssetUpdated.cs

@ -35,7 +35,7 @@ public sealed class AssetUpdated : AssetEvent, IMigrated<IEvent>
{
var result = SimpleMapper.Map(this, new AssetUpdatedV2());
result.Metadata = new AssetMetadata();
result.Metadata = [];
if (IsImage && PixelWidth != null && PixelHeight != null)
{

4
backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppSettings.cs

@ -13,9 +13,9 @@ public sealed record AppSettings
{
public static readonly AppSettings Empty = new AppSettings();
public ReadonlyList<Pattern> Patterns { get; init; } = ReadonlyList.Empty<Pattern>();
public ReadonlyList<Pattern> Patterns { get; init; } = [];
public ReadonlyList<Editor> Editors { get; init; } = ReadonlyList.Empty<Editor>();
public ReadonlyList<Editor> Editors { get; init; } = [];
public bool HideScheduler { get; init; }

2
backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs

@ -16,7 +16,7 @@ public sealed record LanguageConfig(bool IsOptional = false, ReadonlyList<Langua
{
public static readonly LanguageConfig Default = new LanguageConfig();
public ReadonlyList<Language> Fallbacks { get; } = Fallbacks ?? ReadonlyList.Empty<Language>();
public ReadonlyList<Language> Fallbacks { get; } = Fallbacks ?? [];
internal LanguageConfig Cleanup(string self, IReadOnlyDictionary<string, LanguageConfig> allowed)
{

6
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs

@ -17,8 +17,8 @@ namespace Squidex.Domain.Apps.Core.Apps;
public sealed record Role(string Name, PermissionSet? Permissions = null, JsonObject? Properties = null)
{
private static readonly HashSet<string> ExtraPermissions = new HashSet<string>
{
private static readonly HashSet<string> ExtraPermissions =
[
PermissionIds.AppComments,
PermissionIds.AppContributorsRead,
PermissionIds.AppHistory,
@ -29,7 +29,7 @@ public sealed record Role(string Name, PermissionSet? Permissions = null, JsonOb
PermissionIds.AppSearch,
PermissionIds.AppTranslate,
PermissionIds.AppUsage
};
];
public const string Editor = nameof(Editor);
public const string Developer = nameof(Developer);

2
backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs

@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Assets;
public sealed class AssetMetadata : Dictionary<string, JsonValue>
{
private static readonly char[] PathSeparators = { '.', '[', ']' };
private static readonly char[] PathSeparators = ['.', '[', ']'];
public const string FocusX = "focusX";
public const string FocusY = "focusY";

2
backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs

@ -115,7 +115,7 @@ public sealed class ContentData : Dictionary<string, ContentFieldData?>, IEquata
public static ContentData Merge(params ContentData[] contents)
{
return MergeTo(new ContentData(), contents);
return MergeTo([], contents);
}
public ContentData MergeInto(ContentData target)

2
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs

@ -30,7 +30,7 @@ public sealed class WorkflowTransitionSurrogate : ISurrogate<WorkflowTransition>
if (!string.IsNullOrEmpty(Role))
{
roles = new[] { Role };
roles = [Role];
}
return WorkflowTransition.When(Expression, roles);

2
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs

@ -24,7 +24,7 @@ public sealed record Workflow(Status Initial, ReadonlyDictionary<Status, Workflo
public ReadonlyDictionary<Status, WorkflowStep> Steps { get; } = Steps ?? ReadonlyDictionary.Empty<Status, WorkflowStep>();
public ReadonlyList<DomainId> SchemaIds { get; } = SchemaIds ?? ReadonlyList.Empty<DomainId>();
public ReadonlyList<DomainId> SchemaIds { get; } = SchemaIds ?? [];
public static Workflow CreateDefault(string? name = null)
{

6
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs

@ -14,8 +14,8 @@ public sealed class FieldCollection<T> where T : IField
{
public static readonly FieldCollection<T> Empty = new FieldCollection<T>();
private static readonly Dictionary<long, T> EmptyById = new Dictionary<long, T>();
private static readonly Dictionary<string, T> EmptyByString = new Dictionary<string, T>();
private static readonly Dictionary<long, T> EmptyById = [];
private static readonly Dictionary<string, T> EmptyByString = [];
private readonly T[] fieldsOrdered;
private Dictionary<long, T>? fieldsById;
@ -68,7 +68,7 @@ public sealed class FieldCollection<T> where T : IField
private FieldCollection()
{
fieldsOrdered = Array.Empty<T>();
fieldsOrdered = [];
}
public FieldCollection(T[] fields)

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldNames.cs

@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Core.Schemas;
public sealed class FieldNames : ReadonlyList<string>
{
public static readonly FieldNames Empty = new FieldNames(new List<string>());
public static readonly new FieldNames Empty = new FieldNames(new List<string>());
public FieldNames()
{

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRules.cs

@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Core.Schemas;
public sealed class FieldRules : ReadonlyList<FieldRule>
{
public static readonly FieldRules Empty = new FieldRules(new List<FieldRule>());
public static readonly new FieldRules Empty = new FieldRules(new List<FieldRule>());
public FieldRules()
{

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/FieldSurrogate.cs

@ -31,7 +31,7 @@ public sealed class FieldSurrogate : IFieldSettings
if (Properties is ArrayFieldProperties arrayProperties)
{
var nested = Children?.Select(n => n.ToNestedField()).ToArray() ?? Array.Empty<NestedField>();
var nested = Children?.Select(n => n.ToNestedField()).ToArray() ?? [];
return new ArrayField(Id, Name, partitioning, nested, arrayProperties, this);
}

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs

@ -86,7 +86,7 @@ public sealed class SchemaSurrogate : ISurrogate<Schema>
public Schema ToSource()
{
var fields = Fields?.Select(f => f.ToField()).ToArray() ?? Array.Empty<RootField>();
var fields = Fields?.Select(f => f.ToField()).ToArray() ?? [];
var schema = new Schema(Name, fields, Properties, IsPublished, Type);

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs

@ -33,7 +33,7 @@ public sealed class ResolvedComponents : ReadonlyDictionary<DomainId, Schema>
{
if (TryGetValue(schemaId, out var schema))
{
result ??= new Dictionary<DomainId, Schema>();
result ??= [];
result[schemaId] = schema;
}
}

10
backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Squidex.Domain.Apps.Core</RootNamespace>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<NeutralLanguage>en</NeutralLanguage>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -12,15 +12,15 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
<ItemGroup>

2
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddDefaultValues.cs

@ -43,7 +43,7 @@ public sealed class AddDefaultValues : IContentDataConverter, IContentItemConver
continue;
}
data[field.Name] = new ContentFieldData();
data[field.Name] = [];
}
}

8
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs

@ -16,10 +16,10 @@ namespace Squidex.Domain.Apps.Core.ConvertContent;
public sealed class ContentConverter
{
private readonly List<IContentDataConverter> dataConverters = new List<IContentDataConverter>();
private readonly List<IContentItemConverter> itemConverters = new List<IContentItemConverter>();
private readonly List<IContentFieldConverter> fieldConverters = new List<IContentFieldConverter>();
private readonly List<IContentValueConverter> valueConverters = new List<IContentValueConverter>();
private readonly List<IContentDataConverter> dataConverters = [];
private readonly List<IContentItemConverter> itemConverters = [];
private readonly List<IContentFieldConverter> fieldConverters = [];
private readonly List<IContentValueConverter> valueConverters = [];
private readonly ResolvedComponents components;
private readonly Schema schema;

4
backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs

@ -12,8 +12,8 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds;
public sealed class StringReferenceExtractor
{
private readonly List<Regex> contentsPatterns = new List<Regex>();
private readonly List<Regex> assetsPatterns = new List<Regex>();
private readonly List<Regex> contentsPatterns = [];
private readonly List<Regex> assetsPatterns = [];
public StringReferenceExtractor(IUrlGenerator urlGenerator)
{

4
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs

@ -197,7 +197,7 @@ internal sealed class JsonTypeVisitor : IFieldVisitor<JsonSchemaProperty?, JsonT
property.ExtensionData = new Dictionary<string, object>
{
["schemaIds"] = field.Properties.SchemaIds ?? ReadonlyList.Empty<DomainId>()
["schemaIds"] = field.Properties.SchemaIds ?? []
};
property.UniqueItems = !field.Properties.AllowDuplicates;
@ -218,7 +218,7 @@ internal sealed class JsonTypeVisitor : IFieldVisitor<JsonSchemaProperty?, JsonT
if (field.Properties.AllowedValues != null)
{
var names = property.EnumerationNames ??= new Collection<string>();
var names = property.EnumerationNames ??= [];
foreach (var value in field.Properties.AllowedValues)
{

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/PredefinedPatternsFormatter.cs

@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules;
public sealed class PredefinedPatternsFormatter : IRuleEventFormatter
{
private readonly List<(string Pattern, Func<EnrichedEvent, string?> Replacer)> patterns = new List<(string Pattern, Func<EnrichedEvent, string?> Replacer)>();
private readonly List<(string Pattern, Func<EnrichedEvent, string?> Replacer)> patterns = [];
private readonly IUrlGenerator urlGenerator;
public PredefinedPatternsFormatter(IUrlGenerator urlGenerator)

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionDefinition.cs

@ -23,5 +23,5 @@ public sealed class RuleActionDefinition
public string Description { get; set; }
public List<RuleActionProperty> Properties { get; } = new List<RuleActionProperty>();
public List<RuleActionProperty> Properties { get; } = [];
}

9
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs

@ -164,14 +164,7 @@ public partial class RuleEventFormatter
{
if (!part.IsText)
{
var result = part.Var.Result;
result = TransformText(result, part.VarTransform);
if (result == null)
{
result = part.VarFallback;
}
var result = TransformText(part.Var.Result, part.VarTransform) ?? part.VarFallback;
if (string.IsNullOrEmpty(result))
{

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs

@ -316,7 +316,7 @@ public sealed class RuleService : IRuleService
}
}
matchingRules ??= new ();
matchingRules ??= [];
matchingRules.GetOrAddNew(triggerHandler).Add(state);
}

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleTypeProvider.cs

@ -20,7 +20,7 @@ public sealed class RuleTypeProvider : ITypeProvider
{
private const string ActionSuffix = "Action";
private const string ActionSuffixV2 = "ActionV2";
private readonly Dictionary<string, RuleActionDefinition> actionTypes = new Dictionary<string, RuleActionDefinition>();
private readonly Dictionary<string, RuleActionDefinition> actionTypes = [];
public IReadOnlyDictionary<string, RuleActionDefinition> Actions
{

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetCommandScriptVars.cs

@ -52,7 +52,7 @@ public sealed class AssetCommandScriptVars : ScriptVars
[FieldDescription(nameof(FieldDescriptions.AssetMetadata))]
public AssetMetadata? Metadata
{
set => SetInitial(value != null ? new AssetMetadataWrapper(value) : null);
set => SetInitial(value);
}
[FieldDescription(nameof(FieldDescriptions.AssetTags))]

4
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs

@ -50,7 +50,7 @@ public static class JsonMapper
return JsValue.Null;
}
private static JsValue FromArray(JsonArray arr, Engine engine)
private static JsArray FromArray(JsonArray arr, Engine engine)
{
var target = new JsValue[arr.Count];
@ -62,7 +62,7 @@ public static class JsonMapper
return engine.Realm.Intrinsics.Array.Construct(target);
}
private static JsValue FromObject(JsonObject obj, Engine engine)
private static JsonObjectInstance FromObject(JsonObject obj, Engine engine)
{
var target = new JsonObjectInstance(engine);

124
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/AssetMetadataWrapper.cs

@ -1,124 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using Squidex.Domain.Apps.Core.Assets;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.Scripting.Internal;
public sealed class AssetMetadataWrapper : IDictionary<string, object?>
{
private readonly AssetMetadata metadata;
public int Count
{
get => metadata.Count;
}
public ICollection<string> Keys
{
get => metadata.Keys;
}
public ICollection<object?> Values
{
get => metadata.Values.Cast<object?>().ToList();
}
public object? this[string key]
{
get => metadata[key];
set => metadata[key] = JsonValue.Create(value);
}
public bool IsReadOnly
{
get => false;
}
public AssetMetadataWrapper(AssetMetadata metadata)
{
this.metadata = metadata;
}
public bool TryGetValue(string key, [MaybeNullWhen(false)] out object? value)
{
if (metadata.TryGetValue(key, out var temp))
{
value = temp;
return true;
}
else
{
value = null;
return false;
}
}
public void Add(string key, object? value)
{
metadata.Add(key, JsonValue.Create(value));
}
public void Add(KeyValuePair<string, object?> item)
{
Add(item.Key, item.Value);
}
public bool Remove(string key)
{
return metadata.Remove(key);
}
public bool Remove(KeyValuePair<string, object?> item)
{
return false;
}
public void Clear()
{
metadata.Clear();
}
public bool Contains(KeyValuePair<string, object?> item)
{
return false;
}
public bool ContainsKey(string key)
{
return metadata.ContainsKey(key);
}
public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex)
{
var i = arrayIndex;
foreach (var item in metadata)
{
if (i >= array.Length)
{
break;
}
array[i] = new KeyValuePair<string, object?>(item.Key, item.Value);
i++;
}
}
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()
{
return metadata.Select(x => new KeyValuePair<string, object?>(x.Key, x.Value)).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)metadata).GetEnumerator();
}
}

50
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/CustomClrConverter.cs

@ -0,0 +1,50 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Diagnostics.CodeAnalysis;
using Jint;
using Jint.Runtime.Interop;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.Scripting.Internal;
internal sealed class CustomClrConverter : DefaultTypeConverter
{
public CustomClrConverter(Engine engine)
: base(engine)
{
}
public override object? Convert(object? value, Type type, IFormatProvider formatProvider)
{
if (type == typeof(JsonValue))
{
return JsonValue.Create(value);
}
return base.Convert(value, type, formatProvider);
}
public override bool TryConvert(object? value, Type type, IFormatProvider formatProvider, [NotNullWhen(true)] out object? converted)
{
if (type == typeof(JsonValue))
{
try
{
converted = JsonValue.Create(value);
return true;
}
catch
{
converted = null;
return false;
}
}
return base.TryConvert(value, type, formatProvider, out converted);
}
}

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintUser.cs

@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Scripting.Internal;
public static class JintUser
{
private static readonly char[] ClaimSeparators = { '/', '.', ':' };
private static readonly char[] ClaimSeparators = ['/', '.', ':'];
public static JsValue Create(Engine engine, IUser user)
{

3
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -37,7 +37,7 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
timeoutScript = options.Value.TimeoutScript;
timeoutExecution = options.Value.TimeoutExecution;
this.extensions = extensions?.ToArray() ?? Array.Empty<IJintExtension>();
this.extensions = extensions?.ToArray() ?? [];
}
public async Task<JsonValue> ExecuteAsync(ScriptVars vars, string script, ScriptOptions options = default,
@ -152,6 +152,7 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
var engine = new Engine(engineOptions =>
{
engineOptions.SetTypeConverter(engine => new CustomClrConverter(engine));
engineOptions.AddObjectConverter(JintObjectConverter.Instance);
engineOptions.SetReferencesResolver(NullPropagation.Instance);
engineOptions.Strict();

14
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs

@ -18,23 +18,21 @@ public sealed class NullPropagation : IReferenceResolver
public bool TryUnresolvableReference(Engine engine, Reference reference, out JsValue value)
{
value = reference.GetBase();
value = reference.Base;
return true;
}
public bool TryPropertyReference(Engine engine, Reference reference, ref JsValue value)
{
return value.IsNull() || value.IsUndefined();
}
public bool TryGetCallable(Engine engine, object reference, out JsValue value)
{
value = new ClrFunctionInstance(engine, "anonymous", (thisObj, _) => thisObj);
return true;
}
public bool TryPropertyReference(Engine engine, Reference reference, ref JsValue value)
{
return value.IsNull() || value.IsUndefined();
}
public bool CheckCoercible(JsValue value)
{
return true;

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs

@ -471,7 +471,7 @@ public sealed partial class ScriptingCompleter
private void Add(JsonType type, string? name, string? description, string[]? allowedValues = null, string? decprecationReason = null)
{
var parts = name?.Split('.') ?? Array.Empty<string>();
var parts = name?.Split('.') ?? [];
foreach (var part in parts)
{

26
backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Squidex.Domain.Apps.Core</RootNamespace>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<NeutralLanguage>en</NeutralLanguage>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -18,19 +18,19 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fluid.Core" Version="2.4.0" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Jint" Version="3.0.0-beta-2049" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Fluid.Core" Version="2.5.0" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Jint" Version="3.0.0-beta-2055" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="5.19.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="ValueTaskSupplement" Version="1.1.0" />
</ItemGroup>

4
backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs

@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Subscriptions;
public sealed class EventMessageEvaluator : IMessageEvaluator
{
private readonly Dictionary<DomainId, Dictionary<Guid, AppSubscription>> subscriptions = new Dictionary<DomainId, Dictionary<Guid, AppSubscription>>();
private readonly Dictionary<DomainId, Dictionary<Guid, AppSubscription>> subscriptions = [];
private readonly ReaderWriterLockSlim readerWriterLock = new ReaderWriterLockSlim();
public async ValueTask<IEnumerable<Guid>> GetSubscriptionsAsync(object message)
@ -34,7 +34,7 @@ public sealed class EventMessageEvaluator : IMessageEvaluator
{
if (await subscription.ShouldHandle(appEvent))
{
result ??= new List<Guid>();
result ??= [];
result.Add(id);
}
}

4
backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagsExport.cs

@ -9,7 +9,7 @@ namespace Squidex.Domain.Apps.Core.Tags;
public class TagsExport
{
public Dictionary<string, Tag> Tags { get; set; } = new Dictionary<string, Tag>();
public Dictionary<string, Tag> Tags { get; set; } = [];
public Dictionary<string, string> Alias { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Alias { get; set; } = [];
}

13
backend/src/Squidex.Domain.Apps.Core.Operations/Templates/TemplateParseException.cs

@ -5,8 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
namespace Squidex.Domain.Apps.Core.Templates;
[Serializable]
@ -20,17 +18,6 @@ public class TemplateParseException : Exception
Error = error;
}
protected TemplateParseException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Error = info.GetString(nameof(Error)) ?? string.Empty;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(nameof(Error), Error);
}
private static string BuildErrorMessage(string error, string template)
{
return $"Failed to parse template with <{error}>, template: {template}.";

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/RootContext.cs

@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent;
public sealed class RootContext
{
private readonly ConcurrentBag<ValidationError> errors = new ConcurrentBag<ValidationError>();
private readonly ConcurrentBag<ValidationError> errors = [];
private readonly Scheduler scheduler = new Scheduler();
public IJsonSerializer Serializer { get; }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs

@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent;
public sealed record ValidationContext(RootContext Root)
{
public ImmutableQueue<string> Path { get; init; } = ImmutableQueue<string>.Empty;
public ImmutableQueue<string> Path { get; init; } = [];
public bool IsOptional { get; init; }

6
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs

@ -184,17 +184,17 @@ public sealed class MongoContentCollection : MongoRepositoryBase<MongoContentEnt
{
if (q.Ids is { Count: > 0 })
{
return await queryByIds.QueryAsync(app, new List<ISchemaEntity> { schema }, q, ct);
return await queryByIds.QueryAsync(app, [schema], q, ct);
}
if (q.ScheduledFrom != null && q.ScheduledTo != null)
{
return await queryScheduled.QueryAsync(app, new List<ISchemaEntity> { schema }, q, ct);
return await queryScheduled.QueryAsync(app, [schema], q, ct);
}
if (q.Referencing != default)
{
return await queryReferences.QueryAsync(app, new List<ISchemaEntity> { schema }, q, ct);
return await queryReferences.QueryAsync(app, [schema], q, ct);
}
if (queryInDedicatedCollection != null)

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs

@ -162,7 +162,7 @@ public sealed class MongoContentEntity : IContentEntity, IVersionedEntity<Domain
entity.DocumentId = job.Value.UniqueId;
entity.IndexedAppId = job.Value.AppId.Id;
entity.IndexedSchemaId = job.Value.SchemaId.Id;
entity.ReferencedIds ??= new HashSet<DomainId>();
entity.ReferencedIds ??= [];
entity.Version = job.NewVersion;
var (app, schema) = await appProvider.GetAppWithSchemaAsync(entity.IndexedAppId, entity.IndexedSchemaId, true, ct);

8
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -18,8 +18,8 @@
<ProjectReference Include="..\Squidex.Domain.Apps.Entities\Squidex.Domain.Apps.Entities.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00015" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasIndexDefinition.cs

@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Text;
public static class AtlasIndexDefinition
{
private static readonly Dictionary<string, string> FieldPaths = new Dictionary<string, string>();
private static readonly Dictionary<string, string> FieldPaths = [];
private static readonly Dictionary<string, string> FieldAnalyzers = new Dictionary<string, string>
{
["iv"] = "lucene.standard",

6
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/LuceneQueryVisitor.cs

@ -204,15 +204,15 @@ public sealed class LuceneQueryVisitor
switch (clause.Occur)
{
case Occur.MUST:
musts ??= new BsonArray();
musts ??= [];
musts.Add(converted);
break;
case Occur.SHOULD:
shoulds ??= new BsonArray();
shoulds ??= [];
shoulds.Add(converted);
break;
case Occur.MUST_NOT:
mustNots ??= new BsonArray();
mustNots ??= [];
mustNots.Add(converted);
break;
}

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs

@ -37,7 +37,7 @@ public abstract class MongoTextIndexBase<T> : MongoRepositoryBase<MongoTextIndex
private sealed class SearchOperation
{
public List<(DomainId Id, double Score)> Results { get; } = new List<(DomainId Id, double Score)>();
public List<(DomainId Id, double Score)> Results { get; } = [];
public string SearchTerms { get; set; }

10
backend/src/Squidex.Domain.Apps.Entities/AppProvider.cs

@ -150,7 +150,7 @@ public sealed class AppProvider : IAppProvider
return indexForApps.GetAppsForUserAsync(userId, permissions, ct)!;
});
return apps?.ToList() ?? new List<IAppEntity>();
return apps?.ToList() ?? [];
}
public async Task<List<IAppEntity>> GetTeamAppsAsync(DomainId teamId,
@ -161,7 +161,7 @@ public sealed class AppProvider : IAppProvider
return indexForApps.GetAppsForTeamAsync(teamId, ct)!;
});
return apps?.ToList() ?? new List<IAppEntity>();
return apps?.ToList() ?? [];
}
public async Task<List<ITeamEntity>> GetUserTeamsAsync(string userId, CancellationToken ct = default)
@ -171,7 +171,7 @@ public sealed class AppProvider : IAppProvider
return indexForTeams.GetTeamsAsync(userId, ct)!;
});
return teams?.ToList() ?? new List<ITeamEntity>();
return teams?.ToList() ?? [];
}
public async Task<List<ISchemaEntity>> GetSchemasAsync(DomainId appId,
@ -191,7 +191,7 @@ public sealed class AppProvider : IAppProvider
}
}
return schemas?.ToList() ?? new List<ISchemaEntity>();
return schemas?.ToList() ?? [];
}
public async Task<List<IRuleEntity>> GetRulesAsync(DomainId appId,
@ -202,7 +202,7 @@ public sealed class AppProvider : IAppProvider
return indexForRules.GetRulesAsync(appId, ct)!;
});
return rules?.ToList() ?? new List<IRuleEntity>();
return rules?.ToList() ?? [];
}
public async Task<IRuleEntity?> GetRuleAsync(DomainId appId, DomainId id,

4
backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs

@ -32,7 +32,7 @@ public static class AppProviderExtensions
{
if (schemaId == schema.Id)
{
result ??= new Dictionary<DomainId, Schema>();
result ??= [];
result[schemaId] = schema.SchemaDef;
}
else if (result == null || !result.TryGetValue(schemaId, out _))
@ -41,7 +41,7 @@ public static class AppProviderExtensions
if (resolvedEntity != null)
{
result ??= new Dictionary<DomainId, Schema>();
result ??= [];
result[schemaId] = resolvedEntity.SchemaDef;
await ResolveSchemaAsync(resolvedEntity);

6
backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs

@ -28,11 +28,11 @@ public sealed class AppPermanentDeleter : IEventConsumer
this.factory = factory;
// Compute the event types names once for performance reasons and use hashset for extensibility.
consumingTypes = new HashSet<string>
{
consumingTypes =
[
typeRegistry.GetName<IEvent, AppDeleted>(),
typeRegistry.GetName<IEvent, AppContributorRemoved>()
};
];
}
public bool Handles(StoredEvent @event)

4
backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs

@ -13,8 +13,8 @@ namespace Squidex.Domain.Apps.Entities.Apps;
public sealed class RolePermissionsProvider
{
private readonly List<string> forAppSchemas = new List<string>();
private readonly List<string> forAppWithoutSchemas = new List<string>();
private readonly List<string> forAppSchemas = [];
private readonly List<string> forAppWithoutSchemas = [];
private readonly IAppProvider appProvider;
public RolePermissionsProvider(IAppProvider appProvider)

4
backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs

@ -15,8 +15,8 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates;
public sealed class StringLogger : ILogger, ILogLine
{
private const int MaxActionLength = 40;
private readonly List<string> lines = new List<string>();
private readonly List<string> errors = new List<string>();
private readonly List<string> lines = [];
private readonly List<string> errors = [];
private string startedLine = string.Empty;
public bool CanWriteToSameLine => false;

6
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs

@ -24,10 +24,10 @@ public sealed class AssetPermanentDeleter : IEventConsumer
this.assetFileStore = assetFileStore;
// Compute the event types names once for performance reasons and use hashset for extensibility.
consumingTypes = new HashSet<string>
{
consumingTypes =
[
typeRegistry.GetName<IEvent, AssetDeleted>()
};
];
}
public bool Handles(StoredEvent @event)

4
backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs

@ -22,8 +22,8 @@ public sealed class BackupAssets : IBackupHandler
private const int BatchSize = 100;
private const string TagsFile = "AssetTags.json";
private const string TagsAliasFile = "AssetTagsAlias.json";
private readonly HashSet<DomainId> assetIds = new HashSet<DomainId>();
private readonly HashSet<DomainId> assetFolderIds = new HashSet<DomainId>();
private readonly HashSet<DomainId> assetIds = [];
private readonly HashSet<DomainId> assetFolderIds = [];
private readonly Rebuilder rebuilder;
private readonly IAssetFileStore assetFileStore;
private readonly ITagService tagService;

4
backend/src/Squidex.Domain.Apps.Entities/Assets/Commands/UploadAssetCommand.cs

@ -12,11 +12,11 @@ namespace Squidex.Domain.Apps.Entities.Assets.Commands;
public abstract class UploadAssetCommand : AssetCommand
{
public HashSet<string> Tags { get; set; } = new HashSet<string>();
public HashSet<string> Tags { get; set; } = [];
public AssetFile File { get; set; }
public AssetMetadata Metadata { get; } = new AssetMetadata();
public AssetMetadata Metadata { get; } = [];
public AssetType Type { get; set; }

4
backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs

@ -155,12 +155,12 @@ public partial class AssetDomainObject
{
if (Tags == null)
{
Tags = new HashSet<string>();
Tags = [];
}
if (Metadata == null)
{
Metadata = new AssetMetadata();
Metadata = [];
}
}
}

5
backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs

@ -29,10 +29,7 @@ public sealed class AssetLoader : IAssetLoader
var asset = await GetCachedAsync(uniqueId, version, ct);
if (asset == null)
{
asset = await GetAsync(uniqueId, version, ct);
}
asset ??= await GetAsync(uniqueId, version, ct);
if (asset is not { Version: > EtagVersion.Empty } || (version > EtagVersion.Any && asset.Version != version))
{

2
backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs

@ -104,7 +104,7 @@ public class AssetQueryParser
private static void WithSorting(ClrQuery query)
{
query.Sort ??= new List<SortNode>();
query.Sort ??= [];
if (query.Sort.Count == 0)
{

2
backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/Steps/ConvertTags.cs

@ -31,7 +31,7 @@ public sealed class ConvertTags : IAssetEnricherStep
foreach (var asset in assets)
{
asset.TagNames = new HashSet<string>();
asset.TagNames = [];
if (asset.Tags != null)
{

6
backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs

@ -39,10 +39,10 @@ public sealed class RecursiveDeleter : IEventConsumer
this.log = log;
// Compute the event types names once for performance reasons and use hashset for extensibility.
consumingTypes = new HashSet<string>
{
consumingTypes =
[
typeRegistry.GetName<IEvent, AssetFolderDeleted>()
};
];
}
public bool Handles(StoredEvent @event)

7
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupRestoreException.cs

@ -5,8 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
namespace Squidex.Domain.Apps.Entities.Backup;
[Serializable]
@ -16,9 +14,4 @@ public class BackupRestoreException : Exception
: base(message, inner)
{
}
protected BackupRestoreException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}

4
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs

@ -19,13 +19,13 @@ public sealed class BackupWorker :
IMessageHandler<BackupClear>,
IInitializable
{
private readonly Dictionary<DomainId, Task<BackupProcessor>> backupProcessors = new Dictionary<DomainId, Task<BackupProcessor>>();
private readonly Dictionary<DomainId, Task<BackupProcessor>> backupProcessors = [];
private readonly Func<DomainId, BackupProcessor> backupFactory;
private readonly RestoreProcessor restoreProcessor;
public BackupWorker(IServiceProvider serviceProvider)
{
var objectFactory = ActivatorUtilities.CreateFactory(typeof(BackupProcessor), new[] { typeof(DomainId) });
var objectFactory = ActivatorUtilities.CreateFactory(typeof(BackupProcessor), [typeof(DomainId)]);
backupFactory = key =>
{

2
backend/src/Squidex.Domain.Apps.Entities/Backup/State/BackupState.cs

@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Entities.Backup.State;
public sealed class BackupState
{
public List<BackupJob> Jobs { get; set; } = new List<BackupJob>();
public List<BackupJob> Jobs { get; set; } = [];
public void EnsureCanStart()
{

2
backend/src/Squidex.Domain.Apps.Entities/Backup/State/RestoreJob.cs

@ -27,7 +27,7 @@ public sealed class RestoreJob : IRestoreJob
public Instant? Stopped { get; set; }
public List<string> Log { get; set; } = new List<string>();
public List<string> Log { get; set; } = [];
public JobStatus Status { get; set; }

2
backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs

@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Entities.Backup;
public sealed class UserMapping : IUserMapping
{
private const string UsersFile = "Users.json";
private readonly Dictionary<string, RefToken> userMap = new Dictionary<string, RefToken>();
private readonly Dictionary<string, RefToken> userMap = [];
private readonly RefToken initiator;
public RefToken Initiator

2
backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs

@ -20,7 +20,7 @@ public sealed class ConfigPlansProvider : IBillingPlans
};
private readonly Dictionary<string, Plan> plansById = new Dictionary<string, Plan>(StringComparer.OrdinalIgnoreCase);
private readonly List<Plan> plans = new List<Plan>();
private readonly List<Plan> plans = [];
private readonly Plan freePlan;
public ConfigPlansProvider(IEnumerable<Plan> config)

2
backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs

@ -26,7 +26,7 @@ public sealed class UsageNotifierWorker : IMessageHandler<UsageTrackingCheck>, I
[CollectionName("UsageNotifications")]
public sealed class State
{
public Dictionary<DomainId, DateTime> NotificationsSent { get; set; } = new Dictionary<DomainId, DateTime>();
public Dictionary<DomainId, DateTime> NotificationsSent { get; set; } = [];
}
public IClock Clock { get; set; } = SystemClock.Instance;

6
backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs

@ -23,7 +23,7 @@ public sealed class BackupContents : IBackupHandler
{
private const int BatchSize = 100;
private const string UrlsFile = "Urls.json";
private readonly Dictionary<DomainId, HashSet<DomainId>> contentIdsBySchemaId = new Dictionary<DomainId, HashSet<DomainId>>();
private readonly Dictionary<DomainId, HashSet<DomainId>> contentIdsBySchemaId = [];
private readonly Rebuilder rebuilder;
private readonly IUrlGenerator urlGenerator;
private Urls? assetsUrlNew;
@ -116,7 +116,7 @@ public sealed class BackupContents : IBackupHandler
if (!ReferenceEquals(newValue, s))
{
replacements ??= new List<(string, string)>();
replacements ??= [];
replacements.Add((key, newValue));
break;
}
@ -125,7 +125,7 @@ public sealed class BackupContents : IBackupHandler
if (!ReferenceEquals(newValue, s))
{
replacements ??= new List<(string, string)>();
replacements ??= [];
replacements.Add((key, newValue));
break;
}

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Counter/CounterService.cs

@ -18,7 +18,7 @@ public sealed class CounterService : ICounterService, IDeleter
[CollectionName("Counters")]
public sealed class State
{
public Dictionary<string, long> Counters { get; set; } = new Dictionary<string, long>();
public Dictionary<string, long> Counters { get; set; } = [];
public bool Increment(string name)
{

6
backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs

@ -18,11 +18,11 @@ public sealed class DefaultContentWorkflow : IContentWorkflow
private static readonly StatusInfo InfoPublished = new StatusInfo(Status.Published, StatusColors.Published);
private static readonly StatusInfo[] All =
{
[
InfoArchived,
InfoDraft,
InfoPublished
};
];
private static readonly Dictionary<Status, (StatusInfo Info, StatusInfo[] Transitions)> Flow =
new Dictionary<Status, (StatusInfo Info, StatusInfo[] Transitions)>
@ -90,7 +90,7 @@ public sealed class DefaultContentWorkflow : IContentWorkflow
public ValueTask<StatusInfo[]> GetNextAsync(IContentEntity content, Status status, ClaimsPrincipal? user)
{
var result = Flow.TryGetValue(status, out var step) ? step.Transitions : Array.Empty<StatusInfo>();
var result = Flow.TryGetValue(status, out var step) ? step.Transitions : [];
return ValueTask.FromResult(result);
}

8
backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentsBulkUpdateCommandMiddleware.cs

@ -237,7 +237,7 @@ public sealed class ContentsBulkUpdateCommandMiddleware : ICommandMiddleware
if (id != null)
{
return new[] { id.Value };
return [id.Value];
}
if (bulkJob.Query != null)
@ -256,7 +256,7 @@ public sealed class ContentsBulkUpdateCommandMiddleware : ICommandMiddleware
// Therefore we create a new ID if we cannot find the ID for the query.
if (existingResult.Count == 0 && bulkJob.Type == BulkUpdateContentType.Upsert)
{
return new[] { DomainId.NewGuid() };
return [DomainId.NewGuid()];
}
return existingResult.Select(x => x.Id).ToArray();
@ -264,9 +264,9 @@ public sealed class ContentsBulkUpdateCommandMiddleware : ICommandMiddleware
if (bulkJob.Type is BulkUpdateContentType.Create or BulkUpdateContentType.Upsert)
{
return new[] { DomainId.NewGuid() };
return [DomainId.NewGuid()];
}
return Array.Empty<DomainId>();
return [];
}
}

4
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs

@ -88,7 +88,7 @@ public sealed class GraphQLExecutionContext : QueryExecutionContext
public IDataLoaderResult<IEnrichedAssetEntity?> GetAsset(DomainId id,
TimeSpan cacheDuration)
{
var assets = GetAssets(new List<DomainId> { id }, cacheDuration);
var assets = GetAssets([id], cacheDuration);
var asset = assets.Then(x => x.FirstOrDefault());
return asset;
@ -97,7 +97,7 @@ public sealed class GraphQLExecutionContext : QueryExecutionContext
public IDataLoaderResult<IEnrichedContentEntity?> GetContent(DomainId schemaId, DomainId id, HashSet<string>? fields,
TimeSpan cacheDuration)
{
var contents = GetContents(new List<DomainId> { id }, fields, cacheDuration);
var contents = GetContents([id], fields, cacheDuration);
var content = contents.Then(x => x.FirstOrDefault(x => x.SchemaId.Id == schemaId));
return content;

32
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs

@ -21,15 +21,15 @@ internal static class AssetActions
{
public static class Metadata
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.String)
{
Name = "path",
Description = FieldDescriptions.JsonPath,
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Sync<IEnrichedAssetEntity, object?>((source, fieldContext, _) =>
{
@ -47,15 +47,15 @@ internal static class AssetActions
public static class Find
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.NonNullString)
{
Name = "id",
Description = "The ID of the asset (usually GUID).",
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Sync<object, object?>((_, fieldContext, context) =>
{
@ -68,8 +68,8 @@ internal static class AssetActions
public static class Query
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.Int)
{
Name = "top",
@ -93,8 +93,8 @@ internal static class AssetActions
Name = "orderby",
Description = FieldDescriptions.QueryOrderBy,
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Async<object, object>(async (_, fieldContext, context) =>
{
@ -119,15 +119,15 @@ internal static class AssetActions
public static class Subscription
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.EnrichedAssetEventType)
{
Name = "type",
Description = FieldDescriptions.EventType,
DefaultValue = null
}
};
},
];
public static readonly ISourceStreamResolver Resolver = Resolvers.Stream(PermissionIds.AppAssetsRead, c =>
{

20
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs

@ -22,19 +22,19 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types;
internal sealed class Builder
{
private readonly Dictionary<FieldInfo, ComponentUnionGraphType> componentUnionTypes = new ();
private readonly Dictionary<FieldInfo, EmbeddableStringGraphType> embeddableStringTypes = new ();
private readonly Dictionary<FieldInfo, NestedGraphType> nestedTypes = new ();
private readonly Dictionary<SchemaInfo, ComponentGraphType> componentTypes = new ();
private readonly Dictionary<SchemaInfo, ContentGraphType> contentTypes = new ();
private readonly Dictionary<SchemaInfo, ContentResultGraphType> contentResultTypes = new ();
private readonly Dictionary<string, ContentUnionGraphType> unionTypes = new ();
private readonly Dictionary<string, EnumerationGraphType?> enumTypes = new ();
private readonly Dictionary<string, IGraphType[]> dynamicTypes = new ();
private readonly Dictionary<FieldInfo, ComponentUnionGraphType> componentUnionTypes = [];
private readonly Dictionary<FieldInfo, EmbeddableStringGraphType> embeddableStringTypes = [];
private readonly Dictionary<FieldInfo, NestedGraphType> nestedTypes = [];
private readonly Dictionary<SchemaInfo, ComponentGraphType> componentTypes = [];
private readonly Dictionary<SchemaInfo, ContentGraphType> contentTypes = [];
private readonly Dictionary<SchemaInfo, ContentResultGraphType> contentResultTypes = [];
private readonly Dictionary<string, ContentUnionGraphType> unionTypes = [];
private readonly Dictionary<string, EnumerationGraphType?> enumTypes = [];
private readonly Dictionary<string, IGraphType[]> dynamicTypes = [];
private readonly FieldVisitor fieldVisitor;
private readonly FieldInputVisitor fieldInputVisitor;
private readonly PartitionResolver partitionResolver;
private readonly HashSet<SchemaInfo> allSchemas = new HashSet<SchemaInfo>();
private readonly HashSet<SchemaInfo> allSchemas = [];
private readonly ReservedNames typeNames = ReservedNames.ForTypes();
private readonly GraphQLOptions options;

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentUnionGraphType.cs

@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
internal sealed class ComponentUnionGraphType : UnionGraphType
{
private readonly Dictionary<string, IObjectGraphType> types = new Dictionary<string, IObjectGraphType>();
private readonly Dictionary<string, IObjectGraphType> types = [];
public bool HasType => types.Count > 0;

104
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs

@ -23,15 +23,15 @@ internal static class ContentActions
{
public static class Json
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.String)
{
Name = "path",
Description = FieldDescriptions.JsonPath,
DefaultValue = null
}
};
},
];
public static readonly ValueResolver<object> Resolver = (value, fieldContext, context) =>
{
@ -48,20 +48,20 @@ internal static class ContentActions
};
}
public static readonly QueryArguments JsonPath = new QueryArguments
{
public static readonly QueryArguments JsonPath =
[
new QueryArgument(Scalars.String)
{
Name = "path",
Description = FieldDescriptions.JsonPath,
DefaultValue = null
}
};
},
];
public static class Find
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.NonNullString)
{
Name = "id",
@ -73,8 +73,8 @@ internal static class ContentActions
Name = "version",
Description = FieldDescriptions.QueryVersion,
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Sync<object, object?>((_, fieldContext, context) =>
{
@ -98,15 +98,15 @@ internal static class ContentActions
public static class FindSingleton
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.Int)
{
Name = "version",
Description = FieldDescriptions.QueryVersion,
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Sync<object, object?>((_, fieldContext, context) =>
{
@ -128,15 +128,15 @@ internal static class ContentActions
public static class QueryByIds
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.NonNullStrings)
{
Name = "ids",
Description = FieldDescriptions.EntityIds,
DefaultValue = null,
}
};
},
];
public static readonly IFieldResolver Resolver = Resolvers.Sync<object, object?>((_, fieldContext, context) =>
{
@ -150,8 +150,8 @@ internal static class ContentActions
public static class QueryOrReferencing
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.Int)
{
Name = "top",
@ -181,8 +181,8 @@ internal static class ContentActions
Name = "search",
Description = FieldDescriptions.QuerySearch,
DefaultValue = null
}
};
},
];
public static readonly IFieldResolver Query = Resolvers.Async<object, object>(async (_, fieldContext, context) =>
{
@ -268,8 +268,8 @@ internal static class ContentActions
{
public static QueryArguments Arguments(IGraphType inputType)
{
return new QueryArguments
{
return
[
new QueryArgument(new NonNullGraphType(inputType))
{
Name = "data",
@ -293,8 +293,8 @@ internal static class ContentActions
Name = "id",
Description = FieldDescriptions.ContentRequestOptionalId,
DefaultValue = null
}
};
},
];
}
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsCreate, c =>
@ -324,8 +324,8 @@ internal static class ContentActions
{
public static QueryArguments Arguments(IGraphType inputType)
{
return new QueryArguments
{
return
[
new QueryArgument(Scalars.NonNullString)
{
Name = "id",
@ -361,8 +361,8 @@ internal static class ContentActions
Name = "expectedVersion",
Description = FieldDescriptions.EntityExpectedVersion,
DefaultValue = EtagVersion.Any
}
};
},
];
}
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsUpsert, c =>
@ -395,8 +395,8 @@ internal static class ContentActions
{
public static QueryArguments Arguments(IGraphType inputType)
{
return new QueryArguments
{
return
[
new QueryArgument(Scalars.String)
{
Name = "id",
@ -414,8 +414,8 @@ internal static class ContentActions
Name = "expectedVersion",
Description = FieldDescriptions.EntityExpectedVersion,
DefaultValue = EtagVersion.Any
}
};
},
];
}
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsUpdateOwn, c =>
@ -432,8 +432,8 @@ internal static class ContentActions
{
public static QueryArguments Arguments(IGraphType inputType)
{
return new QueryArguments
{
return
[
new QueryArgument(Scalars.String)
{
Name = "id",
@ -451,8 +451,8 @@ internal static class ContentActions
Name = "expectedVersion",
Description = FieldDescriptions.EntityExpectedVersion,
DefaultValue = EtagVersion.Any
}
};
},
];
}
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsUpdateOwn, c =>
@ -467,8 +467,8 @@ internal static class ContentActions
public static class ChangeStatus
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.NonNullString)
{
Name = "id",
@ -492,8 +492,8 @@ internal static class ContentActions
Name = "expectedVersion",
Description = FieldDescriptions.EntityExpectedVersion,
DefaultValue = EtagVersion.Any
}
};
},
];
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsChangeStatusOwn, c =>
{
@ -510,8 +510,8 @@ internal static class ContentActions
public static class Delete
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.NonNullString)
{
Name = "id",
@ -523,8 +523,8 @@ internal static class ContentActions
Name = "expectedVersion",
Description = FieldDescriptions.EntityExpectedVersion,
DefaultValue = EtagVersion.Any
}
};
},
];
public static readonly IFieldResolver Resolver = ContentCommand(PermissionIds.AppContentsDeleteOwn, c =>
{
@ -534,8 +534,8 @@ internal static class ContentActions
public static class Subscription
{
public static readonly QueryArguments Arguments = new QueryArguments
{
public static readonly QueryArguments Arguments =
[
new QueryArgument(Scalars.EnrichedContentEventType)
{
Name = "type",
@ -547,8 +547,8 @@ internal static class ContentActions
Name = "schemaName",
Description = FieldDescriptions.ContentSchemaName,
DefaultValue = null
}
};
},
];
public static readonly ISourceStreamResolver Resolver = Resolvers.Stream(PermissionIds.AppContentsRead, c =>
{

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentUnionGraphType.cs

@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
internal sealed class ContentUnionGraphType : UnionGraphType
{
private readonly Dictionary<DomainId, IObjectGraphType> types = new Dictionary<DomainId, IObjectGraphType>();
private readonly Dictionary<DomainId, IObjectGraphType> types = [];
// We need the schema identity at runtime.
public IReadOnlyDictionary<DomainId, IObjectGraphType> SchemaTypes => types;

4
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Dynamic/DynamicSchemaBuilder.cs

@ -15,7 +15,7 @@ internal static class DynamicSchemaBuilder
{
if (string.IsNullOrWhiteSpace(typeDefinitions))
{
return Array.Empty<IGraphType>();
return [];
}
Schema schema;
@ -25,7 +25,7 @@ internal static class DynamicSchemaBuilder
}
catch
{
return Array.Empty<IGraphType>();
return [];
}
var map = schema.AdditionalTypeInstances.ToDictionary(x => x.Name);

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/FieldMap.cs

@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types;
internal sealed class FieldMap
{
private readonly Dictionary<string, Dictionary<string, string>> schemas = new Dictionary<string, Dictionary<string, string>>();
private readonly Dictionary<string, Dictionary<string, string>> schemas = [];
public FieldMap(IEnumerable<SchemaInfo> source)
{

4
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedExtensions.cs

@ -160,7 +160,7 @@ public static class SharedExtensions
{
if (item.Value is string id)
{
result ??= new List<DomainId>();
result ??= [];
result.Add(DomainId.Create(id));
}
}
@ -193,7 +193,7 @@ public static class SharedExtensions
{
private readonly GraphQLDocument document;
private readonly ISchema schema;
private HashSet<string>? fieldNames = new HashSet<string>();
private HashSet<string>? fieldNames = [];
private IComplexGraphType? currentParent;
public FieldNameResolver(GraphQLDocument document, ISchema schema)

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs

@ -149,7 +149,7 @@ public class ContentQueryParser
private static void WithSorting(ClrQuery query)
{
query.Sort ??= new List<SortNode>();
query.Sort ??= [];
if (query.Sort.Count == 0)
{

5
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs

@ -228,10 +228,7 @@ public sealed class ContentQueryService : IContentQueryService
schema = await appProvider.GetSchemaAsync(context.App.Id, schemaId, canCache, ct);
}
if (schema == null)
{
schema = await appProvider.GetSchemaAsync(context.App.Id, schemaIdOrName, canCache, ct);
}
schema ??= await appProvider.GetSchemaAsync(context.App.Id, schemaIdOrName, canCache, ct);
if (schema != null && !HasPermission(context, schema, PermissionIds.AppContentsReadOwn))
{

8
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichWithWorkflows.cs

@ -48,14 +48,14 @@ public sealed class EnrichWithWorkflows : IContentEnricherStep
{
if (editingStatus == Status.Draft)
{
content.NextStatuses = new[]
{
content.NextStatuses =
[
new StatusInfo(Status.Published, StatusColors.Published)
};
];
}
else
{
content.NextStatuses = Array.Empty<StatusInfo>();
content.NextStatuses = [];
}
}
else

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveAssets.cs

@ -71,7 +71,7 @@ public sealed class ResolveAssets : IContentEnricherStep
{
foreach (var content in contents)
{
content.ReferenceData ??= new ContentData();
content.ReferenceData ??= [];
var fieldReference = content.ReferenceData.GetOrAdd(field.Name, _ => new ContentFieldData())!;
@ -79,7 +79,7 @@ public sealed class ResolveAssets : IContentEnricherStep
{
foreach (var (partitionKey, partitionValue) in fieldData)
{
fieldIds ??= new HashSet<DomainId>();
fieldIds ??= [];
fieldIds.Clear();
partitionValue.AddReferencedIds(field, fieldIds, components);

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveReferences.cs

@ -73,7 +73,7 @@ public sealed class ResolveReferences : IContentEnricherStep
{
foreach (var content in contents)
{
content.ReferenceData ??= new ContentData();
content.ReferenceData ??= [];
var fieldReference = content.ReferenceData.GetOrAdd(field.Name, _ => new ContentFieldData())!;
@ -83,7 +83,7 @@ public sealed class ResolveReferences : IContentEnricherStep
{
foreach (var (partition, partitionValue) in fieldData)
{
fieldIds ??= new HashSet<DomainId>();
fieldIds ??= [];
fieldIds.Clear();
partitionValue.AddReferencedIds(field, fieldIds, components);

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs

@ -31,7 +31,7 @@ public static class Extensions
if (geoJson != null)
{
result ??= new Dictionary<string, Geometry>();
result ??= [];
result[$"{field}.{key}"] = geoJson;
}
}
@ -65,7 +65,7 @@ public static class Extensions
{
if (sb.Length > 0)
{
result ??= new Dictionary<string, string>();
result ??= [];
result[key] = sb.ToString();
}
}

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs

@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State;
public sealed class InMemoryTextIndexerState : ITextIndexerState
{
private readonly Dictionary<DomainId, TextContentState> states = new Dictionary<DomainId, TextContentState>();
private readonly Dictionary<DomainId, TextContentState> states = [];
public Task ClearAsync(
CancellationToken ct = default)

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs

@ -38,8 +38,8 @@ public sealed class TextIndexingProcess : IEventConsumer
{
private readonly Dictionary<DomainId, TextContentState> states;
private readonly IJsonSerializer serializer;
private readonly Dictionary<DomainId, TextContentState> updates = new Dictionary<DomainId, TextContentState>();
private readonly Dictionary<string, IndexCommand> commands = new Dictionary<string, IndexCommand>();
private readonly Dictionary<DomainId, TextContentState> updates = [];
private readonly Dictionary<string, IndexCommand> commands = [];
public Updates(Dictionary<DomainId, TextContentState> states, IJsonSerializer serializer)
{

2
backend/src/Squidex.Domain.Apps.Entities/ContextHeaders.cs

@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Entities;
public static class ContextHeaders
{
private static readonly char[] Separators = { ',', ';' };
private static readonly char[] Separators = [',', ';'];
public const string KeyBatchSize = "X-BatchSize";
public const string KeyNoCacheKeys = "X-NoCacheKeys";

2
backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs

@ -26,7 +26,7 @@ public sealed class HistoryEvent
public string EventType { get; set; }
public Dictionary<string, string> Parameters { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Parameters { get; set; } = [];
public HistoryEvent()
{

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save