diff --git a/Dockerfile b/Dockerfile index 4aa37d447..1fe474f1e 100644 --- a/Dockerfile +++ b/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"] diff --git a/backend/.editorconfig b/backend/.editorconfig index afd4c9dd8..facac6742 100644 --- a/backend/.editorconfig +++ b/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 diff --git a/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs index d3c60f317..95f2287ef 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs @@ -144,7 +144,7 @@ public sealed class AlgoliaContent public string ObjectID { get; set; } [JsonExtensionData] - public Dictionary More { get; set; } = new Dictionary(); + public Dictionary More { get; set; } = []; } public sealed class AlgoliaJob diff --git a/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs index a31116057..fc2cd94fb 100644 --- a/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs @@ -149,7 +149,7 @@ public sealed class ElasticSearchContent public string ContentId { get; set; } [JsonExtensionData] - public Dictionary More { get; set; } = new Dictionary(); + public Dictionary More { get; set; } = []; } public sealed class ElasticSearchJob diff --git a/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaProducer.cs b/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaProducer.cs index 0f6da694a..954fa471c 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaProducer.cs +++ b/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) { diff --git a/backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs index 776c8b831..677e941c8 100644 --- a/backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/OpenSearch/OpenSearchActionHandler.cs @@ -149,7 +149,7 @@ public sealed class OpenSearchContent public string ContentId { get; set; } [JsonExtensionData] - public Dictionary More { get; set; } = new Dictionary(); + public Dictionary More { get; set; } = []; } public sealed class OpenSearchJob diff --git a/backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs index 0224a4ce2..020b0f68e 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Typesense/TypesenseActionHandler.cs @@ -136,7 +136,7 @@ public sealed class TypesenseContent public string Id { get; set; } [JsonExtensionData] - public Dictionary More { get; set; } = new Dictionary(); + public Dictionary More { get; set; } = []; } public sealed class TypesenseJob diff --git a/backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs b/backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs index 628066850..0b3e355de 100644 --- a/backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs +++ b/backend/extensions/Squidex.Extensions/Assets/Azure/AzureMetadataSource.cs @@ -22,17 +22,17 @@ public sealed class AzureMetadataSource : IAssetMetadataSource private readonly ILogger log; private readonly ComputerVisionClient client; private readonly char[] trimChars = - { + [ ' ', '_', '-' - }; - private readonly List features = new List - { + ]; + private readonly List 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(); + command.Tags ??= []; if (result.Color?.DominantColorForeground != null) { diff --git a/backend/extensions/Squidex.Extensions/Samples/Middleware/DoubleLinkedContentMiddleware.cs b/backend/extensions/Squidex.Extensions/Samples/Middleware/DoubleLinkedContentMiddleware.cs index 67c90c372..665c2f7da 100644 --- a/backend/extensions/Squidex.Extensions/Samples/Middleware/DoubleLinkedContentMiddleware.cs +++ b/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().SelectMany(x => x).SingleOrDefault().ToString(); + return fieldData?.Values.Select(x => x.Value).OfType().SelectMany(x => x).SingleOrDefault().ToString(); } return null; diff --git a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj index 884c1e0bc..64ace7aa3 100644 --- a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj +++ b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj @@ -1,44 +1,45 @@  - net7.0 + net8.0 latest enable - enable + enable - - - - - - - - - + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj b/backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj index 1adeb37db..43902a781 100644 --- a/backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj +++ b/backend/i18n/translator/Squidex.Translator/Squidex.Translator.csproj @@ -1,27 +1,27 @@ - + Exe - net7.0 + net8.0 latest enable - NU1608 + NU1608 - + - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/backend/src/Migrations/Migrations.csproj b/backend/src/Migrations/Migrations.csproj index 70a27707b..e483f4c58 100644 --- a/backend/src/Migrations/Migrations.csproj +++ b/backend/src/Migrations/Migrations.csproj @@ -1,12 +1,12 @@ - + - net7.0 + net8.0 latest enable enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Migrations/OldEvents/AssetCreated.cs b/backend/src/Migrations/OldEvents/AssetCreated.cs index 84b8c9379..716246d0e 100644 --- a/backend/src/Migrations/OldEvents/AssetCreated.cs +++ b/backend/src/Migrations/OldEvents/AssetCreated.cs @@ -44,7 +44,7 @@ public sealed class AssetCreated : AssetEvent, IMigrated { var result = SimpleMapper.Map(this, new AssetCreatedV2()); - result.Metadata = new AssetMetadata(); + result.Metadata = []; if (IsImage && PixelWidth != null && PixelHeight != null) { diff --git a/backend/src/Migrations/OldEvents/AssetUpdated.cs b/backend/src/Migrations/OldEvents/AssetUpdated.cs index 41951cad1..376463a92 100644 --- a/backend/src/Migrations/OldEvents/AssetUpdated.cs +++ b/backend/src/Migrations/OldEvents/AssetUpdated.cs @@ -35,7 +35,7 @@ public sealed class AssetUpdated : AssetEvent, IMigrated { var result = SimpleMapper.Map(this, new AssetUpdatedV2()); - result.Metadata = new AssetMetadata(); + result.Metadata = []; if (IsImage && PixelWidth != null && PixelHeight != null) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppSettings.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppSettings.cs index 8505af3a2..785ad0599 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppSettings.cs +++ b/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 Patterns { get; init; } = ReadonlyList.Empty(); + public ReadonlyList Patterns { get; init; } = []; - public ReadonlyList Editors { get; init; } = ReadonlyList.Empty(); + public ReadonlyList Editors { get; init; } = []; public bool HideScheduler { get; init; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs index caef4b336..406ea63bf 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguageConfig.cs @@ -16,7 +16,7 @@ public sealed record LanguageConfig(bool IsOptional = false, ReadonlyList Fallbacks { get; } = Fallbacks ?? ReadonlyList.Empty(); + public ReadonlyList Fallbacks { get; } = Fallbacks ?? []; internal LanguageConfig Cleanup(string self, IReadOnlyDictionary allowed) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs index e8b4d9f40..e6568a247 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs +++ b/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 ExtraPermissions = new HashSet - { + private static readonly HashSet 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); diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs index 9fa72d9e0..82b1687ac 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs +++ b/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 { - private static readonly char[] PathSeparators = { '.', '[', ']' }; + private static readonly char[] PathSeparators = ['.', '[', ']']; public const string FocusX = "focusX"; public const string FocusY = "focusY"; diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs index 8528da1ee..8c58bf46f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs @@ -115,7 +115,7 @@ public sealed class ContentData : Dictionary, IEquata public static ContentData Merge(params ContentData[] contents) { - return MergeTo(new ContentData(), contents); + return MergeTo([], contents); } public ContentData MergeInto(ContentData target) diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs index dc13455ef..a653ecf28 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowTransitionSurrogate.cs @@ -30,7 +30,7 @@ public sealed class WorkflowTransitionSurrogate : ISurrogate if (!string.IsNullOrEmpty(Role)) { - roles = new[] { Role }; + roles = [Role]; } return WorkflowTransition.When(Expression, roles); diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs index e7c7a704f..65738fd66 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs @@ -24,7 +24,7 @@ public sealed record Workflow(Status Initial, ReadonlyDictionary Steps { get; } = Steps ?? ReadonlyDictionary.Empty(); - public ReadonlyList SchemaIds { get; } = SchemaIds ?? ReadonlyList.Empty(); + public ReadonlyList SchemaIds { get; } = SchemaIds ?? []; public static Workflow CreateDefault(string? name = null) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs index 737c65b58..465702f11 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs @@ -14,8 +14,8 @@ public sealed class FieldCollection where T : IField { public static readonly FieldCollection Empty = new FieldCollection(); - private static readonly Dictionary EmptyById = new Dictionary(); - private static readonly Dictionary EmptyByString = new Dictionary(); + private static readonly Dictionary EmptyById = []; + private static readonly Dictionary EmptyByString = []; private readonly T[] fieldsOrdered; private Dictionary? fieldsById; @@ -68,7 +68,7 @@ public sealed class FieldCollection where T : IField private FieldCollection() { - fieldsOrdered = Array.Empty(); + fieldsOrdered = []; } public FieldCollection(T[] fields) diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldNames.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldNames.cs index 31bed6288..7c86bfb27 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldNames.cs +++ b/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 { - public static readonly FieldNames Empty = new FieldNames(new List()); + public static readonly new FieldNames Empty = new FieldNames(new List()); public FieldNames() { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRules.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRules.cs index f6dcefcec..3c79c44b9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRules.cs +++ b/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 { - public static readonly FieldRules Empty = new FieldRules(new List()); + public static readonly new FieldRules Empty = new FieldRules(new List()); public FieldRules() { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/FieldSurrogate.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/FieldSurrogate.cs index 337b28f0e..7440728b2 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/FieldSurrogate.cs +++ b/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(); + var nested = Children?.Select(n => n.ToNestedField()).ToArray() ?? []; return new ArrayField(Id, Name, partitioning, nested, arrayProperties, this); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs index 860bdc644..01cda0c08 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/SchemaSurrogate.cs @@ -86,7 +86,7 @@ public sealed class SchemaSurrogate : ISurrogate public Schema ToSource() { - var fields = Fields?.Select(f => f.ToField()).ToArray() ?? Array.Empty(); + var fields = Fields?.Select(f => f.ToField()).ToArray() ?? []; var schema = new Schema(Name, fields, Properties, IsPublished, Type); diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs index 09caeeb8e..28aee27c9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ResolvedComponents.cs @@ -33,7 +33,7 @@ public sealed class ResolvedComponents : ReadonlyDictionary { if (TryGetValue(schemaId, out var schema)) { - result ??= new Dictionary(); + result ??= []; result[schemaId] = schema; } } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj index 7748b2ec0..362489aad 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj @@ -1,10 +1,10 @@  - net7.0 + net8.0 Squidex.Domain.Apps.Core latest enable - en + en enable @@ -12,15 +12,15 @@ True - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddDefaultValues.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddDefaultValues.cs index aa630f436..66ab847a4 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddDefaultValues.cs +++ b/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] = []; } } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs index d7685db3f..89ea8a27a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs +++ b/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 dataConverters = new List(); - private readonly List itemConverters = new List(); - private readonly List fieldConverters = new List(); - private readonly List valueConverters = new List(); + private readonly List dataConverters = []; + private readonly List itemConverters = []; + private readonly List fieldConverters = []; + private readonly List valueConverters = []; private readonly ResolvedComponents components; private readonly Schema schema; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs index 9374c4698..b5ae865d5 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs +++ b/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 contentsPatterns = new List(); - private readonly List assetsPatterns = new List(); + private readonly List contentsPatterns = []; + private readonly List assetsPatterns = []; public StringReferenceExtractor(IUrlGenerator urlGenerator) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs index 6bdd99518..63f88fa17 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs @@ -197,7 +197,7 @@ internal sealed class JsonTypeVisitor : IFieldVisitor { - ["schemaIds"] = field.Properties.SchemaIds ?? ReadonlyList.Empty() + ["schemaIds"] = field.Properties.SchemaIds ?? [] }; property.UniqueItems = !field.Properties.AllowDuplicates; @@ -218,7 +218,7 @@ internal sealed class JsonTypeVisitor : IFieldVisitor(); + var names = property.EnumerationNames ??= []; foreach (var value in field.Properties.AllowedValues) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/PredefinedPatternsFormatter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/PredefinedPatternsFormatter.cs index 9c5b8ac8d..000a8cc3f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/PredefinedPatternsFormatter.cs +++ b/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 Replacer)> patterns = new List<(string Pattern, Func Replacer)>(); + private readonly List<(string Pattern, Func Replacer)> patterns = []; private readonly IUrlGenerator urlGenerator; public PredefinedPatternsFormatter(IUrlGenerator urlGenerator) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionDefinition.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionDefinition.cs index 4406013cf..ace35380e 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionDefinition.cs +++ b/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 Properties { get; } = new List(); + public List Properties { get; } = []; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs index b3b70f156..f876fdd2b 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs +++ b/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)) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs index 8753238c0..6ae083c90 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs +++ b/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); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleTypeProvider.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleTypeProvider.cs index db8592306..be357ae7e 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleTypeProvider.cs +++ b/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 actionTypes = new Dictionary(); + private readonly Dictionary actionTypes = []; public IReadOnlyDictionary Actions { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetCommandScriptVars.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetCommandScriptVars.cs index 972315f90..2040639ff 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetCommandScriptVars.cs +++ b/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))] diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs index be41c6a10..0800fd9ae 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs +++ b/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); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/AssetMetadataWrapper.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/AssetMetadataWrapper.cs deleted file mode 100644 index c034fd56d..000000000 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/AssetMetadataWrapper.cs +++ /dev/null @@ -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 -{ - private readonly AssetMetadata metadata; - - public int Count - { - get => metadata.Count; - } - - public ICollection Keys - { - get => metadata.Keys; - } - - public ICollection Values - { - get => metadata.Values.Cast().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 item) - { - Add(item.Key, item.Value); - } - - public bool Remove(string key) - { - return metadata.Remove(key); - } - - public bool Remove(KeyValuePair item) - { - return false; - } - - public void Clear() - { - metadata.Clear(); - } - - public bool Contains(KeyValuePair item) - { - return false; - } - - public bool ContainsKey(string key) - { - return metadata.ContainsKey(key); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - var i = arrayIndex; - - foreach (var item in metadata) - { - if (i >= array.Length) - { - break; - } - - array[i] = new KeyValuePair(item.Key, item.Value); - i++; - } - } - - public IEnumerator> GetEnumerator() - { - return metadata.Select(x => new KeyValuePair(x.Key, x.Value)).GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)metadata).GetEnumerator(); - } -} diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/CustomClrConverter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/CustomClrConverter.cs new file mode 100644 index 000000000..2476adc31 --- /dev/null +++ b/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); + } +} diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintUser.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintUser.cs index d9675597e..a0feb7e35 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintUser.cs +++ b/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) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs index ad1b7fa0f..82081437a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs +++ b/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(); + this.extensions = extensions?.ToArray() ?? []; } public async Task 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(); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs index 5820d00cd..8890c5bd5 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs +++ b/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; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs index 097ad12f0..16be0cb20 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs +++ b/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(); + var parts = name?.Split('.') ?? []; foreach (var part in parts) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj index 4fb5c5495..04d358b04 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj @@ -1,10 +1,10 @@ - + - net7.0 + net8.0 Squidex.Domain.Apps.Core latest enable - en + en enable @@ -18,19 +18,19 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - + - + diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs index e75f5acef..cc641d3c0 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs +++ b/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> subscriptions = new Dictionary>(); + private readonly Dictionary> subscriptions = []; private readonly ReaderWriterLockSlim readerWriterLock = new ReaderWriterLockSlim(); public async ValueTask> GetSubscriptionsAsync(object message) @@ -34,7 +34,7 @@ public sealed class EventMessageEvaluator : IMessageEvaluator { if (await subscription.ShouldHandle(appEvent)) { - result ??= new List(); + result ??= []; result.Add(id); } } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagsExport.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagsExport.cs index 06de568d1..df1983c8a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagsExport.cs +++ b/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 Tags { get; set; } = new Dictionary(); + public Dictionary Tags { get; set; } = []; - public Dictionary Alias { get; set; } = new Dictionary(); + public Dictionary Alias { get; set; } = []; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/TemplateParseException.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/TemplateParseException.cs index 39147f584..4f007ae3d 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/TemplateParseException.cs +++ b/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}."; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/RootContext.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/RootContext.cs index 508356a69..5a98b554c 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/RootContext.cs +++ b/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 errors = new ConcurrentBag(); + private readonly ConcurrentBag errors = []; private readonly Scheduler scheduler = new Scheduler(); public IJsonSerializer Serializer { get; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs index 498aa4d8c..638e0b762 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs +++ b/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 Path { get; init; } = ImmutableQueue.Empty; + public ImmutableQueue Path { get; init; } = []; public bool IsOptional { get; init; } diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs index 27241193b..0d4ac30fb 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs @@ -184,17 +184,17 @@ public sealed class MongoContentCollection : MongoRepositoryBase 0 }) { - return await queryByIds.QueryAsync(app, new List { 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 { schema }, q, ct); + return await queryScheduled.QueryAsync(app, [schema], q, ct); } if (q.Referencing != default) { - return await queryReferences.QueryAsync(app, new List { schema }, q, ct); + return await queryReferences.QueryAsync(app, [schema], q, ct); } if (queryInDedicatedCollection != null) diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs index 0c40f3108..113c96605 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentEntity.cs @@ -162,7 +162,7 @@ public sealed class MongoContentEntity : IContentEntity, IVersionedEntity(); + entity.ReferencedIds ??= []; entity.Version = job.NewVersion; var (app, schema) = await appProvider.GetAppWithSchemaAsync(entity.IndexedAppId, entity.IndexedSchemaId, true, ct); diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj index 2e7d62edc..98f6bf0fc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj @@ -1,6 +1,6 @@ - + - net7.0 + net8.0 latest enable enable @@ -18,8 +18,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasIndexDefinition.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasIndexDefinition.cs index bce6d47eb..eea6ad274 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasIndexDefinition.cs +++ b/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 FieldPaths = new Dictionary(); + private static readonly Dictionary FieldPaths = []; private static readonly Dictionary FieldAnalyzers = new Dictionary { ["iv"] = "lucene.standard", diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/LuceneQueryVisitor.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/LuceneQueryVisitor.cs index 0cea6d45d..cb3636633 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/LuceneQueryVisitor.cs +++ b/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; } diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs index 5b80f12a8..b4bcc8135 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs @@ -37,7 +37,7 @@ public abstract class MongoTextIndexBase : MongoRepositoryBase Results { get; } = new List<(DomainId Id, double Score)>(); + public List<(DomainId Id, double Score)> Results { get; } = []; public string SearchTerms { get; set; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/AppProvider.cs b/backend/src/Squidex.Domain.Apps.Entities/AppProvider.cs index c067c69b2..dfdb7eb8a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/AppProvider.cs +++ b/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(); + return apps?.ToList() ?? []; } public async Task> GetTeamAppsAsync(DomainId teamId, @@ -161,7 +161,7 @@ public sealed class AppProvider : IAppProvider return indexForApps.GetAppsForTeamAsync(teamId, ct)!; }); - return apps?.ToList() ?? new List(); + return apps?.ToList() ?? []; } public async Task> 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(); + return teams?.ToList() ?? []; } public async Task> GetSchemasAsync(DomainId appId, @@ -191,7 +191,7 @@ public sealed class AppProvider : IAppProvider } } - return schemas?.ToList() ?? new List(); + return schemas?.ToList() ?? []; } public async Task> GetRulesAsync(DomainId appId, @@ -202,7 +202,7 @@ public sealed class AppProvider : IAppProvider return indexForRules.GetRulesAsync(appId, ct)!; }); - return rules?.ToList() ?? new List(); + return rules?.ToList() ?? []; } public async Task GetRuleAsync(DomainId appId, DomainId id, diff --git a/backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs b/backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs index 972e453d0..71078ab45 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/AppProviderExtensions.cs @@ -32,7 +32,7 @@ public static class AppProviderExtensions { if (schemaId == schema.Id) { - result ??= new Dictionary(); + 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(); + result ??= []; result[schemaId] = resolvedEntity.SchemaDef; await ResolveSchemaAsync(resolvedEntity); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs index d339b83fb..496ccd2e9 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs +++ b/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 - { + consumingTypes = + [ typeRegistry.GetName(), typeRegistry.GetName() - }; + ]; } public bool Handles(StoredEvent @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs index b1360d198..6bd60a527 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs +++ b/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 forAppSchemas = new List(); - private readonly List forAppWithoutSchemas = new List(); + private readonly List forAppSchemas = []; + private readonly List forAppWithoutSchemas = []; private readonly IAppProvider appProvider; public RolePermissionsProvider(IAppProvider appProvider) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs index 2ca3c7136..a1aafda86 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs +++ b/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 lines = new List(); - private readonly List errors = new List(); + private readonly List lines = []; + private readonly List errors = []; private string startedLine = string.Empty; public bool CanWriteToSameLine => false; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs index 85e299c82..6e58fa73b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs +++ b/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 - { + consumingTypes = + [ typeRegistry.GetName() - }; + ]; } public bool Handles(StoredEvent @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs index 6b198cc40..9cd749b19 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs +++ b/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 assetIds = new HashSet(); - private readonly HashSet assetFolderIds = new HashSet(); + private readonly HashSet assetIds = []; + private readonly HashSet assetFolderIds = []; private readonly Rebuilder rebuilder; private readonly IAssetFileStore assetFileStore; private readonly ITagService tagService; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Commands/UploadAssetCommand.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Commands/UploadAssetCommand.cs index e4a983e46..59d7e6497 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Commands/UploadAssetCommand.cs +++ b/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 Tags { get; set; } = new HashSet(); + public HashSet Tags { get; set; } = []; public AssetFile File { get; set; } - public AssetMetadata Metadata { get; } = new AssetMetadata(); + public AssetMetadata Metadata { get; } = []; public AssetType Type { get; set; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs index 83bbdec87..ed894bd97 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs +++ b/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(); + Tags = []; } if (Metadata == null) { - Metadata = new AssetMetadata(); + Metadata = []; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs index 0e4969cf1..b314f111b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs +++ b/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)) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs index 2e5b2d7f3..122bdc037 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs +++ b/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(); + query.Sort ??= []; if (query.Sort.Count == 0) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/Steps/ConvertTags.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/Steps/ConvertTags.cs index e224fff40..2dc6afcaf 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/Steps/ConvertTags.cs +++ b/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(); + asset.TagNames = []; if (asset.Tags != null) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs index 9d198968f..802134333 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs +++ b/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 - { + consumingTypes = + [ typeRegistry.GetName() - }; + ]; } public bool Handles(StoredEvent @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupRestoreException.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupRestoreException.cs index 8c4d52815..f238c5fbe 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupRestoreException.cs +++ b/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) - { - } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs index c7dbac6f3..3b0f619af 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWorker.cs @@ -19,13 +19,13 @@ public sealed class BackupWorker : IMessageHandler, IInitializable { - private readonly Dictionary> backupProcessors = new Dictionary>(); + private readonly Dictionary> backupProcessors = []; private readonly Func 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 => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/State/BackupState.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/State/BackupState.cs index 7f03d2804..9e9a648d3 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/State/BackupState.cs +++ b/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 Jobs { get; set; } = new List(); + public List Jobs { get; set; } = []; public void EnsureCanStart() { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/State/RestoreJob.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/State/RestoreJob.cs index d9da4eece..179e05186 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/State/RestoreJob.cs +++ b/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 Log { get; set; } = new List(); + public List Log { get; set; } = []; public JobStatus Status { get; set; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs index 4897e600a..f1fbdae3e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs +++ b/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 userMap = new Dictionary(); + private readonly Dictionary userMap = []; private readonly RefToken initiator; public RefToken Initiator diff --git a/backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs b/backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs index 771dcd711..1d8a0fcc1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Billing/ConfigPlansProvider.cs @@ -20,7 +20,7 @@ public sealed class ConfigPlansProvider : IBillingPlans }; private readonly Dictionary plansById = new Dictionary(StringComparer.OrdinalIgnoreCase); - private readonly List plans = new List(); + private readonly List plans = []; private readonly Plan freePlan; public ConfigPlansProvider(IEnumerable config) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs b/backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs index b16fdbaa3..afd8de3c7 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Billing/UsageNotifierWorker.cs @@ -26,7 +26,7 @@ public sealed class UsageNotifierWorker : IMessageHandler, I [CollectionName("UsageNotifications")] public sealed class State { - public Dictionary NotificationsSent { get; set; } = new Dictionary(); + public Dictionary NotificationsSent { get; set; } = []; } public IClock Clock { get; set; } = SystemClock.Instance; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs index 7015b4d30..484e2df66 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs +++ b/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> contentIdsBySchemaId = new Dictionary>(); + private readonly Dictionary> 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; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Counter/CounterService.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Counter/CounterService.cs index 78e494e92..dd4588b9f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Counter/CounterService.cs +++ b/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 Counters { get; set; } = new Dictionary(); + public Dictionary Counters { get; set; } = []; public bool Increment(string name) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs index b87550083..12572b23c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs +++ b/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 Flow = new Dictionary @@ -90,7 +90,7 @@ public sealed class DefaultContentWorkflow : IContentWorkflow public ValueTask GetNextAsync(IContentEntity content, Status status, ClaimsPrincipal? user) { - var result = Flow.TryGetValue(status, out var step) ? step.Transitions : Array.Empty(); + var result = Flow.TryGetValue(status, out var step) ? step.Transitions : []; return ValueTask.FromResult(result); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentsBulkUpdateCommandMiddleware.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentsBulkUpdateCommandMiddleware.cs index 5ca293803..9c54fe745 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentsBulkUpdateCommandMiddleware.cs +++ b/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(); + return []; } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs index 08bd14652..17f23e182 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs @@ -88,7 +88,7 @@ public sealed class GraphQLExecutionContext : QueryExecutionContext public IDataLoaderResult GetAsset(DomainId id, TimeSpan cacheDuration) { - var assets = GetAssets(new List { 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 GetContent(DomainId schemaId, DomainId id, HashSet? fields, TimeSpan cacheDuration) { - var contents = GetContents(new List { id }, fields, cacheDuration); + var contents = GetContents([id], fields, cacheDuration); var content = contents.Then(x => x.FirstOrDefault(x => x.SchemaId.Id == schemaId)); return content; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs index 28d1177a8..8e7dc3e26 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs +++ b/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((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((_, 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(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 => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs index e69653ee1..08960e3da 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs +++ b/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 componentUnionTypes = new (); - private readonly Dictionary embeddableStringTypes = new (); - private readonly Dictionary nestedTypes = new (); - private readonly Dictionary componentTypes = new (); - private readonly Dictionary contentTypes = new (); - private readonly Dictionary contentResultTypes = new (); - private readonly Dictionary unionTypes = new (); - private readonly Dictionary enumTypes = new (); - private readonly Dictionary dynamicTypes = new (); + private readonly Dictionary componentUnionTypes = []; + private readonly Dictionary embeddableStringTypes = []; + private readonly Dictionary nestedTypes = []; + private readonly Dictionary componentTypes = []; + private readonly Dictionary contentTypes = []; + private readonly Dictionary contentResultTypes = []; + private readonly Dictionary unionTypes = []; + private readonly Dictionary enumTypes = []; + private readonly Dictionary dynamicTypes = []; private readonly FieldVisitor fieldVisitor; private readonly FieldInputVisitor fieldInputVisitor; private readonly PartitionResolver partitionResolver; - private readonly HashSet allSchemas = new HashSet(); + private readonly HashSet allSchemas = []; private readonly ReservedNames typeNames = ReservedNames.ForTypes(); private readonly GraphQLOptions options; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentUnionGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentUnionGraphType.cs index e40824f00..e62866683 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentUnionGraphType.cs +++ b/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 types = new Dictionary(); + private readonly Dictionary types = []; public bool HasType => types.Count > 0; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs index 949aacf55..f19bf285f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs +++ b/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 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((_, 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((_, 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((_, 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(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 => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentUnionGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentUnionGraphType.cs index a13955b9e..1d4ff2055 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentUnionGraphType.cs +++ b/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 types = new Dictionary(); + private readonly Dictionary types = []; // We need the schema identity at runtime. public IReadOnlyDictionary SchemaTypes => types; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Dynamic/DynamicSchemaBuilder.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Dynamic/DynamicSchemaBuilder.cs index b0de5b35c..249606b99 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Dynamic/DynamicSchemaBuilder.cs +++ b/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(); + return []; } Schema schema; @@ -25,7 +25,7 @@ internal static class DynamicSchemaBuilder } catch { - return Array.Empty(); + return []; } var map = schema.AdditionalTypeInstances.ToDictionary(x => x.Name); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/FieldMap.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/FieldMap.cs index b649aecd2..8a4e850d0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/FieldMap.cs +++ b/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> schemas = new Dictionary>(); + private readonly Dictionary> schemas = []; public FieldMap(IEnumerable source) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedExtensions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedExtensions.cs index 6d8c1e0cb..6cbf2aaa2 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedExtensions.cs +++ b/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(); + result ??= []; result.Add(DomainId.Create(id)); } } @@ -193,7 +193,7 @@ public static class SharedExtensions { private readonly GraphQLDocument document; private readonly ISchema schema; - private HashSet? fieldNames = new HashSet(); + private HashSet? fieldNames = []; private IComplexGraphType? currentParent; public FieldNameResolver(GraphQLDocument document, ISchema schema) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs index cd81c9251..c427c4909 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs +++ b/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(); + query.Sort ??= []; if (query.Sort.Count == 0) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs index f3463c973..245e952bd 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs +++ b/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)) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichWithWorkflows.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichWithWorkflows.cs index a189cbb46..5f9b9d947 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichWithWorkflows.cs +++ b/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(); + content.NextStatuses = []; } } else diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveAssets.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveAssets.cs index a170c066a..9949e6528 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveAssets.cs +++ b/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(); + fieldIds ??= []; fieldIds.Clear(); partitionValue.AddReferencedIds(field, fieldIds, components); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveReferences.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveReferences.cs index de7dfa2f8..bb7f95c55 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ResolveReferences.cs +++ b/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(); + fieldIds ??= []; fieldIds.Clear(); partitionValue.AddReferencedIds(field, fieldIds, components); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs index c91557a5d..9541ff618 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs @@ -31,7 +31,7 @@ public static class Extensions if (geoJson != null) { - result ??= new Dictionary(); + result ??= []; result[$"{field}.{key}"] = geoJson; } } @@ -65,7 +65,7 @@ public static class Extensions { if (sb.Length > 0) { - result ??= new Dictionary(); + result ??= []; result[key] = sb.ToString(); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs index cb1fcd99e..a733d0b06 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs +++ b/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 states = new Dictionary(); + private readonly Dictionary states = []; public Task ClearAsync( CancellationToken ct = default) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs index adf5aaf19..14e6be846 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs @@ -38,8 +38,8 @@ public sealed class TextIndexingProcess : IEventConsumer { private readonly Dictionary states; private readonly IJsonSerializer serializer; - private readonly Dictionary updates = new Dictionary(); - private readonly Dictionary commands = new Dictionary(); + private readonly Dictionary updates = []; + private readonly Dictionary commands = []; public Updates(Dictionary states, IJsonSerializer serializer) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/ContextHeaders.cs b/backend/src/Squidex.Domain.Apps.Entities/ContextHeaders.cs index 2dde6dffb..add08359f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/ContextHeaders.cs +++ b/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"; diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs index 2bb309e18..d3b54b93f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs @@ -26,7 +26,7 @@ public sealed class HistoryEvent public string EventType { get; set; } - public Dictionary Parameters { get; set; } = new Dictionary(); + public Dictionary Parameters { get; set; } = []; public HistoryEvent() { diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs index aceb8cda3..7fdc7380a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Entities.History; public abstract class HistoryEventsCreatorBase : IHistoryEventsCreator { - private readonly Dictionary texts = new Dictionary(); + private readonly Dictionary texts = []; private readonly TypeRegistry typeRegistry; public IReadOnlyDictionary Texts diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs index 0b54e63f6..98267a7be 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Entities.History; public sealed class HistoryService : IHistoryService, IEventConsumer { - private readonly Dictionary texts = new Dictionary(); + private readonly Dictionary texts = []; private readonly List creators; private readonly IHistoryEventRepository repository; private readonly NotifoService notifo; diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs b/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs index 5a258adcf..46012281c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs @@ -116,10 +116,10 @@ public class NotifoService : IUserEvents var response = await client.Users.PostUsersAsync(options.AppId, new UpsertUsersDto { - Requests = new List - { + Requests = + [ userRequest - } + ] }); var apiKey = response.First().ApiKey; @@ -254,7 +254,7 @@ public class NotifoService : IUserEvents { var publishRequest = new PublishDto { - Properties = new NotificationProperties() + Properties = [] }; foreach (var (key, value) in historyEvent.Parameters) diff --git a/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs b/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs index d7be0a091..8d7673221 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Entities; public abstract class OperationContextBase where TCommand : SquidexCommand, IAggregateCommand { - private readonly List errors = new List(); + private readonly List errors = []; private readonly IServiceProvider serviceProvider; private readonly Func snapshotProvider; private readonly TSnapShot snapshotInitial; @@ -35,7 +35,7 @@ public abstract class OperationContextBase where TCommand : public ClaimsPrincipal? User => Command.User; - public Dictionary Context { get; } = new Dictionary(); + public Dictionary Context { get; } = []; protected OperationContextBase(IServiceProvider serviceProvider, Func snapshotProvider) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs index 18f5455b2..40ac06aab 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Rules; public sealed class BackupRules : IBackupHandler { private const int BatchSize = 100; - private readonly HashSet ruleIds = new HashSet(); + private readonly HashSet ruleIds = []; private readonly Rebuilder rebuilder; public string Name { get; } = "Rules"; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleQueryService.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleQueryService.cs index 50bc9cfbd..10763715f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleQueryService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleQueryService.cs @@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Queries; public sealed class RuleQueryService : IRuleQueryService { - private static readonly List EmptyResults = new List(); + private static readonly List EmptyResults = []; private readonly IRulesIndex rulesIndex; private readonly IRuleEnricher ruleEnricher; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleQueueWriter.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleQueueWriter.cs index 93d02431e..a84d38dfc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleQueueWriter.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleQueueWriter.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Entities.Rules; internal sealed class RuleQueueWriter : IAsyncDisposable { - private readonly List writes = new List(); + private readonly List writes = []; private readonly IRuleEventRepository ruleEventRepository; private readonly IRuleUsageTracker ruleUsageTracker; private readonly ILogger? log; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/RuleRunnerWorker.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/RuleRunnerWorker.cs index 6edbcd749..c3cb4ce3e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/RuleRunnerWorker.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/RuleRunnerWorker.cs @@ -18,13 +18,13 @@ public sealed class RuleRunnerWorker : IMessageHandler, IMessageHandler { - private readonly Dictionary> processors = new Dictionary>(); + private readonly Dictionary> processors = []; private readonly Func processorFactory; private readonly ISnapshotStore snapshotStore; public RuleRunnerWorker(IServiceProvider serviceProvider, ISnapshotStore snapshotStore) { - var objectFactory = ActivatorUtilities.CreateFactory(typeof(RuleRunnerProcessor), new[] { typeof(DomainId) }); + var objectFactory = ActivatorUtilities.CreateFactory(typeof(RuleRunnerProcessor), [typeof(DomainId)]); processorFactory = key => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerWorker.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerWorker.cs index adf019419..141d3f345 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerWorker.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerWorker.cs @@ -57,7 +57,7 @@ public sealed class UsageTrackerWorker : IMessageHandler, [CollectionName("UsageTracker")] public sealed class State { - public Dictionary Targets { get; set; } = new Dictionary(); + public Dictionary Targets { get; set; } = []; } public UsageTrackerWorker(IPersistenceFactory persistenceFactory, IApiUsageTracker usageTracker) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs index 36672c6be..2cfa8296a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas; public sealed class BackupSchemas : IBackupHandler { private const int BatchSize = 100; - private readonly HashSet schemaIds = new HashSet(); + private readonly HashSet schemaIds = []; private readonly Rebuilder rebuilder; public string Name { get; } = "Schemas"; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Search/SearchManager.cs b/backend/src/Squidex.Domain.Apps.Entities/Search/SearchManager.cs index 1d7ec8233..80f8a22b0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Search/SearchManager.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Search/SearchManager.cs @@ -11,7 +11,7 @@ namespace Squidex.Domain.Apps.Entities.Search; public sealed class SearchManager : ISearchManager { - private static readonly SearchResults Empty = new SearchResults(); + private static readonly SearchResults Empty = []; private readonly IEnumerable searchSources; private readonly ILogger log; @@ -27,7 +27,7 @@ public sealed class SearchManager : ISearchManager { if (string.IsNullOrWhiteSpace(query) || query.Length < 3) { - return new SearchResults(); + return []; } var tasks = searchSources.Select(x => SearchAsync(x, query, context, ct)); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj index bdedc1ae4..229fb0e7b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj +++ b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj @@ -1,9 +1,9 @@  - net7.0 + net8.0 latest enable - en + en enable @@ -20,23 +20,23 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - + - + diff --git a/backend/src/Squidex.Domain.Apps.Entities/Tags/TagService.cs b/backend/src/Squidex.Domain.Apps.Entities/Tags/TagService.cs index 9b5c9e7a7..b4df09d07 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Tags/TagService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Tags/TagService.cs @@ -22,10 +22,10 @@ public sealed class TagService : ITagService public ValueTask OnReadAsync() { // Tags should never be null, but it might happen due of bugs. - Tags ??= new Dictionary(); + Tags ??= []; // Alias can be null, because it was not part of the initial release. - Alias ??= new Dictionary(); + Alias ??= []; return default; } diff --git a/backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj b/backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj index 926d19563..3ed78b3c3 100644 --- a/backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj +++ b/backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 latest enable enable @@ -14,7 +14,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs b/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs index d4538832b..03e203f3f 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs +++ b/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs @@ -18,19 +18,19 @@ public sealed class MongoUser : IdentityUser { [BsonRequired] [BsonElement] - public List Claims { get; set; } = new List(); + public List Claims { get; set; } = []; [BsonRequired] [BsonElement] - public List Tokens { get; set; } = new List(); + public List Tokens { get; set; } = []; [BsonRequired] [BsonElement] - public List Logins { get; set; } = new List(); + public List Logins { get; set; } = []; [BsonRequired] [BsonElement] - public HashSet Roles { get; set; } = new HashSet(); + public HashSet Roles { get; set; } = []; internal string? GetToken(string provider, string name) { diff --git a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj index 390e4c47d..d7c89924a 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj +++ b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj @@ -1,6 +1,6 @@ - + - net7.0 + net8.0 latest enable enable @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs b/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs index 57d065afa..23238e0c0 100644 --- a/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs +++ b/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs @@ -67,10 +67,10 @@ public sealed class DefaultUserResolver : IUserResolver var values = new UserValues { - CustomClaims = new List - { + CustomClaims = + [ new Claim(type, value) - } + ] }; await userService.UpdateAsync(id, values, silent, ct); diff --git a/backend/src/Squidex.Domain.Users/DefaultUserService.cs b/backend/src/Squidex.Domain.Users/DefaultUserService.cs index 1e2c9b722..191f6bfe3 100644 --- a/backend/src/Squidex.Domain.Users/DefaultUserService.cs +++ b/backend/src/Squidex.Domain.Users/DefaultUserService.cs @@ -177,7 +177,7 @@ public sealed class DefaultUserService : IUserService if (isFirst) { - var permissions = values.Permissions?.ToIds().ToList() ?? new List(); + var permissions = values.Permissions?.ToIds().ToList() ?? []; permissions.Add(PermissionIds.Admin); diff --git a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj index 6b4937e1c..c905616aa 100644 --- a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj +++ b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 latest enable enable @@ -17,14 +17,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj b/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj index adddb2b04..baed81dd8 100644 --- a/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj +++ b/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj @@ -1,17 +1,17 @@ - + - net7.0 + net8.0 Squidex.Infrastructure latest enable enable - - + + - + diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/Formatter.cs b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/Formatter.cs index b6449b92b..7d3971c55 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/Formatter.cs +++ b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/Formatter.cs @@ -15,7 +15,7 @@ namespace Squidex.Infrastructure.EventSourcing; public static class Formatter { - private static readonly HashSet PrivateHeaders = new HashSet { "$v", "$p", "$c", "$causedBy" }; + private static readonly HashSet PrivateHeaders = ["$v", "$p", "$c", "$causedBy"]; public static StoredEvent Read(ResolvedEvent resolvedEvent, string? prefix, IJsonSerializer serializer) { diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs index 7519d9eab..a01627065 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs +++ b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs @@ -17,7 +17,6 @@ namespace Squidex.Infrastructure.EventSourcing; public sealed class GetEventStore : IEventStore, IInitializable { private const string StreamPrefix = "squidex"; - private static readonly IReadOnlyList EmptyEvents = new List(); private readonly EventStoreClient client; private readonly EventStoreProjectionClient projectionClient; private readonly IJsonSerializer serializer; diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj index 2b77d4dc0..721567983 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj +++ b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 Squidex.Infrastructure latest enable @@ -11,11 +11,11 @@ True - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs index d86fc0183..bb9986a6f 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs @@ -18,7 +18,7 @@ public delegate bool EventPredicate(MongoEvent data); public partial class MongoEventStore : MongoRepositoryBase, IEventStore { - private static readonly List EmptyEvents = new List(); + private static readonly List EmptyEvents = []; public IEventSubscription CreateSubscription(IEventSubscriber subscriber, StreamFilter filter, string? position = null) { diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoBase.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoBase.cs index 536cefff2..ca67643b2 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoBase.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoBase.cs @@ -42,5 +42,5 @@ public abstract class MongoBase new UpdateOptions { IsUpsert = true }; protected static readonly BsonDocument FindAll = - new BsonDocument(); + []; } diff --git a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj index a1e626c90..89b6c926a 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj +++ b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 Squidex.Infrastructure latest enable @@ -14,7 +14,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsage.cs b/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsage.cs index a0b2868da..c7fc47bdf 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsage.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsage.cs @@ -31,5 +31,5 @@ public sealed class MongoUsage [BsonRequired] [BsonElement(nameof(Counters))] - public Counters Counters { get; set; } = new Counters(); + public Counters Counters { get; set; } = []; } diff --git a/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs b/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs index d003e0b2f..3ad141989 100644 --- a/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs +++ b/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs @@ -12,7 +12,7 @@ namespace Squidex.Infrastructure.Collections; public class ReadonlyDictionary : IReadOnlyDictionary, IEquatable> where TKey : notnull { - private static readonly Dictionary EmptyInner = new Dictionary(); + private static readonly Dictionary EmptyInner = []; private readonly IDictionary inner; public TValue this[TKey key] diff --git a/backend/src/Squidex.Infrastructure/Collections/ReadonlyList{T}.cs b/backend/src/Squidex.Infrastructure/Collections/ReadonlyList{T}.cs index 51510e48a..812e17a89 100644 --- a/backend/src/Squidex.Infrastructure/Collections/ReadonlyList{T}.cs +++ b/backend/src/Squidex.Infrastructure/Collections/ReadonlyList{T}.cs @@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.Collections; public class ReadonlyList : ReadOnlyCollection, IEquatable> { - private static readonly List EmptyInner = new List(); + private static readonly List EmptyInner = []; public ReadonlyList() : base(EmptyInner) diff --git a/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectFactory.cs b/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectFactory.cs index 1788eec37..147c27c13 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectFactory.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectFactory.cs @@ -19,7 +19,7 @@ public sealed class DefaultDomainObjectFactory : IDomainObjectFactory private static class DefaultFactory { private static readonly ObjectFactory ObjectFactory = - ActivatorUtilities.CreateFactory(typeof(T), new[] { typeof(DomainId) }); + ActivatorUtilities.CreateFactory(typeof(T), [typeof(DomainId)]); public static T Create(IServiceProvider serviceProvider, DomainId id) { @@ -30,7 +30,7 @@ public sealed class DefaultDomainObjectFactory : IDomainObjectFactory private static class PersistenceFactory { private static readonly ObjectFactory ObjectFactory = - ActivatorUtilities.CreateFactory(typeof(T), new[] { typeof(DomainId), typeof(IPersistenceFactory) }); + ActivatorUtilities.CreateFactory(typeof(T), [typeof(DomainId), typeof(IPersistenceFactory)]); public static T Create(IServiceProvider serviceProvider, DomainId id, IPersistenceFactory persistenceFactory) { diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs index 8cffb0319..3211777d9 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure.Commands; public abstract partial class DomainObject : IAggregate where T : class, IDomainState, new() { - private readonly List> uncomittedEvents = new List>(); + private readonly List> uncomittedEvents = []; private readonly ILogger log; private readonly IPersistenceFactory persistenceFactory; private readonly IPersistence persistence; diff --git a/backend/src/Squidex.Infrastructure/DomainException.cs b/backend/src/Squidex.Infrastructure/DomainException.cs index 5b1e8b67c..af75e84e6 100644 --- a/backend/src/Squidex.Infrastructure/DomainException.cs +++ b/backend/src/Squidex.Infrastructure/DomainException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure; [Serializable] @@ -24,17 +22,4 @@ public class DomainException : Exception { ErrorCode = errorCode; } - - protected DomainException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - ErrorCode = info.GetString(nameof(ErrorCode)); - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(ErrorCode), ErrorCode); - - base.GetObjectData(info, context); - } } diff --git a/backend/src/Squidex.Infrastructure/DomainForbiddenException.cs b/backend/src/Squidex.Infrastructure/DomainForbiddenException.cs index 8fc1141a6..858429a61 100644 --- a/backend/src/Squidex.Infrastructure/DomainForbiddenException.cs +++ b/backend/src/Squidex.Infrastructure/DomainForbiddenException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure; [Serializable] @@ -18,9 +16,4 @@ public class DomainForbiddenException : DomainException : base(message, ValidationError, inner) { } - - protected DomainForbiddenException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } diff --git a/backend/src/Squidex.Infrastructure/DomainObjectConflictException.cs b/backend/src/Squidex.Infrastructure/DomainObjectConflictException.cs index 621dcfcfc..6c0355745 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectConflictException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectConflictException.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; using Squidex.Infrastructure.Translations; namespace Squidex.Infrastructure; @@ -20,11 +19,6 @@ public class DomainObjectConflictException : DomainObjectException { } - protected DomainObjectConflictException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - private static string FormatMessage(string id) { return T.Get("exceptions.domainObjectConflict", new { id }); diff --git a/backend/src/Squidex.Infrastructure/DomainObjectDeletedException.cs b/backend/src/Squidex.Infrastructure/DomainObjectDeletedException.cs index 413a6b404..bb8fd1f85 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectDeletedException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectDeletedException.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; using Squidex.Infrastructure.Translations; namespace Squidex.Infrastructure; @@ -20,11 +19,6 @@ public class DomainObjectDeletedException : DomainObjectException { } - protected DomainObjectDeletedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - private static string FormatMessage(string id) { return T.Get("exceptions.domainObjectDeleted", new { id }); diff --git a/backend/src/Squidex.Infrastructure/DomainObjectException.cs b/backend/src/Squidex.Infrastructure/DomainObjectException.cs index d635edcc0..500ac5beb 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure; [Serializable] @@ -21,17 +19,4 @@ public class DomainObjectException : DomainException Id = id; } - - public DomainObjectException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Id = info.GetString(nameof(Id))!; - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(Id), Id); - - base.GetObjectData(info, context); - } } diff --git a/backend/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs b/backend/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs index ab05ebdd9..e0918695f 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; using Squidex.Infrastructure.Translations; namespace Squidex.Infrastructure; @@ -20,11 +19,6 @@ public class DomainObjectNotFoundException : DomainObjectException { } - protected DomainObjectNotFoundException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - private static string FormatMessage(string id) { return T.Get("exceptions.domainObjectNotFound", new { id }); diff --git a/backend/src/Squidex.Infrastructure/DomainObjectVersionException.cs b/backend/src/Squidex.Infrastructure/DomainObjectVersionException.cs index 76f4af1d1..4a0a2955f 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectVersionException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectVersionException.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; using Squidex.Infrastructure.Translations; namespace Squidex.Infrastructure; @@ -15,32 +14,15 @@ public class DomainObjectVersionException : DomainObjectException { private const string ExposedErrorCode = "OBJECT_VERSION_CONFLICT"; - public long CurrentVersion { get; } + public long VersionCurrent { get; } - public long ExpectedVersion { get; } + public long VersionExpected { get; } - public DomainObjectVersionException(string id, long currentVersion, long expectedVersion, Exception? inner = null) - : base(FormatMessage(id, currentVersion, expectedVersion), id, ExposedErrorCode, inner) + public DomainObjectVersionException(string id, long versionCurrent, long versionExpected, Exception? inner = null) + : base(FormatMessage(id, versionCurrent, versionExpected), id, ExposedErrorCode, inner) { - CurrentVersion = currentVersion; - - ExpectedVersion = expectedVersion; - } - - protected DomainObjectVersionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - CurrentVersion = info.GetInt64(nameof(CurrentVersion)); - - ExpectedVersion = info.GetInt64(nameof(ExpectedVersion)); - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(CurrentVersion), CurrentVersion); - info.AddValue(nameof(ExpectedVersion), ExpectedVersion); - - base.GetObjectData(info, context); + VersionCurrent = versionCurrent; + VersionExpected = versionExpected; } private static string FormatMessage(string id, long currentVersion, long expectedVersion) diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Consume/EventConsumerWorker.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Consume/EventConsumerWorker.cs index 9b4ab1759..388949aff 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/Consume/EventConsumerWorker.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/Consume/EventConsumerWorker.cs @@ -17,7 +17,7 @@ public sealed class EventConsumerWorker : IMessageHandler, IBackgroundProcess { - private readonly Dictionary processors = new Dictionary(); + private readonly Dictionary processors = []; private CompletionTimer? timer; public EventConsumerWorker(IEnumerable eventConsumers, diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs index 2cf5d30ad..1296fcecf 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs @@ -28,7 +28,7 @@ public class Envelope where T : class, IEvent this.payload = payload; - this.headers = headers ?? new EnvelopeHeaders(); + this.headers = headers ?? []; } public Envelope To() where TOther : class, IEvent diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/WrongEventVersionException.cs b/backend/src/Squidex.Infrastructure/EventSourcing/WrongEventVersionException.cs index 04249dbd6..4e4df6b3e 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/WrongEventVersionException.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/WrongEventVersionException.cs @@ -5,39 +5,20 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure.EventSourcing; [Serializable] public class WrongEventVersionException : Exception { - public long CurrentVersion { get; } - - public long ExpectedVersion { get; } - - public WrongEventVersionException(long currentVersion, long expectedVersion, Exception? inner = null) - : base(FormatMessage(currentVersion, expectedVersion), inner) - { - CurrentVersion = currentVersion; - - ExpectedVersion = expectedVersion; - } + public long VersionCurrent { get; } - protected WrongEventVersionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - CurrentVersion = info.GetInt64(nameof(CurrentVersion)); + public long VersionExpected { get; } - ExpectedVersion = info.GetInt64(nameof(ExpectedVersion)); - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) + public WrongEventVersionException(long versionCurrent, long versionExpected, Exception? inner = null) + : base(FormatMessage(versionCurrent, versionExpected), inner) { - info.AddValue(nameof(CurrentVersion), CurrentVersion); - info.AddValue(nameof(ExpectedVersion), ExpectedVersion); - - base.GetObjectData(info, context); + VersionCurrent = versionCurrent; + VersionExpected = versionExpected; } private static string FormatMessage(long currentVersion, long expectedVersion) diff --git a/backend/src/Squidex.Infrastructure/FileExtensions.cs b/backend/src/Squidex.Infrastructure/FileExtensions.cs index 64a68cc1d..f523f1628 100644 --- a/backend/src/Squidex.Infrastructure/FileExtensions.cs +++ b/backend/src/Squidex.Infrastructure/FileExtensions.cs @@ -12,13 +12,13 @@ namespace Squidex.Infrastructure; public static class FileExtensions { private static readonly string[] Extensions = - { + [ "bytes", "kB", "MB", "GB", "TB" - }; + ]; private static readonly Dictionary UnifiedExtensions = new Dictionary { diff --git a/backend/src/Squidex.Infrastructure/Guard.cs b/backend/src/Squidex.Infrastructure/Guard.cs index d6e3d1472..522e3b8f8 100644 --- a/backend/src/Squidex.Infrastructure/Guard.cs +++ b/backend/src/Squidex.Infrastructure/Guard.cs @@ -17,7 +17,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float ValidNumber(float target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (float.IsNaN(target) || float.IsPositiveInfinity(target) || float.IsNegativeInfinity(target)) { @@ -31,7 +31,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double ValidNumber(double target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (double.IsNaN(target) || double.IsPositiveInfinity(target) || double.IsNegativeInfinity(target)) { @@ -45,7 +45,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ValidSlug(string? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { NotNullOrEmpty(target, parameterName); @@ -61,7 +61,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ValidPropertyName(string? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { NotNullOrEmpty(target, parameterName); @@ -77,7 +77,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static object? HasType(object? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (target != null && target.GetType() != typeof(T)) { @@ -91,7 +91,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static object? HasType(object? target, Type? expectedType, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (target != null && expectedType != null && target.GetType() != expectedType) { @@ -105,7 +105,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue Between(TValue target, TValue lower, TValue upper, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : IComparable { if (!target.IsBetween(lower, upper)) { @@ -119,7 +119,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TEnum Enum(TEnum target, - [CallerArgumentExpression("target")] string? parameterName = null) where TEnum : struct + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TEnum : struct { if (!target.IsEnumValue()) { @@ -133,7 +133,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue GreaterThan(TValue target, TValue lower, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(lower) <= 0) { @@ -147,7 +147,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue GreaterEquals(TValue target, TValue lower, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(lower) < 0) { @@ -161,7 +161,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue LessThan(TValue target, TValue upper, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(upper) >= 0) { @@ -175,7 +175,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue LessEquals(TValue target, TValue upper, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(upper) > 0) { @@ -189,7 +189,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IReadOnlyCollection NotEmpty(IReadOnlyCollection? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { NotNull(target, parameterName); @@ -205,7 +205,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid NotEmpty(Guid target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (target == Guid.Empty) { @@ -219,7 +219,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static DomainId NotEmpty(DomainId target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (target == DomainId.Empty) { @@ -233,7 +233,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue NotNull(TValue? target, - [CallerArgumentExpression("target")] string? parameterName = null) where TValue : class + [CallerArgumentExpression(nameof(target))] string? parameterName = null) where TValue : class { if (target == null) { @@ -247,7 +247,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static object? NotNull(object? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (target == null) { @@ -261,7 +261,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TValue NotDefault(TValue target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { if (Equals(target, default(TValue)!)) { @@ -275,7 +275,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string NotNullOrEmpty(string? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { NotNull(target, parameterName); @@ -291,7 +291,7 @@ public static class Guard [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ValidFileName(string? target, - [CallerArgumentExpression("target")] string? parameterName = null) + [CallerArgumentExpression(nameof(target))] string? parameterName = null) { NotNullOrEmpty(target, parameterName); diff --git a/backend/src/Squidex.Infrastructure/HashSet.cs b/backend/src/Squidex.Infrastructure/HashSet.cs index 75d169132..1a18b4456 100644 --- a/backend/src/Squidex.Infrastructure/HashSet.cs +++ b/backend/src/Squidex.Infrastructure/HashSet.cs @@ -16,11 +16,11 @@ public static class HashSet public static HashSet Of(T item1) { - return new HashSet { item1 }; + return [item1]; } public static HashSet Of(T item1, T item2) { - return new HashSet { item1, item2 }; + return [item1, item2]; } } diff --git a/backend/src/Squidex.Infrastructure/Json/JsonException.cs b/backend/src/Squidex.Infrastructure/Json/JsonException.cs index b7bf1a73f..cc7a26d5b 100644 --- a/backend/src/Squidex.Infrastructure/Json/JsonException.cs +++ b/backend/src/Squidex.Infrastructure/Json/JsonException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure.Json; [Serializable] @@ -25,9 +23,4 @@ public class JsonException : Exception : base(message, inner) { } - - protected JsonException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } diff --git a/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs b/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs index 23a7d1bfd..aaaac9541 100644 --- a/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs +++ b/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs @@ -14,7 +14,7 @@ namespace Squidex.Infrastructure.Json.Objects; public readonly struct JsonValue : IEquatable { - private static readonly char[] PathSeparators = { '.', '[', ']' }; + private static readonly char[] PathSeparators = ['.', '[', ']']; public static readonly JsonValue Null; public static readonly JsonValue True = new JsonValue(true); @@ -250,12 +250,12 @@ public readonly struct JsonValue : IEquatable public static JsonObject Object() { - return new JsonObject(); + return []; } public static JsonArray Array() { - return new JsonArray(); + return []; } public static JsonValue Array(IEnumerable values) diff --git a/backend/src/Squidex.Infrastructure/Json/System/ReadonlyDictionaryConverterFactory.cs b/backend/src/Squidex.Infrastructure/Json/System/ReadonlyDictionaryConverterFactory.cs index 5a4317fbd..4077fcb23 100644 --- a/backend/src/Squidex.Infrastructure/Json/System/ReadonlyDictionaryConverterFactory.cs +++ b/backend/src/Squidex.Infrastructure/Json/System/ReadonlyDictionaryConverterFactory.cs @@ -46,12 +46,11 @@ public sealed class ReadonlyDictionaryConverterFactory : JsonConverterFactory var typeToCreate = IsReadonlyDictionary(typeToConvert) ? typeToConvert : typeToConvert.BaseType!; var concreteType = typeof(Converter<,,>).MakeGenericType( - new Type[] - { + [ typeToCreate.GetGenericArguments()[0], typeToCreate.GetGenericArguments()[1], typeToConvert - }); + ]); var converter = (JsonConverter)Activator.CreateInstance(concreteType)!; diff --git a/backend/src/Squidex.Infrastructure/Json/System/ReadonlyListConverterFactory.cs b/backend/src/Squidex.Infrastructure/Json/System/ReadonlyListConverterFactory.cs index 92d924157..d8848e9f7 100644 --- a/backend/src/Squidex.Infrastructure/Json/System/ReadonlyListConverterFactory.cs +++ b/backend/src/Squidex.Infrastructure/Json/System/ReadonlyListConverterFactory.cs @@ -46,11 +46,10 @@ public sealed class ReadonlyListConverterFactory : JsonConverterFactory var typeToCreate = IsReadonlyList(typeToConvert) ? typeToConvert : typeToConvert.BaseType!; var concreteType = typeof(Converter<,>).MakeGenericType( - new Type[] - { + [ typeToCreate.GetGenericArguments()[0], typeToConvert, - }); + ]); var converter = (JsonConverter)Activator.CreateInstance(concreteType)!; diff --git a/backend/src/Squidex.Infrastructure/Json/System/ReflectionHelper.cs b/backend/src/Squidex.Infrastructure/Json/System/ReflectionHelper.cs index 56262748d..e89bbe1a6 100644 --- a/backend/src/Squidex.Infrastructure/Json/System/ReflectionHelper.cs +++ b/backend/src/Squidex.Infrastructure/Json/System/ReflectionHelper.cs @@ -30,7 +30,7 @@ internal static class ReflectionHelper var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, - new[] { parameterType }, + [parameterType], typeof(ReflectionHelper).Module, true); diff --git a/backend/src/Squidex.Infrastructure/Json/System/StringConverter.cs b/backend/src/Squidex.Infrastructure/Json/System/StringConverter.cs index 18c6a1989..6f286754d 100644 --- a/backend/src/Squidex.Infrastructure/Json/System/StringConverter.cs +++ b/backend/src/Squidex.Infrastructure/Json/System/StringConverter.cs @@ -78,7 +78,7 @@ public sealed class StringConverter : JsonConverter where T : notnull internal static class OptionClones #pragma warning restore MA0048 // File name must match type name { - private static readonly ConditionalWeakTable Clones = new ConditionalWeakTable(); + private static readonly ConditionalWeakTable Clones = []; public static JsonSerializerOptions GetOptionsWithoutConverter(JsonSerializerOptions source, JsonConverter converter) { diff --git a/backend/src/Squidex.Infrastructure/Log/Request.cs b/backend/src/Squidex.Infrastructure/Log/Request.cs index 06cb700ad..f192f13c1 100644 --- a/backend/src/Squidex.Infrastructure/Log/Request.cs +++ b/backend/src/Squidex.Infrastructure/Log/Request.cs @@ -17,5 +17,5 @@ public sealed class Request public string Key; - public Dictionary Properties = new Dictionary(); + public Dictionary Properties = []; } diff --git a/backend/src/Squidex.Infrastructure/Migrations/MigrationFailedException.cs b/backend/src/Squidex.Infrastructure/Migrations/MigrationFailedException.cs index 0075e664b..d174f68d2 100644 --- a/backend/src/Squidex.Infrastructure/Migrations/MigrationFailedException.cs +++ b/backend/src/Squidex.Infrastructure/Migrations/MigrationFailedException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure.Migrations; [Serializable] @@ -20,17 +18,6 @@ public class MigrationFailedException : Exception Name = name; } - protected MigrationFailedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Name = info.GetString(nameof(Name))!; - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(Name), Name); - } - private static string FormatException(string name) { return $"Failed to run migration '{name}'"; diff --git a/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs b/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs index 35d64e13b..7cdb95c42 100644 --- a/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs +++ b/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs @@ -15,8 +15,8 @@ namespace Squidex.Infrastructure.Plugins; public sealed class PluginManager : DisposableObjectBase { - private readonly HashSet pluginLoaders = new HashSet(); - private readonly HashSet loadedPlugins = new HashSet(); + private readonly HashSet pluginLoaders = []; + private readonly HashSet loadedPlugins = []; private readonly List<(string Plugin, string Action, Exception Exception)> exceptions = new List<(string, string, Exception)>(); public static readonly PluginManager Instance = new PluginManager(); diff --git a/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs b/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs index 3c0c12e44..0d517f9c2 100644 --- a/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs +++ b/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs @@ -28,7 +28,7 @@ public static class PropertyPathValidator { if (index == lastIndex || field.Schema.Type == FilterSchemaType.Any) { - result ??= new List(); + result ??= []; result.Add(field); } else diff --git a/backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs b/backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs index c555f0409..43a6b2676 100644 --- a/backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs +++ b/backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs @@ -16,11 +16,11 @@ public static class ValueConverter private delegate bool Parser(List errors, PropertyPath path, JsonValue value, out T result); private static readonly InstantPattern[] InstantPatterns = - { + [ InstantPattern.General, InstantPattern.ExtendedIso, InstantPattern.CreateWithInvariantCulture("yyyy-MM-dd") - }; + ]; public static ClrValue? Convert(FilterField field, JsonValue value, PropertyPath path, List errors) { diff --git a/backend/src/Squidex.Infrastructure/Queries/OData/SortBuilder.cs b/backend/src/Squidex.Infrastructure/Queries/OData/SortBuilder.cs index 1a815e0be..e57a48d2c 100644 --- a/backend/src/Squidex.Infrastructure/Queries/OData/SortBuilder.cs +++ b/backend/src/Squidex.Infrastructure/Queries/OData/SortBuilder.cs @@ -19,7 +19,7 @@ public static class SortBuilder { while (orderBy != null) { - result.Sort ??= new List(); + result.Sort ??= []; result.Sort.Add(OrderBy(orderBy)); orderBy = orderBy.ThenBy; diff --git a/backend/src/Squidex.Infrastructure/Queries/PropertyPath.cs b/backend/src/Squidex.Infrastructure/Queries/PropertyPath.cs index ba990e603..fd630871e 100644 --- a/backend/src/Squidex.Infrastructure/Queries/PropertyPath.cs +++ b/backend/src/Squidex.Infrastructure/Queries/PropertyPath.cs @@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.Queries; public sealed class PropertyPath : ReadonlyList, IEquatable { - private static readonly char[] Separators = { '.', '/' }; + private static readonly char[] Separators = ['.', '/']; public PropertyPath(IList items) : base(items) diff --git a/backend/src/Squidex.Infrastructure/Queries/Query.cs b/backend/src/Squidex.Infrastructure/Queries/Query.cs index 680f602b8..a371e89cc 100644 --- a/backend/src/Squidex.Infrastructure/Queries/Query.cs +++ b/backend/src/Squidex.Infrastructure/Queries/Query.cs @@ -26,7 +26,7 @@ public class Query set => Take = value; } - public List? Sort { get; set; } = new List(); + public List? Sort { get; set; } = []; public HashSet GetAllFields() { diff --git a/backend/src/Squidex.Infrastructure/RefToken.cs b/backend/src/Squidex.Infrastructure/RefToken.cs index 56876d557..e6b788e76 100644 --- a/backend/src/Squidex.Infrastructure/RefToken.cs +++ b/backend/src/Squidex.Infrastructure/RefToken.cs @@ -13,7 +13,7 @@ namespace Squidex.Infrastructure; [TypeConverter(typeof(RefTokenTypeConverter))] public sealed record RefToken { - private static readonly char[] TrimChars = { ' ', ':' }; + private static readonly char[] TrimChars = [' ', ':']; public RefTokenType Type { get; } diff --git a/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs b/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs index 796f358ad..6f7854578 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs @@ -30,7 +30,7 @@ public static class PropertyAccessor var propertyGetMethod = propertyInfo.GetGetMethod()!; - var getMethod = new DynamicMethod(propertyGetMethod.Name, typeof(TValue), new[] { typeof(TSource) }, true); + var getMethod = new DynamicMethod(propertyGetMethod.Name, typeof(TValue), [typeof(TSource)], true); var getGenerator = getMethod.GetILGenerator(); // Load this to stack. @@ -71,7 +71,7 @@ public static class PropertyAccessor var propertySetMethod = propertyInfo.GetSetMethod()!; - var setMethod = new DynamicMethod(propertySetMethod.Name, null, new[] { typeof(TSource), typeof(TValue) }, true); + var setMethod = new DynamicMethod(propertySetMethod.Name, null, [typeof(TSource), typeof(TValue)], true); var setGenerator = setMethod.GetILGenerator(); // Load this to stack. diff --git a/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs b/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs index efb940b1e..aa952e904 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs @@ -40,7 +40,7 @@ public static class SimpleMapper { var method = CreateMethod.MakeGenericMethod(typeof(TSource), typeof(TTarget), valueType); - return (IPropertyMapper)method.Invoke(null, new object?[] { sourceProperty, targetProperty })!; + return (IPropertyMapper)method.Invoke(null, [sourceProperty, targetProperty])!; } private static IPropertyMapper CreateCore(PropertyInfo sourceProperty, PropertyInfo targetProperty) @@ -80,7 +80,7 @@ public static class SimpleMapper { var method = CreateMethod.MakeGenericMethod(typeof(TSource), typeof(TTarget), valueType); - return (IPropertyMapper)method.Invoke(null, new object?[] { sourceProperty, targetProperty })!; + return (IPropertyMapper)method.Invoke(null, [sourceProperty, targetProperty])!; } private static IPropertyMapper CreateCore(PropertyInfo sourceProperty, PropertyInfo targetProperty) @@ -120,7 +120,7 @@ public static class SimpleMapper { var method = CreateMethod.MakeGenericMethod(typeof(TSource), typeof(TTarget), valueType); - return (IPropertyMapper)method.Invoke(null, new object?[] { sourceProperty, targetProperty })!; + return (IPropertyMapper)method.Invoke(null, [sourceProperty, targetProperty])!; } private static IPropertyMapper CreateCore(PropertyInfo sourceProperty, PropertyInfo targetProperty) where TValue : struct @@ -172,7 +172,7 @@ public static class SimpleMapper { var method = CreateMethod.MakeGenericMethod(typeof(TSource), typeof(TTarget), sourceType, targetType); - return (IPropertyMapper)method.Invoke(null, new object?[] { sourceProperty, targetProperty })!; + return (IPropertyMapper)method.Invoke(null, [sourceProperty, targetProperty])!; } private static IPropertyMapper CreateCore(PropertyInfo sourceProperty, PropertyInfo targetProperty) @@ -226,7 +226,7 @@ public static class SimpleMapper { var method = CreateMethod.MakeGenericMethod(typeof(TSource), typeof(TTarget), sourceType, targetType); - return (IPropertyMapper)method.Invoke(null, new object?[] { sourceProperty, targetProperty, typeConverter })!; + return (IPropertyMapper)method.Invoke(null, [sourceProperty, targetProperty, typeConverter])!; } private static IPropertyMapper CreateCore(PropertyInfo sourceProperty, PropertyInfo targetProperty, TypeConverter typeConverter) @@ -273,7 +273,7 @@ public static class SimpleMapper private static class ClassMapper where TSource : class where TTarget : class { - private static readonly List> Mappers = new List>(); + private static readonly List> Mappers = []; static ClassMapper() { diff --git a/backend/src/Squidex.Infrastructure/Reflection/TypeRegistry.cs b/backend/src/Squidex.Infrastructure/Reflection/TypeRegistry.cs index 2347a9401..8c9d6b3f8 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/TypeRegistry.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/TypeRegistry.cs @@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.Reflection; public sealed class TypeRegistry { - private readonly Dictionary configs = new Dictionary(); + private readonly Dictionary configs = []; public TypeRegistry(IEnumerable? providers = null) { diff --git a/backend/src/Squidex.Infrastructure/ResultList.cs b/backend/src/Squidex.Infrastructure/ResultList.cs index f35749bab..f2107af0c 100644 --- a/backend/src/Squidex.Infrastructure/ResultList.cs +++ b/backend/src/Squidex.Infrastructure/ResultList.cs @@ -25,7 +25,7 @@ public static class ResultList private static class Empties { #pragma warning disable SA1401 // Fields should be private - public static Impl Instance = new Impl(new List(), 0); + public static Impl Instance = new Impl([], 0); #pragma warning restore SA1401 // Fields should be private } diff --git a/backend/src/Squidex.Infrastructure/Security/Permission.Part.cs b/backend/src/Squidex.Infrastructure/Security/Permission.Part.cs index e8fd491e8..26552a375 100644 --- a/backend/src/Squidex.Infrastructure/Security/Permission.Part.cs +++ b/backend/src/Squidex.Infrastructure/Security/Permission.Part.cs @@ -31,7 +31,7 @@ public sealed partial class Permission { if (string.IsNullOrWhiteSpace(path)) { - return Array.Empty(); + return []; } var current = path.AsMemory(); @@ -73,7 +73,7 @@ public sealed partial class Permission if (currentSpan.Length == 0) { - return new Part(Array.Empty>(), false); + return new Part([], false); } var isExclusion = false; @@ -88,7 +88,7 @@ public sealed partial class Permission if (currentSpan.Length == 0) { - return new Part(Array.Empty>(), isExclusion); + return new Part([], isExclusion); } if (current.Length > 1 || currentSpan[0] != CharAny) diff --git a/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs b/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs index f83c086ff..0ede9af36 100644 --- a/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs +++ b/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs @@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.Security; public sealed class PermissionSet : ReadonlyList { - public static readonly PermissionSet Empty = new PermissionSet(Array.Empty()); + public static readonly new PermissionSet Empty = new PermissionSet(Array.Empty()); private readonly Lazy display; diff --git a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj index 41c3d5e6f..032c44610 100644 --- a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj +++ b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj @@ -1,9 +1,9 @@ - + - net7.0 + net8.0 latest enable - en + en enable @@ -11,27 +11,27 @@ True - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + - + - - - - - - + + + + + + - + diff --git a/backend/src/Squidex.Infrastructure/States/BatchContext.cs b/backend/src/Squidex.Infrastructure/States/BatchContext.cs index a56671dea..e47222bc7 100644 --- a/backend/src/Squidex.Infrastructure/States/BatchContext.cs +++ b/backend/src/Squidex.Infrastructure/States/BatchContext.cs @@ -13,13 +13,13 @@ namespace Squidex.Infrastructure.States; public sealed class BatchContext : IBatchContext { - private static readonly List> EmptyStream = new List>(); + private static readonly List> EmptyStream = []; private readonly Type owner; private readonly IEventFormatter eventFormatter; private readonly IEventStore eventStore; private readonly IEventStreamNames eventStreamNames; private readonly ISnapshotStore snapshotStore; - private readonly Dictionary>)> events = new Dictionary>)>(); + private readonly Dictionary>)> events = []; private Dictionary>? snapshots; public ISnapshotStore Snapshots => snapshotStore; @@ -40,7 +40,7 @@ public sealed class BatchContext : IBatchContext internal void Add(DomainId key, T snapshot, long version) { - snapshots ??= new (); + snapshots ??= []; if (!snapshots.TryGetValue(key, out var existing) || existing.NewVersion < version) { diff --git a/backend/src/Squidex.Infrastructure/States/DefaultEventStreamNames.cs b/backend/src/Squidex.Infrastructure/States/DefaultEventStreamNames.cs index 1b4d5d36a..2085f113c 100644 --- a/backend/src/Squidex.Infrastructure/States/DefaultEventStreamNames.cs +++ b/backend/src/Squidex.Infrastructure/States/DefaultEventStreamNames.cs @@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.States; public sealed class DefaultEventStreamNames : IEventStreamNames { - private static readonly string[] Suffixes = { "Processor", "DomainObject", "State" }; + private static readonly string[] Suffixes = ["Processor", "DomainObject", "State"]; public string GetStreamName(Type aggregateType, string id) { diff --git a/backend/src/Squidex.Infrastructure/States/InconsistentStateException.cs b/backend/src/Squidex.Infrastructure/States/InconsistentStateException.cs index f1229e8b3..f40b7dabd 100644 --- a/backend/src/Squidex.Infrastructure/States/InconsistentStateException.cs +++ b/backend/src/Squidex.Infrastructure/States/InconsistentStateException.cs @@ -5,8 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; - namespace Squidex.Infrastructure.States; [Serializable] @@ -23,21 +21,6 @@ public class InconsistentStateException : Exception VersionExpected = expected; } - protected InconsistentStateException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - VersionCurrent = info.GetInt64(nameof(VersionCurrent)); - VersionExpected = info.GetInt64(nameof(VersionExpected)); - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(VersionCurrent), VersionCurrent); - info.AddValue(nameof(VersionExpected), VersionExpected); - - base.GetObjectData(info, context); - } - private static string FormatMessage(long current, long expected) { return $"Requested version {expected}, but found {current}."; diff --git a/backend/src/Squidex.Infrastructure/States/NameReservationState.cs b/backend/src/Squidex.Infrastructure/States/NameReservationState.cs index f85063b32..6d3a08b13 100644 --- a/backend/src/Squidex.Infrastructure/States/NameReservationState.cs +++ b/backend/src/Squidex.Infrastructure/States/NameReservationState.cs @@ -12,7 +12,7 @@ public sealed class NameReservationState : SimpleState Reservations { get; set; } = new List(); + public List Reservations { get; set; } = []; public (bool, string?) Reserve(DomainId id, string name) { diff --git a/backend/src/Squidex.Infrastructure/States/Persistence.cs b/backend/src/Squidex.Infrastructure/States/Persistence.cs index 6592c48e0..f5886ad0a 100644 --- a/backend/src/Squidex.Infrastructure/States/Persistence.cs +++ b/backend/src/Squidex.Infrastructure/States/Persistence.cs @@ -227,7 +227,7 @@ internal sealed class Persistence : IPersistence } catch (WrongEventVersionException ex) { - throw new InconsistentStateException(ex.CurrentVersion, ex.ExpectedVersion, ex); + throw new InconsistentStateException(ex.VersionCurrent, ex.VersionExpected, ex); } versionEvents += eventData.Length; diff --git a/backend/src/Squidex.Infrastructure/Tasks/AsyncHelper.cs b/backend/src/Squidex.Infrastructure/Tasks/AsyncHelper.cs index 6b986f362..ce29bb840 100644 --- a/backend/src/Squidex.Infrastructure/Tasks/AsyncHelper.cs +++ b/backend/src/Squidex.Infrastructure/Tasks/AsyncHelper.cs @@ -71,7 +71,7 @@ public static class AsyncHelper await target.Writer.WriteAsync(batch, ct); // Create a new batch, because the value is shared and might be processes by another concurrent task. - batch = new List(); + batch = []; } } diff --git a/backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs b/backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs index f43f31a8d..9c4b94a6d 100644 --- a/backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs +++ b/backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs @@ -23,7 +23,7 @@ public sealed class MissingKeys } else { - missingTranslations = new HashSet(); + missingTranslations = []; } } diff --git a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs index 3867f1a79..5adefecc2 100644 --- a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs +++ b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs @@ -154,7 +154,7 @@ public sealed class BackgroundUsageTracker : DisposableObjectBase, IUsageTracker { var counters = value.Find(x => x.Date == date)?.Counters; - enriched.Add((date, counters ?? new Counters())); + enriched.Add((date, counters ?? [])); } result[category] = enriched; diff --git a/backend/src/Squidex.Infrastructure/Validation/Validate.cs b/backend/src/Squidex.Infrastructure/Validation/Validate.cs index 449a26e54..3862a46d2 100644 --- a/backend/src/Squidex.Infrastructure/Validation/Validate.cs +++ b/backend/src/Squidex.Infrastructure/Validation/Validate.cs @@ -17,7 +17,7 @@ public static class Validate var addValidation = new AddValidation((m, p) => { - errors ??= new List(); + errors ??= []; errors.Add(new ValidationError(m, p)); }); @@ -35,7 +35,7 @@ public static class Validate var addValidation = new AddValidation((m, p) => { - errors ??= new List(); + errors ??= []; errors.Add(new ValidationError(m, p)); }); diff --git a/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs b/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs index 19c18863c..8807e92b0 100644 --- a/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs +++ b/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs @@ -29,7 +29,7 @@ public sealed class ValidationError this.message = message; - this.propertyNames = propertyNames ?? Array.Empty(); + this.propertyNames = propertyNames ?? []; } public ValidationError WithPrefix(string prefix) diff --git a/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs b/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs index dc0138c13..ee42ebc35 100644 --- a/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs +++ b/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization; using System.Text; namespace Squidex.Infrastructure.Validation; @@ -33,19 +32,6 @@ public class ValidationException : DomainException Errors = errors; } - protected ValidationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Errors = (List)info.GetValue(nameof(Errors), typeof(List))!; - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue(nameof(Errors), Errors); - - base.GetObjectData(info, context); - } - private static string FormatMessage(IReadOnlyList errors) { Guard.NotNull(errors); diff --git a/backend/src/Squidex.Shared/Squidex.Shared.csproj b/backend/src/Squidex.Shared/Squidex.Shared.csproj index 50018b35d..eb39efbfc 100644 --- a/backend/src/Squidex.Shared/Squidex.Shared.csproj +++ b/backend/src/Squidex.Shared/Squidex.Shared.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 latest enable enable @@ -10,7 +10,7 @@ True - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Shared/Users/ClientUser.cs b/backend/src/Squidex.Shared/Users/ClientUser.cs index 76f145b04..f25f12e3e 100644 --- a/backend/src/Squidex.Shared/Users/ClientUser.cs +++ b/backend/src/Squidex.Shared/Users/ClientUser.cs @@ -47,10 +47,10 @@ public sealed class ClientUser : IUser this.token = token; - claims = new List - { + claims = + [ new Claim(OpenIdClaims.ClientId, token.Identifier), new Claim(SquidexClaimTypes.DisplayName, token.Identifier) - }; + ]; } } diff --git a/backend/src/Squidex.Web/ApiModelValidationAttribute.cs b/backend/src/Squidex.Web/ApiModelValidationAttribute.cs index 66fa7e530..22c8ced19 100644 --- a/backend/src/Squidex.Web/ApiModelValidationAttribute.cs +++ b/backend/src/Squidex.Web/ApiModelValidationAttribute.cs @@ -56,7 +56,7 @@ public sealed class ApiModelValidationAttribute : ActionFilterAttribute if (!string.IsNullOrWhiteSpace(key)) { - properties = new[] { key.ToCamelCase() }; + properties = [key.ToCamelCase()]; } foreach (var error in value.Errors) diff --git a/backend/src/Squidex.Web/GraphQL/DynamicUserContextBuilder.cs b/backend/src/Squidex.Web/GraphQL/DynamicUserContextBuilder.cs index 7c68db9ce..3682e2186 100644 --- a/backend/src/Squidex.Web/GraphQL/DynamicUserContextBuilder.cs +++ b/backend/src/Squidex.Web/GraphQL/DynamicUserContextBuilder.cs @@ -15,7 +15,7 @@ namespace Squidex.Web.GraphQL; public sealed class DynamicUserContextBuilder : IUserContextBuilder { - private readonly ObjectFactory factory = ActivatorUtilities.CreateFactory(typeof(GraphQLExecutionContext), new[] { typeof(Context) }); + private readonly ObjectFactory factory = ActivatorUtilities.CreateFactory(typeof(GraphQLExecutionContext), [typeof(Context)]); public ValueTask?> BuildUserContextAsync(HttpContext context, object? payload) { diff --git a/backend/src/Squidex.Web/IgnoreHashFileProvider.cs b/backend/src/Squidex.Web/IgnoreHashFileProvider.cs index e1e8d4ad7..796404b6d 100644 --- a/backend/src/Squidex.Web/IgnoreHashFileProvider.cs +++ b/backend/src/Squidex.Web/IgnoreHashFileProvider.cs @@ -13,7 +13,7 @@ namespace Squidex.Web; public sealed partial class IgnoreHashFileProvider : IFileProvider { - private readonly char[] pathSeparators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\' }; + private readonly char[] pathSeparators = [Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\']; private readonly Dictionary map = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly IFileProvider inner; diff --git a/backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs b/backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs index 4c6c3ec06..970b63d5d 100644 --- a/backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs +++ b/backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs @@ -61,7 +61,7 @@ public sealed class ApiCostsFilter : IAsyncActionFilter, IFilterContainer } } - context.HttpContext.Response.Headers.Add("X-Costs", FilterDefinition.Costs.ToString(CultureInfo.InvariantCulture)); + context.HttpContext.Response.Headers["X-Costs"] = FilterDefinition.Costs.ToString(CultureInfo.InvariantCulture); await next(); } diff --git a/backend/src/Squidex.Web/Pipeline/AppResolver.cs b/backend/src/Squidex.Web/Pipeline/AppResolver.cs index 80777f084..d94b93236 100644 --- a/backend/src/Squidex.Web/Pipeline/AppResolver.cs +++ b/backend/src/Squidex.Web/Pipeline/AppResolver.cs @@ -114,7 +114,7 @@ public sealed class AppResolver : IAsyncActionFilter context.HttpContext.Features.Set(requestContext); context.HttpContext.Features.Set(new AppFeature(app)); - context.HttpContext.Response.Headers.Add("X-AppId", app.Id.ToString()); + context.HttpContext.Response.Headers["X-AppId"] = app.Id.ToString(); } await next(); diff --git a/backend/src/Squidex.Web/Pipeline/CachingManager.cs b/backend/src/Squidex.Web/Pipeline/CachingManager.cs index 9bc1b8eb4..e8972f417 100644 --- a/backend/src/Squidex.Web/Pipeline/CachingManager.cs +++ b/backend/src/Squidex.Web/Pipeline/CachingManager.cs @@ -24,7 +24,6 @@ namespace Squidex.Web.Pipeline; public sealed class CachingManager : IRequestCache { public const string SurrogateKeySizeHeader = "X-SurrogateKeys"; - private const int MaxStackSize = 256; private const int MaxAllowedKeysSize = 20000; private readonly ObjectPool stringBuilderPool; private readonly CachingOptions cachingOptions; @@ -33,8 +32,8 @@ public sealed class CachingManager : IRequestCache internal sealed class CacheContext : IDisposable { private readonly IncrementalHash hasher = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); - private readonly HashSet keys = new HashSet(); - private readonly HashSet headers = new HashSet(); + private readonly HashSet keys = []; + private readonly HashSet headers = []; private readonly ReaderWriterLockSlim slimLock = new ReaderWriterLockSlim(); private readonly int maxKeysSize; private bool hasDependency; @@ -118,7 +117,7 @@ public sealed class CachingManager : IRequestCache { using (Telemetry.Activities.StartActivity("CalculateEtag")) { - response.Headers.Add(HeaderNames.ETag, hasher.GetHexStringAndReset()); + response.Headers[HeaderNames.ETag] = hasher.GetHexStringAndReset(); } } diff --git a/backend/src/Squidex.Web/Pipeline/TeamResolver.cs b/backend/src/Squidex.Web/Pipeline/TeamResolver.cs index b8c7c8716..9c5528881 100644 --- a/backend/src/Squidex.Web/Pipeline/TeamResolver.cs +++ b/backend/src/Squidex.Web/Pipeline/TeamResolver.cs @@ -86,7 +86,7 @@ public sealed class TeamResolver : IAsyncActionFilter context.HttpContext.Features.Set(requestContext); context.HttpContext.Features.Set(new TeamFeature(team)); - context.HttpContext.Response.Headers.Add("X-TeamId", team.Id.ToString()); + context.HttpContext.Response.Headers["X-TeamId"] = team.Id.ToString(); } await next(); diff --git a/backend/src/Squidex.Web/Resource.cs b/backend/src/Squidex.Web/Resource.cs index bbefc0767..d21f0a6ba 100644 --- a/backend/src/Squidex.Web/Resource.cs +++ b/backend/src/Squidex.Web/Resource.cs @@ -17,7 +17,7 @@ public abstract class Resource [LocalizedRequired] [Display(Description = "The links.")] [JsonPropertyName("_links")] - public Dictionary Links { get; } = new Dictionary(); + public Dictionary Links { get; } = []; protected void AddSelfLink(string href) { diff --git a/backend/src/Squidex.Web/Squidex.Web.csproj b/backend/src/Squidex.Web/Squidex.Web.csproj index 466ec63fb..47fad8444 100644 --- a/backend/src/Squidex.Web/Squidex.Web.csproj +++ b/backend/src/Squidex.Web/Squidex.Web.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 latest enable enable @@ -13,10 +13,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex/Areas/Api/Config/OpenApi/TagByGroupNameProcessor.cs b/backend/src/Squidex/Areas/Api/Config/OpenApi/TagByGroupNameProcessor.cs index dee2edf20..fa32f369e 100644 --- a/backend/src/Squidex/Areas/Api/Config/OpenApi/TagByGroupNameProcessor.cs +++ b/backend/src/Squidex/Areas/Api/Config/OpenApi/TagByGroupNameProcessor.cs @@ -20,7 +20,7 @@ public sealed class TagByGroupNameProcessor : IOperationProcessor if (!string.IsNullOrWhiteSpace(groupName)) { - context.OperationDescription.Operation.Tags = new List { groupName }; + context.OperationDescription.Operation.Tags = [groupName]; return true; } diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationsBuilder.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationsBuilder.cs index bf6de0d09..9d8ae741e 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationsBuilder.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationsBuilder.cs @@ -47,10 +47,10 @@ internal sealed class OperationsBuilder var operation = new OpenApiOperation { - Tags = new List - { + Tags = + [ tag - } + ] }; var operations = Parent.OpenApiDocument.Paths.GetOrAddNew($"{Path}{path}"); diff --git a/backend/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs b/backend/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs index f207d6431..6021bf3e6 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/News/Models/FeaturesDto.cs @@ -12,7 +12,7 @@ public class FeaturesDto /// /// The latest features. /// - public List Features { get; } = new List(); + public List Features { get; } = []; /// /// The recent version. diff --git a/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/SimulatedRuleEventDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/SimulatedRuleEventDto.cs index d6e95e23b..4597a94e9 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/SimulatedRuleEventDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/SimulatedRuleEventDto.cs @@ -68,7 +68,7 @@ public sealed record SimulatedRuleEventDto { var result = SimpleMapper.Map(ruleEvent, new SimulatedRuleEventDto { - SkipReasons = new List() + SkipReasons = [] }); foreach (var reason in Enum.GetValues()) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs index df4059a22..95bc1cf33 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs @@ -89,7 +89,7 @@ public sealed class FieldDto : Resource if (field is IArrayField arrayField) { - result.Nested = new List(); + result.Nested = []; foreach (var nestedField in arrayField.Fields) { diff --git a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs index 4787e3daf..d6a30477e 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs @@ -115,13 +115,13 @@ public class SchemaDto : Resource /// /// The field rules. /// - public List FieldRules { get; set; } = new List(); + public List FieldRules { get; set; } = []; /// /// The list of fields. /// [LocalizedRequired] - public List Fields { get; set; } = new List(); + public List Fields { get; set; } = []; public static SchemaDto FromDomain(ISchemaEntity schema, Resources resources) { diff --git a/backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs b/backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs index 058226fdc..722843853 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs @@ -12,7 +12,7 @@ namespace Squidex.Areas.Api.Controllers.UI; public sealed record MyUIOptions { [JsonExtensionData] - public Dictionary More { get; set; } = new Dictionary(); + public Dictionary More { get; set; } = []; [JsonPropertyName("regexSuggestions")] public Dictionary RegexSuggestions { get; set; } diff --git a/backend/src/Squidex/Areas/Frontend/Middlewares/OptionsFeature.cs b/backend/src/Squidex/Areas/Frontend/Middlewares/OptionsFeature.cs index d44c74da4..51bf894e5 100644 --- a/backend/src/Squidex/Areas/Frontend/Middlewares/OptionsFeature.cs +++ b/backend/src/Squidex/Areas/Frontend/Middlewares/OptionsFeature.cs @@ -9,5 +9,5 @@ namespace Squidex.Areas.Frontend.Middlewares; public sealed class OptionsFeature { - public Dictionary Options { get; } = new Dictionary(); + public Dictionary Options { get; } = []; } diff --git a/backend/src/Squidex/Areas/IdentityServer/Config/AlwaysAddScopeHandler.cs b/backend/src/Squidex/Areas/IdentityServer/Config/AlwaysAddScopeHandler.cs index ab81ac535..4280c8122 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Config/AlwaysAddScopeHandler.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Config/AlwaysAddScopeHandler.cs @@ -23,7 +23,7 @@ public sealed class AlwaysAddScopeHandler : IOpenIddictServerHandler.Empty; + var scopes = context.AccessTokenPrincipal?.GetScopes() ?? []; context.Response.Scope = string.Join(' ', scopes); } diff --git a/backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs b/backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs index 0a5bb1395..441c553b3 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs @@ -35,12 +35,7 @@ public class DynamicApplicationStore : InMemoryApplicationStore { var application = await base.FindByIdAsync(identifier, cancellationToken); - if (application == null) - { - application = await GetDynamicAsync(identifier); - } - - return application; + return application ?? await GetDynamicAsync(identifier); } public override async ValueTask FindByClientIdAsync(string identifier, diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePropertiesModel.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePropertiesModel.cs index 2d11c95af..00a049c01 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePropertiesModel.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePropertiesModel.cs @@ -15,7 +15,7 @@ public class ChangePropertiesModel public UserValues ToValues() { - var properties = Properties?.Select(x => x.ToTuple()).ToList() ?? new List<(string Name, string Value)>(); + var properties = Properties?.Select(x => x.ToTuple()).ToList() ?? []; return new UserValues { Properties = properties }; } diff --git a/backend/src/Squidex/Config/Domain/StoreServices.cs b/backend/src/Squidex/Config/Domain/StoreServices.cs index 6009244c9..22a24857f 100644 --- a/backend/src/Squidex/Config/Domain/StoreServices.cs +++ b/backend/src/Squidex/Config/Domain/StoreServices.cs @@ -183,9 +183,9 @@ public static class StoreServices { options.BaseAddress = new Uri("https://cloud.mongodb.com/"); }) - .ConfigureHttpMessageHandlerBuilder(builder => + .ConfigurePrimaryHttpMessageHandler(() => { - builder.PrimaryHandler = new HttpClientHandler + return new HttpClientHandler { Credentials = new NetworkCredential(atlasOptions.PublicKey, atlasOptions.PrivateKey, "cloud.mongodb.com") }; diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj index bb52dc590..978e32f27 100644 --- a/backend/src/Squidex/Squidex.csproj +++ b/backend/src/Squidex/Squidex.csproj @@ -1,14 +1,14 @@  - net7.0 + net8.0 Latest true latest enable en - NU1608 + NU1608 enable - true + true @@ -34,46 +34,48 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + - + + + - + - - + + - - + + - - - - - - - - - + + + + + + + + + - - - + + + @@ -87,7 +89,7 @@ true - + diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesJsonTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesJsonTests.cs index 883c9d030..0677d6287 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesJsonTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesJsonTests.cs @@ -19,11 +19,11 @@ public class RolesJsonTests { var source = new Dictionary { - ["Custom"] = new[] - { + ["Custom"] = + [ "Permission1", "Permission2" - } + ] }; var expected = diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs index 7abdf4a2d..d26b1307c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs @@ -145,8 +145,8 @@ public class ContentDataTests { var source = new ContentData { - ["field1"] = new ContentFieldData(), - ["field2"] = new ContentFieldData() + ["field1"] = [], + ["field2"] = [] }; var clone = source.Clone(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/TranslationStatusTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/TranslationStatusTests.cs index bc1489166..50be564a3 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/TranslationStatusTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/TranslationStatusTests.cs @@ -21,7 +21,7 @@ public class TranslationStatusTests { var schema = new Schema("my-schema"); - var actual = TranslationStatus.Create(new ContentData(), schema, languages); + var actual = TranslationStatus.Create([], schema, languages); Assert.Equal(new TranslationStatus { @@ -38,7 +38,7 @@ public class TranslationStatusTests new Schema("my-schema") .AddString(1, "field1", Partitioning.Invariant); - var actual = TranslationStatus.Create(new ContentData(), schema, languages); + var actual = TranslationStatus.Create([], schema, languages); Assert.Equal(new TranslationStatus { @@ -55,7 +55,7 @@ public class TranslationStatusTests new Schema("my-schema") .AddString(1, "field1", Partitioning.Language); - var actual = TranslationStatus.Create(new ContentData(), schema, languages); + var actual = TranslationStatus.Create([], schema, languages); Assert.Equal(new TranslationStatus { diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/ArrayFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/ArrayFieldTests.cs index 1d362bd85..fa90226c1 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/ArrayFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/ArrayFieldTests.cs @@ -200,11 +200,11 @@ public class ArrayfieldTests var parent_1 = parent_0.AddField(field1); var parent_2 = parent_1.AddField(field2); var parent_3 = parent_2.AddField(field3); - var parent_4 = parent_3.ReorderFields(new List { 3, 2, 1 }); - var parent_5 = parent_4.ReorderFields(new List { 3, 2, 1 }); + var parent_4 = parent_3.ReorderFields([3, 2, 1]); + var parent_5 = parent_4.ReorderFields([3, 2, 1]); - Assert.Equal(new List { field3, field2, field1 }, parent_4.Fields.ToList()); - Assert.Equal(new List { field3, field2, field1 }, parent_5.Fields.ToList()); + Assert.Equal([field3, field2, field1], parent_4.Fields.ToList()); + Assert.Equal([field3, field2, field1], parent_5.Fields.ToList()); Assert.Same(parent_4, parent_5); } @@ -217,7 +217,7 @@ public class ArrayfieldTests var parent_1 = parent_0.AddField(field1); var parent_2 = parent_1.AddField(field2); - Assert.Throws(() => parent_2.ReorderFields(new List { 1 })); + Assert.Throws(() => parent_2.ReorderFields([1])); } [Fact] @@ -229,7 +229,7 @@ public class ArrayfieldTests var parent_1 = parent_0.AddField(field1); var parent_2 = parent_1.AddField(field2); - Assert.Throws(() => parent_2.ReorderFields(new List { 1, 4 })); + Assert.Throws(() => parent_2.ReorderFields([1, 4])); } private static NestedField CreateField(int id) diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs index 016b37b60..817d76c84 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs @@ -307,11 +307,11 @@ public class SchemaTests var schema_1 = schema_0.AddField(field1); var schema_2 = schema_1.AddField(field2); var schema_3 = schema_2.AddField(field3); - var schema_4 = schema_3.ReorderFields(new List { 3, 2, 1 }); - var schema_5 = schema_4.ReorderFields(new List { 3, 2, 1 }); + var schema_4 = schema_3.ReorderFields([3, 2, 1]); + var schema_5 = schema_4.ReorderFields([3, 2, 1]); - Assert.Equal(new List { field3, field2, field1 }, schema_4.Fields.ToList()); - Assert.Equal(new List { field3, field2, field1 }, schema_5.Fields.ToList()); + Assert.Equal([field3, field2, field1], schema_4.Fields.ToList()); + Assert.Equal([field3, field2, field1], schema_5.Fields.ToList()); Assert.Same(schema_4, schema_5); } @@ -324,7 +324,7 @@ public class SchemaTests var schema_1 = schema_0.AddField(field1); var schema_2 = schema_1.AddField(field2); - Assert.Throws(() => schema_2.ReorderFields(new List { 1 })); + Assert.Throws(() => schema_2.ReorderFields([1])); } [Fact] @@ -336,7 +336,7 @@ public class SchemaTests var schema_1 = schema_0.AddField(field1); var schema_2 = schema_1.AddField(field2); - Assert.Throws(() => schema_2.ReorderFields(new List { 1, 4 })); + Assert.Throws(() => schema_2.ReorderFields([1, 4])); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionFlatTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionFlatTests.cs index 0f960594a..e999b6f40 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionFlatTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionFlatTests.cs @@ -31,7 +31,7 @@ public class ContentConversionFlatTests new ContentFieldData() .AddLocalized("it", 7)) .AddField("field5", - new ContentFieldData()); + []); [Fact] public void Should_return_flatten_value() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs index a503b5c7d..eaf53f740 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs @@ -89,7 +89,7 @@ public class ContentConversionTests var expected = new ContentData() .AddField("references", - new ContentFieldData()) + []) .AddField("assets1", new ContentFieldData() .AddInvariant(JsonValue.Array(1))) diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs index c8526e389..c9bde14b3 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs @@ -212,7 +212,7 @@ public class FieldConvertersTests var actual = new ContentConverter(ResolvedComponents.Empty, schema) - .Add(new ResolveLanguages(languages, new[] { Language.DE }) { ResolveFallback = true }) + .Add(new ResolveLanguages(languages, [Language.DE]) { ResolveFallback = true }) .Convert(source); var expected = @@ -290,7 +290,7 @@ public class FieldConvertersTests var expected = new ContentData() .AddField(field1.Name, - new ContentFieldData()); + []); Assert.Equal(expected, actual); } @@ -325,7 +325,7 @@ public class FieldConvertersTests var expected = new ContentData() .AddField(field1.Name, - new ContentFieldData()); + []); if (value != false) { @@ -473,7 +473,7 @@ public class FieldConvertersTests var source = new ContentData() .AddField(field1.Name, - new ContentFieldData()); + []); var actual = new ContentConverter(ResolvedComponents.Empty, schema) @@ -582,7 +582,7 @@ public class FieldConvertersTests var source = new ContentFieldData(); var actual = - new ResolveLanguages(languages, Array.Empty()) { ResolveFallback = true } + new ResolveLanguages(languages, []) { ResolveFallback = true } .ConvertFieldAfter(field, source); Assert.Same(source, actual); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs index 5ba7a739e..4240c3a39 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs @@ -573,7 +573,7 @@ public class SchemaSynchronizerTests var events = sourceSchema.Synchronize(targetSchema, idGenerator); events.ShouldHaveSameEvents( - new SchemaFieldsReordered { FieldIds = new[] { 11L, 10L }, ParentFieldId = arrayId } + new SchemaFieldsReordered { FieldIds = [11L, 10L], ParentFieldId = arrayId } ); } @@ -593,7 +593,7 @@ public class SchemaSynchronizerTests var events = sourceSchema.Synchronize(targetSchema, idGenerator); events.ShouldHaveSameEvents( - new SchemaFieldsReordered { FieldIds = new[] { 11L, 10L } } + new SchemaFieldsReordered { FieldIds = [11L, 10L] } ); } @@ -615,7 +615,7 @@ public class SchemaSynchronizerTests events.ShouldHaveSameEvents( new FieldDeleted { FieldId = NamedId.Of(11L, "f2") }, new FieldAdded { FieldId = NamedId.Of(50L, "f3"), Name = "f3", Partitioning = Partitioning.Invariant.Key, Properties = new StringFieldProperties() }, - new SchemaFieldsReordered { FieldIds = new[] { 50L, 10L } } + new SchemaFieldsReordered { FieldIds = [50L, 10L] } ); } @@ -637,7 +637,7 @@ public class SchemaSynchronizerTests events.ShouldHaveSameEvents( new FieldAdded { FieldId = NamedId.Of(50L, "f3"), Name = "f3", Partitioning = Partitioning.Invariant.Key, Properties = new StringFieldProperties() }, - new SchemaFieldsReordered { FieldIds = new[] { 10L, 50L, 11L } } + new SchemaFieldsReordered { FieldIds = [10L, 50L, 11L] } ); } @@ -659,7 +659,7 @@ public class SchemaSynchronizerTests events.ShouldHaveSameEvents( new FieldDeleted { FieldId = NamedId.Of(10L, "f1") }, new FieldAdded { FieldId = NamedId.Of(50L, "f3"), Name = "f3", Partitioning = Partitioning.Invariant.Key, Properties = new StringFieldProperties() }, - new SchemaFieldsReordered { FieldIds = new[] { 50L, 11L } } + new SchemaFieldsReordered { FieldIds = [50L, 11L] } ); } } diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs index 48e33111a..61f37ddbe 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs @@ -191,7 +191,7 @@ public class ReferenceExtractionTests var actual = new ContentConverter(components, schema) - .Add(new ValueReferencesConverter(new HashSet { id2 })) + .Add(new ValueReferencesConverter([id2])) .Convert(source); Assert.Equal(expected, actual); @@ -273,7 +273,7 @@ public class ReferenceExtractionTests var actual = field.GetReferencedIds(value, components); - Assert.Equal(new HashSet { id1, id2 }, actual); + Assert.Equal([id1, id2], actual); } [Theory] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleTypeProviderTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleTypeProviderTests.cs index 0f36b6bf3..a0a9923ab 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleTypeProviderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleTypeProviderTests.cs @@ -143,7 +143,7 @@ public class RuleTypeProviderTests Description = null, Editor = RuleFieldEditor.Dropdown, IsRequired = false, - Options = new[] { "Yes", "No" } + Options = ["Yes", "No"] }); expected.Properties.Add(new RuleActionProperty @@ -153,7 +153,7 @@ public class RuleTypeProviderTests Description = null, Editor = RuleFieldEditor.Dropdown, IsRequired = false, - Options = new[] { "Yes", "No" } + Options = ["Yes", "No"] }); expected.Properties.Add(new RuleActionProperty diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/AssetMetadataWrapperTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/AssetMetadataWrapperTests.cs deleted file mode 100644 index 5e53c1f69..000000000 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/AssetMetadataWrapperTests.cs +++ /dev/null @@ -1,112 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using Squidex.Domain.Apps.Core.Assets; -using Squidex.Domain.Apps.Core.Scripting.Internal; -using Squidex.Infrastructure.Json.Objects; - -namespace Squidex.Domain.Apps.Core.Operations.Scripting; - -public class AssetMetadataWrapperTests -{ - private readonly AssetMetadata metadata = new AssetMetadata(); - private readonly AssetMetadataWrapper sut; - - public AssetMetadataWrapperTests() - { - sut = new AssetMetadataWrapper(metadata); - } - - [Fact] - public void Should_add_value() - { - sut.Add("key", 1); - - Assert.Equal(JsonValue.Create(1), metadata["key"]); - Assert.Equal(JsonValue.Create(1), sut["key"]); - - Assert.True(metadata.ContainsKey("key")); - Assert.True(sut.ContainsKey("key")); - - Assert.Single(metadata); - Assert.Single(sut); - } - - [Fact] - public void Should_set_value() - { - sut["key"] = 1; - - Assert.Equal(JsonValue.Create(1), metadata["key"]); - Assert.Equal(JsonValue.Create(1), sut["key"]); - - Assert.True(metadata.ContainsKey("key")); - Assert.True(sut.ContainsKey("key")); - - Assert.Single(metadata); - Assert.Single(sut); - } - - [Fact] - public void Should_provide_keys() - { - sut["key1"] = 1; - sut["key2"] = 2; - - Assert.Equal(new[] - { - "key1", - "key2" - }, sut.Keys.ToArray()); - } - - [Fact] - public void Should_provide_values() - { - sut["key1"] = 1; - sut["key2"] = 2; - - Assert.Equal(new object[] - { - JsonValue.Create(1), - JsonValue.Create(2) - }, sut.Values.ToArray()); - } - - [Fact] - public void Should_enumerate_values() - { - sut["key1"] = 1; - sut["key2"] = 2; - - Assert.Equal(new[] - { - new KeyValuePair("key1", JsonValue.Create(1)), - new KeyValuePair("key2", JsonValue.Create(2)) - }, sut.ToArray()); - } - - [Fact] - public void Should_remove_value() - { - sut["key"] = 1; - sut.Remove("key"); - - Assert.Empty(metadata); - Assert.Empty(sut); - } - - [Fact] - public void Should_clear_collection() - { - sut["key"] = 1; - sut.Clear(); - - Assert.Empty(metadata); - Assert.Empty(sut); - } -} diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs index be3bfe887..cb0ee139a 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs @@ -281,7 +281,7 @@ public class ContentDataObjectTests var original = new ContentData() .AddField("number", - new ContentFieldData()); + []); var expected = new ContentData() @@ -310,7 +310,7 @@ public class ContentDataObjectTests var expected = new ContentData() .AddField("string", - new ContentFieldData()); + []); const string script = @" delete data.string.iv @@ -406,7 +406,7 @@ public class ContentDataObjectTests data.string.iv = 'hello' "; - ExecuteScript(new ContentData(), script); + ExecuteScript([], script); } private static ContentData ExecuteScript(ContentData original, string script) diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs index aec7515aa..c67cc9714 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs @@ -56,7 +56,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return html2Text(value); + html2Text(value); "; var actual = sut.Execute(vars, script).AsString; @@ -73,7 +73,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return markdown2Text(value); + markdown2Text(value); "; var actual = sut.Execute(vars, script).AsString; @@ -90,7 +90,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return wordCount(value); + wordCount(value); "; var actual = sut.Execute(vars, script).AsNumber; @@ -107,7 +107,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return characterCount(value); + characterCount(value); "; var actual = sut.Execute(vars, script).AsNumber; @@ -124,7 +124,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return toCamelCase(value); + toCamelCase(value); "; var actual = sut.Execute(vars, script).AsString; @@ -141,7 +141,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return toPascalCase(value); + toPascalCase(value); "; var actual = sut.Execute(vars, script).AsString; @@ -158,7 +158,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return slugify(value); + slugify(value); "; var actual = sut.Execute(vars, script).AsString; @@ -175,7 +175,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return slugify(value, true); + slugify(value, true); "; var actual = sut.Execute(vars, script).AsString; @@ -192,7 +192,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return sha256(value); + sha256(value); "; var actual = sut.Execute(vars, script).AsString; @@ -209,7 +209,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return sha512(value); + sha512(value); "; var actual = sut.Execute(vars, script).AsString; @@ -226,7 +226,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return md5(value); + md5(value); "; var actual = sut.Execute(vars, script).AsString; @@ -242,7 +242,7 @@ public class JintScriptEngineHelperTests : IClassFixture }; const string script = @" - return guid(); + guid(); "; var actual = sut.Execute(vars, script).AsString; diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs index faac8e0ed..7d9e9a93d 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs @@ -509,7 +509,7 @@ public class JintScriptEngineTests : IClassFixture }; const string script = @" - return value; + value; "; var actual = sut.Execute(vars, script); @@ -526,7 +526,7 @@ public class JintScriptEngineTests : IClassFixture }; const string script = @" - return value; + value; "; var actual = sut.Execute(vars, script); @@ -561,7 +561,7 @@ public class JintScriptEngineTests : IClassFixture "; const string script2 = @" - return ctx.shared + 2; + ctx.shared + 2; "; sut.Execute(vars, script1, new ScriptOptions { AsContext = true }); @@ -584,7 +584,7 @@ public class JintScriptEngineTests : IClassFixture "; const string script2 = @" - return ctx.obj.number + 2; + ctx.obj.number + 2; "; sut.Execute(vars, script1, new ScriptOptions { AsContext = true }); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintUserTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintUserTests.cs index 1db2035f4..123fb7cbf 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintUserTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintUserTests.cs @@ -107,7 +107,7 @@ public class JintUserTests Assert.Equal(isClient, GetValue(identity, "user.isClient")); } - private static object GetValue(ClaimsIdentity identity, string script) + private static object? GetValue(ClaimsIdentity identity, string script) { var engine = new Engine(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ScriptingCompleterTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ScriptingCompleterTests.cs index 38ac4870c..31cd9ea04 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ScriptingCompleterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ScriptingCompleterTests.cs @@ -50,8 +50,7 @@ public class ScriptingCompleterTests AssertCompletion(actual, PresetUser("ctx.user"), - new[] - { + [ "ctx", "ctx.appId", "ctx.appName", @@ -73,7 +72,7 @@ public class ScriptingCompleterTests "ctx.status", "ctx.statusOld", "ctx.validate" - }); + ]); } [Fact] @@ -83,8 +82,7 @@ public class ScriptingCompleterTests AssertCompletion(actual, PresetUser("ctx.user"), - new[] - { + [ "ctx", "ctx.appId", "ctx.appName", @@ -117,7 +115,7 @@ public class ScriptingCompleterTests "ctx.command.permanent", "ctx.command.tags", "ctx.operation" - }); + ]); } [Fact] @@ -141,8 +139,7 @@ public class ScriptingCompleterTests AssertCompletion(actual, PresetActor("event.actor"), PresetUser("event.user"), - new[] - { + [ "event", "event.appId", "event.appId.id", @@ -171,7 +168,7 @@ public class ScriptingCompleterTests "event.timestamp", "event.type", "event.version" - }); + ]); } [Fact] @@ -233,8 +230,7 @@ public class ScriptingCompleterTests AssertCompletion(actual, PresetActor("event.actor"), PresetUser("event.user"), - new[] - { + [ "event", "event.appId", "event.appId.id", @@ -266,7 +262,7 @@ public class ScriptingCompleterTests "event.timestamp", "event.type", "event.version" - }); + ]); } [Fact] @@ -291,8 +287,7 @@ public class ScriptingCompleterTests PresetActor("event.actor"), PresetUser("event.user"), PresetUser("event.mentionedUser"), - new[] - { + [ "event", "event.appId", "event.appId.id", @@ -301,7 +296,7 @@ public class ScriptingCompleterTests "event.text", "event.timestamp", "event.version" - }); + ]); } [Fact] @@ -325,8 +320,7 @@ public class ScriptingCompleterTests AssertCompletion(actual, PresetActor("event.actor"), PresetUser("event.user"), - new[] - { + [ "event", "event.appId", "event.appId.id", @@ -338,7 +332,7 @@ public class ScriptingCompleterTests "event.timestamp", "event.type", "event.version" - }); + ]); } [Fact] @@ -393,18 +387,18 @@ public class ScriptingCompleterTests private static string[] PresetActor(string path) { - return new[] - { + return + [ $"{path}", $"{path}.identifier", $"{path}.type" - }; + ]; } private static string[] PresetUser(string path) { - return new[] - { + return + [ $"{path}", $"{path}.claims", $"{path}.claims.name", @@ -412,6 +406,6 @@ public class ScriptingCompleterTests $"{path}.id", $"{path}.isClient", $"{path}.isUser" - }; + ]; } } diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs index d38e70227..83d2d7765 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs @@ -223,7 +223,7 @@ public class FluidTemplateEngineTests { var template = "{% for x of event %}"; - await Assert.ThrowsAsync(() => sut.RenderAsync(template, new TemplateVars())); + await Assert.ThrowsAsync(() => sut.RenderAsync(template, [])); } private Task RenderAync(string template, object value) diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs index 44d3486cf..3b4d79c55 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ArrayFieldTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class ArrayFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs index ba7939418..6f40d59c6 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/AssetsFieldTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class AssetsFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; private readonly DomainId asset1 = DomainId.NewGuid(); private readonly DomainId asset2 = DomainId.NewGuid(); private readonly IValidatorsFactory factory; diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/BooleanFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/BooleanFieldTests.cs index f4561e7af..f2654ceae 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/BooleanFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/BooleanFieldTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class BooleanFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentFieldTests.cs index fb274f3a6..a72c37eb4 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentFieldTests.cs @@ -18,7 +18,7 @@ public class ComponentFieldTests : IClassFixture { private readonly DomainId schemaId1 = DomainId.NewGuid(); private readonly DomainId schemaId2 = DomainId.NewGuid(); - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentsFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentsFieldTests.cs index a0ad917e5..1a93d4bba 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentsFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ComponentsFieldTests.cs @@ -18,7 +18,7 @@ public class ComponentsFieldTests : IClassFixture { private readonly DomainId schemaId1 = DomainId.NewGuid(); private readonly DomainId schemaId2 = DomainId.NewGuid(); - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ContentValidationTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ContentValidationTests.cs index 41194f9db..d3f7bedca 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ContentValidationTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ContentValidationTests.cs @@ -19,7 +19,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class ContentValidationTests : IClassFixture { private readonly LanguagesConfig languages = LanguagesConfig.English.Set(Language.DE); - private readonly List errors = new List(); + private readonly List errors = []; private Schema schema = new Schema("my-schema"); [Fact] @@ -90,7 +90,7 @@ public class ContentValidationTests : IClassFixture var data = new ContentData() .AddField("unknown", - new ContentFieldData()); + []); await data.ValidateAsync(languages.ToResolver(), errors, schema); @@ -271,7 +271,7 @@ public class ContentValidationTests : IClassFixture var data = new ContentData() .AddField("unknown", - new ContentFieldData()); + []); await data.ValidatePartialAsync(languages.ToResolver(), errors, schema); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/DateTimeFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/DateTimeFieldTests.cs index 3db70795b..351ba087c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/DateTimeFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/DateTimeFieldTests.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class DateTimeFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/GeolocationFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/GeolocationFieldTests.cs index 45ac0b663..f6a749d89 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/GeolocationFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/GeolocationFieldTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class GeolocationFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/JsonFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/JsonFieldTests.cs index 5587bb3ba..bef20ad8a 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/JsonFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/JsonFieldTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class JsonFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/NumberFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/NumberFieldTests.cs index f17d9c9fb..04f449a41 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/NumberFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/NumberFieldTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class NumberFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs index 66a46b19a..c6b0b023c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ReferencesFieldTests.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class ReferencesFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; private readonly DomainId schemaId = DomainId.NewGuid(); private readonly DomainId ref1 = DomainId.NewGuid(); private readonly DomainId ref2 = DomainId.NewGuid(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/StringFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/StringFieldTests.cs index 755097c5a..8b9f4b4dd 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/StringFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/StringFieldTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class StringFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs index 328fa7b73..c4d160b5d 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/TagsFieldTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class TagsFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/UIFieldTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/UIFieldTests.cs index 1c46e9cfb..6ed47399c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/UIFieldTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/UIFieldTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent; public class UIFieldTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public void Should_instantiate_field() @@ -68,7 +68,7 @@ public class UIFieldTests : IClassFixture var data = new ContentData() - .AddField("myUI1", new ContentFieldData()) + .AddField("myUI1", []) .AddField("myUI2", new ContentFieldData() .AddInvariant(JsonValue.Null)); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AllowedValuesValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AllowedValuesValidatorTests.cs index 84ea27413..8755cb376 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AllowedValuesValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AllowedValuesValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class AllowedValuesValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_null() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs index 2d2b16986..0a4e1b875 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class AssetsValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; private static readonly IAssetInfo Document = TestAssets.Document(DomainId.NewGuid()); private static readonly IAssetInfo Image1 = TestAssets.Image(DomainId.NewGuid()); private static readonly IAssetInfo Image2 = TestAssets.Image(DomainId.NewGuid()); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionItemValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionItemValidatorTests.cs index 5b58eeaaf..988643ed1 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionItemValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionItemValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class CollectionItemValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_wrong_type() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionValidatorTests.cs index f0bab3082..a2dd93b11 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/CollectionValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class CollectionValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Theory] [InlineData(20, 10)] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ComponentValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ComponentValidatorTests.cs index 5eb073180..a93e1fd4b 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ComponentValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ComponentValidatorTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class ComponentValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_create_validator_from_component_and_invoke() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/NoValueValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/NoValueValidatorTests.cs index 43e3edd68..2020798cf 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/NoValueValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/NoValueValidatorTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class NoValueValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_undefined() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs index 73543c805..6c2ce9684 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class PatternValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_valid() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RangeValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RangeValidatorTests.cs index 589b29af1..c28c142bf 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RangeValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RangeValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class RangeValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_null() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ReferencesValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ReferencesValidatorTests.cs index cbd1992e6..d4008e7f2 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ReferencesValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/ReferencesValidatorTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class ReferencesValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; private readonly DomainId schemaId1 = DomainId.NewGuid(); private readonly DomainId schemaId2 = DomainId.NewGuid(); private readonly DomainId ref1 = DomainId.NewGuid(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredStringValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredStringValidatorTests.cs index 52d9d6ed8..8be7d3289 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredStringValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredStringValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class RequiredStringValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Theory] [InlineData("MyString")] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredValidatorTests.cs index 87cb52f1a..4afcb1332 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/RequiredValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class RequiredValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_valid() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringLengthValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringLengthValidatorTests.cs index 4747ec3f2..170e0e489 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringLengthValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringLengthValidatorTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class StringLengthValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_null() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringTextValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringTextValidatorTests.cs index b84247b60..9a1f92b0b 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringTextValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/StringTextValidatorTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class StringTextValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Theory] [InlineData(20, 10)] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs index 95db62b47..db3ce344e 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class UniqueObjectValuesValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_errors_if_value_is_invalid() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValidatorTests.cs index 4a38bf99b..82d4a9601 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValidatorTests.cs @@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class UniqueValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_check_uniqueness_if_localized_string() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValuesValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValuesValidatorTests.cs index 65232db91..518389e82 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValuesValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueValuesValidatorTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators; public class UniqueValuesValidatorTests : IClassFixture { - private readonly List errors = new List(); + private readonly List errors = []; [Fact] public async Task Should_not_add_error_if_value_is_null() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj b/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj index f7e714d28..20c582534 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj @@ -1,7 +1,7 @@  Exe - net7.0 + net8.0 Squidex.Domain.Apps.Core latest enable @@ -14,29 +14,29 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + - - + + all runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/AppProviderTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/AppProviderTests.cs index 3e26d3dd0..be723234e 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/AppProviderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/AppProviderTests.cs @@ -51,7 +51,7 @@ public class AppProviderTests : GivenContext public async Task Should_get_team_apps_from_index() { A.CallTo(() => indexForApps.GetAppsForTeamAsync(TeamId, CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetTeamAppsAsync(TeamId, CancellationToken); @@ -64,7 +64,7 @@ public class AppProviderTests : GivenContext var permissions = new PermissionSet("*"); A.CallTo(() => indexForApps.GetAppsForUserAsync("user1", permissions, CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetUserAppsAsync("user1", permissions, CancellationToken); @@ -108,7 +108,7 @@ public class AppProviderTests : GivenContext public async Task Should_get_teams_from_index() { A.CallTo(() => indexForTeams.GetTeamsAsync("user1", CancellationToken)) - .Returns(new List { Team }); + .Returns([Team]); var actual = await sut.GetUserTeamsAsync("user1", CancellationToken); @@ -141,7 +141,7 @@ public class AppProviderTests : GivenContext public async Task Should_get_schemas_from_index() { A.CallTo(() => indexForSchemas.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { Schema }); + .Returns([Schema]); var actual = await sut.GetSchemasAsync(AppId.Id, CancellationToken); @@ -154,7 +154,7 @@ public class AppProviderTests : GivenContext var rule = new RuleEntity(); A.CallTo(() => indexForRules.GetRulesAsync(AppId.Id, CancellationToken)) - .Returns(new List { rule }); + .Returns([rule]); var actual = await sut.GetRulesAsync(AppId.Id, CancellationToken); @@ -167,7 +167,7 @@ public class AppProviderTests : GivenContext var rule = new RuleEntity { Id = DomainId.NewGuid() }; A.CallTo(() => indexForRules.GetRulesAsync(AppId.Id, CancellationToken)) - .Returns(new List { rule }); + .Returns([rule]); var actual = await sut.GetRuleAsync(AppId.Id, rule.Id, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppPermanentDeleterTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppPermanentDeleterTests.cs index 77a096bcc..71bfb2d0b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppPermanentDeleterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppPermanentDeleterTests.cs @@ -51,7 +51,7 @@ public class AppPermanentDeleterTests : GivenContext var storedEvent = new StoredEvent("stream", "1", 1, - new EventData(eventType, new EnvelopeHeaders(), "payload")); + new EventData(eventType, [], "payload")); Assert.True(sut.Handles(storedEvent)); } @@ -63,7 +63,7 @@ public class AppPermanentDeleterTests : GivenContext var storedEvent = new StoredEvent("stream", "1", 1, - new EventData(eventType, new EnvelopeHeaders(), "payload")); + new EventData(eventType, [], "payload")); Assert.True(sut.Handles(storedEvent)); } @@ -75,7 +75,7 @@ public class AppPermanentDeleterTests : GivenContext var storedEvent = new StoredEvent("stream", "1", 1, - new EventData(eventType, new EnvelopeHeaders(), "payload")); + new EventData(eventType, [], "payload")); Assert.False(sut.Handles(storedEvent)); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs index f7e9c58c7..b8c68a5a0 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs @@ -141,6 +141,6 @@ public class DefaultAppLogStoreTests : GivenContext private static Request CreateRecord() { - return new Request { Properties = new Dictionary() }; + return new Request { Properties = [] }; } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs index d469e2f79..8521f8a54 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs @@ -621,7 +621,7 @@ public class AppDomainObjectTests : HandlerTestBase [Fact] public async Task UpdateLanguage_should_create_events_and_update_language() { - var command = new UpdateLanguage { Language = Language.DE, Fallback = new[] { Language.EN } }; + var command = new UpdateLanguage { Language = Language.DE, Fallback = [Language.EN] }; await ExecuteCreateAsync(); await ExecuteAddLanguageAsync(Language.DE); @@ -634,7 +634,7 @@ public class AppDomainObjectTests : HandlerTestBase LastEvents .ShouldHaveSameEvents( - CreateEvent(new AppLanguageUpdated { Language = Language.DE, Fallback = new[] { Language.EN } }) + CreateEvent(new AppLanguageUpdated { Language = Language.DE, Fallback = [Language.EN] }) ); } @@ -680,7 +680,7 @@ public class AppDomainObjectTests : HandlerTestBase [Fact] public async Task UpdateRole_should_create_events_and_update_role() { - var command = new UpdateRole { Name = roleName, Permissions = new[] { "clients.read" }, Properties = JsonValue.Object() }; + var command = new UpdateRole { Name = roleName, Permissions = ["clients.read"], Properties = JsonValue.Object() }; await ExecuteCreateAsync(); await ExecuteAddRoleAsync(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs index bf960617c..573b8483b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs @@ -96,7 +96,7 @@ public class GuardAppLanguagesTests : GivenContext, IClassFixture GuardAppLanguages.CanUpdate(command, App), new ValidationError("Master language cannot have fallback languages.", "Fallback")); @@ -105,7 +105,7 @@ public class GuardAppLanguagesTests : GivenContext, IClassFixture GuardAppLanguages.CanUpdate(command, App), new ValidationError("App does not have fallback language 'Italian'.", "Fallback")); @@ -122,7 +122,7 @@ public class GuardAppLanguagesTests : GivenContext, IClassFixture GuardAppRoles.CanUpdate(command, App), new ValidationError("Name is required.", "Name")); @@ -147,7 +147,7 @@ public class GuardAppRolesTests : GivenContext, IClassFixture GuardAppRoles.CanUpdate(command, App), new ValidationError("Cannot update a default role.")); @@ -156,7 +156,7 @@ public class GuardAppRolesTests : GivenContext, IClassFixture(() => GuardAppRoles.CanUpdate(command, App)); } @@ -166,7 +166,7 @@ public class GuardAppRolesTests : GivenContext, IClassFixture appRepository.QueryAllAsync(User.Identifier, A>.That.Is(AppId.Name), CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetAppsForUserAsync(User.Identifier, new PermissionSet($"squidex.apps.{AppId.Name}"), CancellationToken); @@ -123,7 +123,7 @@ public class AppsIndexTests : GivenContext public async Task Should_resolve_all_apps_from_user() { A.CallTo(() => appRepository.QueryAllAsync(User.Identifier, A>.That.IsEmpty(), CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetAppsForUserAsync(User.Identifier, PermissionSet.Empty, CancellationToken); @@ -134,7 +134,7 @@ public class AppsIndexTests : GivenContext public async Task Should_resolve_all_apps_from_team() { A.CallTo(() => appRepository.QueryAllAsync(TeamId, CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetAppsForTeamAsync(TeamId, CancellationToken); @@ -148,7 +148,7 @@ public class AppsIndexTests : GivenContext .Returns(EtagVersion.Empty); A.CallTo(() => appRepository.QueryAllAsync(User.Identifier, A>.That.IsEmpty(), CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetAppsForUserAsync(User.Identifier, PermissionSet.Empty, CancellationToken); @@ -162,7 +162,7 @@ public class AppsIndexTests : GivenContext .Returns(true); A.CallTo(() => appRepository.QueryAllAsync(User.Identifier, A>.That.IsEmpty(), CancellationToken)) - .Returns(new List { App }); + .Returns([App]); var actual = await sut.GetAppsForUserAsync(User.Identifier, PermissionSet.Empty, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs index 19ad56473..4d528afbb 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RolePermissionsProviderTests.cs @@ -26,11 +26,11 @@ public class RolePermissionsProviderTests : GivenContext public async Task Should_provide_all_permissions() { A.CallTo(() => AppProvider.GetSchemasAsync(A._, default)) - .Returns(new List - { + .Returns( + [ Mocks.Schema(AppId, NamedId.Of(DomainId.NewGuid(), "schema1")), Mocks.Schema(AppId, NamedId.Of(DomainId.NewGuid(), "schema2")) - }); + ]); var actual = await sut.GetPermissionsAsync(App); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Templates/TemplatesClientTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Templates/TemplatesClientTests.cs index a9ae2b1ce..75d219ee0 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Templates/TemplatesClientTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Templates/TemplatesClientTests.cs @@ -29,13 +29,13 @@ public class TemplatesClientTests sut = new TemplatesClient(httpClientFactory, Options.Create(new TemplatesOptions { - Repositories = new[] - { + Repositories = + [ new TemplateRepository { ContentUrl = "https://raw.githubusercontent.com/Squidex/templates/main" - } - } + }, + ] })); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs index 89e5a124c..7e53ac7e4 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs @@ -49,7 +49,7 @@ public class AssetPermanentDeleterTests : GivenContext var storedEvent = new StoredEvent("stream", "1", 1, - new EventData(eventType, new EnvelopeHeaders(), "payload")); + new EventData(eventType, [], "payload")); Assert.True(sut.Handles(storedEvent)); } @@ -61,7 +61,7 @@ public class AssetPermanentDeleterTests : GivenContext var storedEvent = new StoredEvent("stream", "1", 1, - new EventData(eventType, new EnvelopeHeaders(), "payload")); + new EventData(eventType, [], "payload")); Assert.False(sut.Handles(storedEvent)); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs index 3aa8b6146..275895ab5 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs @@ -98,11 +98,11 @@ public class AssetUsageTrackerTests : GivenContext var @event = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - }, + ], AssetId = assetId }; @@ -130,22 +130,22 @@ public class AssetUsageTrackerTests : GivenContext var @event1 = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - }, + ], AssetId = assetId }; var @event2 = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag2", "tag3" - }, + ], AssetId = assetId }; @@ -181,22 +181,22 @@ public class AssetUsageTrackerTests : GivenContext var @event1 = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - }, + ], AssetId = assetId }; var @event2 = new AssetAnnotated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag2", "tag3" - }, + ], AssetId = assetId }; @@ -229,22 +229,22 @@ public class AssetUsageTrackerTests : GivenContext var @event1 = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - }, + ], AssetId = assetId }; var @event2 = new AssetAnnotated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag2", "tag3" - }, + ], AssetId = assetId }; @@ -278,11 +278,11 @@ public class AssetUsageTrackerTests : GivenContext var @event1 = new AssetCreated { AppId = AppId, - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - }, + ], AssetId = assetId }; @@ -315,11 +315,11 @@ public class AssetUsageTrackerTests : GivenContext { var state = new AssetUsageTracker.State { - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - } + ] }; A.CallTo(() => store.ReadAsync(assetKey, default)) @@ -350,11 +350,11 @@ public class AssetUsageTrackerTests : GivenContext { IAssetEntity asset = new AssetEntity { - Tags = new HashSet - { + Tags = + [ "tag1", "tag2" - } + ] }; A.CallTo(() => assetLoader.GetAsync(AppId.Id, assetId, 41, default)) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs index d1e0546bd..2196bf394 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs @@ -42,7 +42,7 @@ public class BackupAssetsTests : GivenContext { var tags = new TagsExport { - Tags = new Dictionary() + Tags = [] }; var context = CreateBackupContext(); @@ -55,8 +55,8 @@ public class BackupAssetsTests : GivenContext A.CallTo(() => context.Writer.WriteJsonAsync(A._, tags.Tags, CancellationToken)) .MustHaveHappened(); - A.CallTo(() => context.Writer.WriteJsonAsync(A._, tags.Alias!, A._)) - .MustNotHaveHappened(); + A.CallTo(() => context.Writer.WriteJsonAsync(A._, tags.Alias, A._)) + .MustHaveHappened(); } [Fact] @@ -68,7 +68,7 @@ public class BackupAssetsTests : GivenContext { ["tag1"] = "new-name" }, - Tags = new Dictionary() + Tags = [] }; var context = CreateBackupContext(); @@ -324,11 +324,11 @@ public class BackupAssetsTests : GivenContext await sut.RestoreAsync(context, CancellationToken); - Assert.Equal(new HashSet - { + Assert.Equal( + [ DomainId.Combine(AppId, assetId1), DomainId.Combine(AppId, assetId2) - }, rebuildAssets); + ], rebuildAssets); } [Fact] @@ -361,11 +361,11 @@ public class BackupAssetsTests : GivenContext await sut.RestoreAsync(context, CancellationToken); - Assert.Equal(new HashSet - { + Assert.Equal( + [ DomainId.Combine(AppId, assetFolderId1), DomainId.Combine(AppId, assetFolderId2) - }, rebuildAssetFolders); + ], rebuildAssetFolders); } private BackupContext CreateBackupContext() diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs index f577dcaf7..9519aed6f 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs @@ -54,7 +54,7 @@ public class AssetDomainObjectTests : HandlerTestBase .Returns(new List { A.Fake() }); A.CallTo(() => tagService.GetTagIdsAsync(AppId.Id, TagGroups.Assets, A>._, default)) - .ReturnsLazily(x => Task.FromResult(x.GetArgument>(2)?.ToDictionary(x => x) ?? new Dictionary())); + .ReturnsLazily(x => Task.FromResult(x.GetArgument>(2)?.ToDictionary(x => x) ?? [])); var log = A.Fake>(); @@ -102,9 +102,9 @@ public class AssetDomainObjectTests : HandlerTestBase FileSize = file.FileSize, FileHash = command.FileHash, FileVersion = 0, - Metadata = new AssetMetadata(), + Metadata = [], MimeType = file.MimeType, - Tags = new HashSet(), + Tags = [], Slug = file.FileName.ToAssetSlug() }) ); @@ -155,9 +155,9 @@ public class AssetDomainObjectTests : HandlerTestBase FileSize = file.FileSize, FileHash = command.FileHash, FileVersion = 0, - Metadata = new AssetMetadata(), + Metadata = [], MimeType = file.MimeType, - Tags = new HashSet(), + Tags = [], Slug = file.FileName.ToAssetSlug() }) ); @@ -187,7 +187,7 @@ public class AssetDomainObjectTests : HandlerTestBase FileSize = file.FileSize, FileHash = command.FileHash, FileVersion = 1, - Metadata = new AssetMetadata(), + Metadata = [], MimeType = file.MimeType }) ); @@ -217,7 +217,7 @@ public class AssetDomainObjectTests : HandlerTestBase FileSize = file.FileSize, FileHash = command.FileHash, FileVersion = 1, - Metadata = new AssetMetadata(), + Metadata = [], MimeType = file.MimeType }) ); @@ -317,7 +317,7 @@ public class AssetDomainObjectTests : HandlerTestBase [Fact] public async Task AnnotateTags_should_create_events_and_update_tags() { - var command = new AnnotateAsset { Tags = new HashSet { "tag1" } }; + var command = new AnnotateAsset { Tags = ["tag1"] }; await ExecuteCreateAsync(); @@ -327,7 +327,7 @@ public class AssetDomainObjectTests : HandlerTestBase LastEvents .ShouldHaveSameEvents( - CreateAssetEvent(new AssetAnnotated { Tags = new HashSet { "tag1" } }) + CreateAssetEvent(new AssetAnnotated { Tags = ["tag1"] }) ); A.CallTo(() => scriptEngine.ExecuteAsync(A._, "", ScriptOptions(), CancellationToken)) @@ -372,7 +372,7 @@ public class AssetDomainObjectTests : HandlerTestBase LastEvents .ShouldHaveSameEvents( - CreateAssetEvent(new AssetDeleted { DeletedSize = 2048, OldTags = new HashSet() }) + CreateAssetEvent(new AssetDeleted { DeletedSize = 2048, OldTags = [] }) ); A.CallTo(() => scriptEngine.ExecuteAsync(A._, "", ScriptOptions(), CancellationToken)) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs index 1e627a106..0b358188f 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs @@ -37,7 +37,7 @@ public class AssetsBulkUpdateCommandMiddlewareTests : GivenContext [Fact] public async Task Should_do_nothing_if_jobs_is_empty() { - var command = new BulkUpdateAssets { Jobs = Array.Empty() }; + var command = new BulkUpdateAssets { Jobs = [] }; var actual = await PublishAsync(command); @@ -167,15 +167,15 @@ public class AssetsBulkUpdateCommandMiddlewareTests : GivenContext return new BulkUpdateAssets { AppId = AppId, - Jobs = new[] - { + Jobs = + [ new BulkUpdateJob { Type = type, Id = id, FileName = fileName - } - } + }, + ] }; } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/ScriptingExtensionsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/ScriptingExtensionsTests.cs index cd756e346..39acfe626 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/ScriptingExtensionsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/ScriptingExtensionsTests.cs @@ -24,7 +24,7 @@ public sealed class ScriptingExtensionsTests : GivenContext { var script = "ctx.command.tags.add('tag');"; - var command = new AnnotateAsset { Tags = new HashSet() }; + var command = new AnnotateAsset { Tags = [] }; var operation = Operation(script, CreateAsset(), command); @@ -38,7 +38,7 @@ public sealed class ScriptingExtensionsTests : GivenContext { var script = "ctx.command.metadata['foo'] = 42;"; - var command = new AnnotateAsset { Metadata = new AssetMetadata() }; + var command = new AnnotateAsset { Metadata = [] }; var operation = Operation(script, CreateAsset(), command); @@ -108,8 +108,8 @@ public sealed class ScriptingExtensionsTests : GivenContext AppId = AppId, Created = default, CreatedBy = User, - Metadata = new AssetMetadata(), - Tags = new HashSet() + Metadata = [], + Tags = [] }; } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetMappingTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetMappingTests.cs index 1bee0ba32..9a1064d49 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetMappingTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetMappingTests.cs @@ -41,7 +41,7 @@ public class AssetMappingTests MimeType = "image/png", ParentId = DomainId.NewGuid(), Slug = "my-image", - Tags = new HashSet { "image" }, + Tags = ["image"], TotalSize = 1024 * 2, Type = AssetType.Image, Version = 42 diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs index 332567cb8..d7660d741 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs @@ -26,10 +26,10 @@ public sealed class AssetsQueryFixture : IAsyncLifetime private readonly int numValues = 250; private readonly NamedId[] appIds = - { + [ NamedId.Of(DomainId.Create("3b5ba909-e5a5-4858-9d0d-df4ff922d452"), "my-app1"), NamedId.Of(DomainId.Create("4b3672c1-97c6-4e0b-a067-71e9e9a29db9"), "my-app1") - }; + ]; public IMongoDatabase Database { get; } @@ -123,10 +123,10 @@ public sealed class AssetsQueryFixture : IAsyncLifetime { ["value"] = JsonValue.Create(tag) }, - Tags = new HashSet - { + Tags = + [ tag - }, + ], Slug = fileName }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs index 60405b409..021eeb1b6 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs @@ -183,7 +183,7 @@ public class AssetsQueryIntegrationTests : IClassFixture, IA { clrQuery.Top = top; clrQuery.Skip = skip; - clrQuery.Sort ??= new List(); + clrQuery.Sort ??= []; if (clrQuery.Sort.Count == 0) { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs index c7a85d93c..d5b3455c1 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs @@ -161,7 +161,7 @@ public class AssetQueryParserTests : GivenContext public async Task Should_not_fail_if_tags_not_found() { A.CallTo(() => tagService.GetTagIdsAsync(AppId.Id, TagGroups.Assets, A>.That.Contains("name1"), CancellationToken)) - .Returns(new Dictionary()); + .Returns([]); var query = Q.Empty.WithODataQuery("$filter=tags eq 'name1'"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/ConvertTagsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/ConvertTagsTests.cs index 3dccc7316..f34f7f634 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/ConvertTagsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/ConvertTagsTests.cs @@ -48,11 +48,11 @@ public class ConvertTagsTests : GivenContext { var asset = new AssetEntity { - Tags = new HashSet - { + Tags = + [ "id1", "id2" - }, + ], AppId = AppId }; @@ -65,7 +65,7 @@ public class ConvertTagsTests : GivenContext await sut.EnrichAsync(ApiContext, Enumerable.Repeat(asset, 1), CancellationToken); - Assert.Equal(new HashSet { "name1", "name2" }, asset.TagNames); + Assert.Equal(["name1", "name2"], asset.TagNames); } [Fact] @@ -73,21 +73,21 @@ public class ConvertTagsTests : GivenContext { var asset1 = new AssetEntity { - Tags = new HashSet - { + Tags = + [ "id1", "id2" - }, + ], AppId = AppId }; var asset2 = new AssetEntity { - Tags = new HashSet - { + Tags = + [ "id2", "id3" - }, + ], AppId = AppId }; @@ -101,7 +101,7 @@ public class ConvertTagsTests : GivenContext await sut.EnrichAsync(ApiContext, new[] { asset1, asset2 }, CancellationToken); - Assert.Equal(new HashSet { "name1", "name2" }, asset1.TagNames); - Assert.Equal(new HashSet { "name2", "name3" }, asset2.TagNames); + Assert.Equal(["name1", "name2"], asset1.TagNames); + Assert.Equal(["name2", "name3"], asset2.TagNames); } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichForCachingTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichForCachingTests.cs index 982e75a39..20049ab37 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichForCachingTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichForCachingTests.cs @@ -32,8 +32,8 @@ public class EnrichForCachingTests : GivenContext await sut.EnrichAsync(ApiContext, CancellationToken); - Assert.Equal(new List - { + Assert.Equal( + [ "X-Fields", "X-Flatten", "X-Languages", @@ -43,7 +43,7 @@ public class EnrichForCachingTests : GivenContext "X-ResolveFlow", "X-ResolveUrls", "X-Unpublished" - }, headers); + ], headers); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichWithMetadataTextTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichWithMetadataTextTests.cs index 2bf6c36bc..b38a94a97 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichWithMetadataTextTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/EnrichWithMetadataTextTests.cs @@ -47,11 +47,11 @@ public class EnrichWithMetadataTextTests : GivenContext var asset = new AssetEntity { FileSize = 2 * 1024, - Tags = new HashSet - { + Tags = + [ "id1", "id2" - }, + ], AppId = AppId }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RepairFilesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RepairFilesTests.cs index 9903f2177..c39e74bba 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RepairFilesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RepairFilesTests.cs @@ -104,7 +104,7 @@ public class RepairFilesTests : GivenContext { var storedEvent = new StoredEvent("stream", "0", -1, - new EventData("type", new EnvelopeHeaders(), "payload")); + new EventData("type", [], "payload")); var storedEvents = new List { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/ConfigPlansProviderTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/ConfigPlansProviderTests.cs index ab9d55081..53a2088ac 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/ConfigPlansProviderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/ConfigPlansProviderTests.cs @@ -43,7 +43,7 @@ public class ConfigPlansProviderTests IsFree = false }; - private static readonly Plan[] Plans = { BasicPlan, FreePlan }; + private static readonly Plan[] Plans = [BasicPlan, FreePlan]; [Fact] public void Should_return_plans() diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageGateTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageGateTests.cs index 5862284ed..142350bec 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageGateTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageGateTests.cs @@ -345,15 +345,15 @@ public class UsageGateTests : GivenContext .Returns( new Dictionary> { - [AppId.Id.ToString()] = new List<(DateOnly, Counters)> - { + [AppId.Id.ToString()] = + [ (default, new Counters { [UsageGate.RulesKeys.TotalCreated] = 100, [UsageGate.RulesKeys.TotalSucceeded] = 120, [UsageGate.RulesKeys.TotalFailed] = 140 }) - } + ] }); var total = await ((IRuleUsageTracker)sut).GetTotalByAppAsync(AppId.Id, CancellationToken); @@ -399,8 +399,8 @@ public class UsageGateTests : GivenContext A.CallTo(() => usageTracker.QueryAsync(key, today, today.AddDays(2), CancellationToken)) .Returns(new Dictionary> { - [usageTracker.FallbackCategory] = new List<(DateOnly, Counters)> - { + [usageTracker.FallbackCategory] = + [ (today.AddDays(0), new Counters { [UsageGate.RulesKeys.TotalCreated] = 50, @@ -419,16 +419,16 @@ public class UsageGateTests : GivenContext [UsageGate.RulesKeys.TotalSucceeded] = 320, [UsageGate.RulesKeys.TotalFailed] = 340 }) - }, - ["Custom"] = new List<(DateOnly, Counters)> - { + ], + ["Custom"] = + [ (today.AddDays(0), new Counters { [UsageGate.RulesKeys.TotalCreated] = 50, [UsageGate.RulesKeys.TotalSucceeded] = 60, [UsageGate.RulesKeys.TotalFailed] = 70 }) - } + ] }); } @@ -548,8 +548,8 @@ public class UsageGateTests : GivenContext A.CallTo(() => usageTracker.QueryAsync(key, today, today.AddDays(2), CancellationToken)) .Returns(new Dictionary> { - [usageTracker.FallbackCategory] = new List<(DateOnly, Counters)> - { + [usageTracker.FallbackCategory] = + [ (today.AddDays(0), new Counters { [UsageGate.AssetsKeys.TotalSize] = 64, @@ -565,15 +565,15 @@ public class UsageGateTests : GivenContext [UsageGate.AssetsKeys.TotalSize] = 512, [UsageGate.AssetsKeys.TotalAssets] = 4 }) - }, - ["Custom"] = new List<(DateOnly, Counters)> - { + ], + ["Custom"] = + [ (today.AddDays(0), new Counters { [UsageGate.AssetsKeys.TotalSize] = 64, [UsageGate.AssetsKeys.TotalAssets] = 1 }) - } + ] }); } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageNotifierWorkerTest.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageNotifierWorkerTest.cs index cfba6cdb4..641798df2 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageNotifierWorkerTest.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Billing/UsageNotifierWorkerTest.cs @@ -59,7 +59,7 @@ public class UsageNotifierWorkerTest : GivenContext AppId = AppId.Id, Usage = 1000, UsageLimit = 3000, - Users = new[] { "1", "2" } + Users = ["1", "2"] }; await sut.HandleAsync(message, default); @@ -80,7 +80,7 @@ public class UsageNotifierWorkerTest : GivenContext AppId = AppId.Id, Usage = 1000, UsageLimit = 3000, - Users = new[] { "1", "2", "3" } + Users = ["1", "2", "3"] }; await sut.HandleAsync(message, default); @@ -105,7 +105,7 @@ public class UsageNotifierWorkerTest : GivenContext AppId = AppId.Id, Usage = 1000, UsageLimit = 3000, - Users = new[] { "1" } + Users = ["1"] }; await sut.HandleAsync(message, default); @@ -125,7 +125,7 @@ public class UsageNotifierWorkerTest : GivenContext AppId = AppId.Id, Usage = 1000, UsageLimit = 3000, - Users = new[] { "1" } + Users = ["1"] }; await sut.HandleAsync(message, default); @@ -153,7 +153,7 @@ public class UsageNotifierWorkerTest : GivenContext AppId = AppId.Id, Usage = 1000, UsageLimit = 3000, - Users = new[] { "1" } + Users = ["1"] }; await sut.HandleAsync(message, default); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentCollaborationHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentCollaborationHandlerTests.cs index ca7b7fa2e..8157d9820 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentCollaborationHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentCollaborationHandlerTests.cs @@ -179,7 +179,7 @@ public class CommentCollaborationHandlerTests : GivenContext CommentId = default, CommentsId = commentsId, Text = commentItem.Text, - Mentions = new string[] { "id1", "id2" } + Mentions = ["id1", "id2"] }, opts => opts.Excluding(x => x.CommentId)); } @@ -204,7 +204,7 @@ public class CommentCollaborationHandlerTests : GivenContext CommentId = default, CommentsId = commentsId, Text = commentItem.Text, - Mentions = new string[] { "id1", "id2" } + Mentions = ["id1", "id2"] }, opts => opts.Excluding(x => x.CommentId)); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentTriggerHandlerTests.cs index a03492f63..be672a18b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Collaboration/CommentTriggerHandlerTests.cs @@ -127,7 +127,7 @@ public class CommentTriggerHandlerTests { var ctx = Context().ToRulesContext(); - var @event = new CommentCreated { Mentions = Array.Empty() }; + var @event = new CommentCreated { Mentions = [] }; var envelope = Envelope.Create(@event); var actual = await sut.CreateEnrichedEventsAsync(envelope, ctx, default).ToListAsync(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs index 2b470be1b..a34459792 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs @@ -192,11 +192,11 @@ public class BackupContentsTests : GivenContext await sut.RestoreAsync(context, CancellationToken); - Assert.Equal(new HashSet - { + Assert.Equal( + [ DomainId.Combine(AppId, contentId1), DomainId.Combine(AppId, contentId2) - }, rebuildContents); + ], rebuildContents); } private Envelope ContentEvent(ContentEvent @event) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs index e4420ed96..81a9344cc 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs @@ -30,12 +30,12 @@ public class ContentsSearchSourceTests : GivenContext public ContentsSearchSourceTests() { A.CallTo(() => AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List - { + .Returns( + [ Mocks.Schema(AppId, schemaId1), Mocks.Schema(AppId, schemaId2), Mocks.Schema(AppId, schemaId3) - }); + ]); sut = new ContentsSearchSource(AppProvider, contentQuery, contentIndex, urlGenerator); } @@ -160,7 +160,7 @@ public class ContentsSearchSourceTests : GivenContext var requestContext = ContextWithPermissions(schemaId1, schemaId2); A.CallTo(() => contentIndex.SearchAsync(App, A.That.Matches(x => x.Text == "query~"), ApiContext.Scope(), CancellationToken)) - .Returns(new List()); + .Returns([]); var actual = await sut.SearchAsync("query", requestContext, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Counter/CounterJintExtensionTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Counter/CounterJintExtensionTests.cs index d188c771c..6af434cc2 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Counter/CounterJintExtensionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Counter/CounterJintExtensionTests.cs @@ -39,7 +39,7 @@ public class CounterJintExtensionTests : GivenContext .Returns(3); const string script = @" - return resetCounter('my', 4); + resetCounter('my', 4); "; var vars = new ScriptVars @@ -69,7 +69,7 @@ public class CounterJintExtensionTests : GivenContext ["appId"] = AppId.Id }; - var actual = (await sut.ExecuteAsync(vars, script)).ToString(); + var actual = (await sut.ExecuteAsync(vars, script, ct: CancellationToken)).ToString(); Assert.Equal("3", actual); } @@ -81,7 +81,7 @@ public class CounterJintExtensionTests : GivenContext .Returns(3); const string script = @" - return incrementCounter('my'); + incrementCounter('my'); "; var vars = new ScriptVars @@ -111,7 +111,7 @@ public class CounterJintExtensionTests : GivenContext ["appId"] = AppId.Id }; - var actual = (await sut.ExecuteAsync(vars, script)).ToString(); + var actual = (await sut.ExecuteAsync(vars, script, ct: CancellationToken)).ToString(); Assert.Equal("3", actual); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs index 306b9f5b1..43c1de2bb 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs @@ -45,7 +45,7 @@ public class ContentsBulkUpdateCommandMiddlewareTests : GivenContext [Fact] public async Task Should_do_nothing_if_jobs_is_empty() { - var command = new BulkUpdateContents { Jobs = Array.Empty() }; + var command = new BulkUpdateContents { Jobs = [] }; var actual = await PublishAsync(command); @@ -546,10 +546,10 @@ public class ContentsBulkUpdateCommandMiddlewareTests : GivenContext return new BulkUpdateContents { AppId = AppId, - Jobs = new[] - { + Jobs = + [ job - }, + ], SchemaId = schemaId }; } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs index e0e11f285..52f936410 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs @@ -207,7 +207,7 @@ public class GuardContentTests : GivenContext, IClassFixture contentQuery.QueryAsync(MatchsContentContext(), A.That.HasIdsWithoutTotal(contentId), diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs index ede912c85..1eb7d19fd 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs @@ -54,19 +54,19 @@ public abstract class ContentsQueryFixture : IAsyncLifetime public MongoContentRepository ContentRepository { get; } public NamedId[] AppIds { get; } = - { + [ NamedId.Of(DomainId.Create("3b5ba909-e5a5-4858-9d0d-df4ff922d452"), "my-app1"), NamedId.Of(DomainId.Create("4b3672c1-97c6-4e0b-a067-71e9e9a29db9"), "my-app1") - }; + ]; public NamedId[] SchemaIds { get; } = - { + [ NamedId.Of(DomainId.Create("3b5ba909-e5a5-4858-9d0d-df4ff922d452"), "my-schema1"), NamedId.Of(DomainId.Create("4b3672c1-97c6-4e0b-a067-71e9e9a29db9"), "my-schema2"), NamedId.Of(DomainId.Create("76357c9b-0514-4377-9fcc-a632e7ef960d"), "my-schema3"), NamedId.Of(DomainId.Create("164c451e-e5a8-41f8-8aaf-e4b56603d7e7"), "my-schema4"), NamedId.Of(DomainId.Create("741e902c-fdfa-41ad-8e5a-b7cb9d6e3d94"), "my-schema5") - }; + ]; protected ContentsQueryFixture(bool selfHosting) { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTestsBase.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTestsBase.cs index 33dcd7de0..550d45026 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTestsBase.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTestsBase.cs @@ -126,10 +126,10 @@ public abstract class ContentsQueryTestsBase { var query = new ClrQuery { - Sort = new List - { + Sort = + [ new SortNode("data.value.iv", SortOrder.Ascending) - } + ] }; var contents = await QueryAsync(_.ContentRepository, query, 1000, 9000); @@ -202,7 +202,7 @@ public abstract class ContentsQueryTestsBase { clrQuery.Take = top; clrQuery.Skip = skip; - clrQuery.Sort ??= new List(); + clrQuery.Sort ??= []; if (clrQuery.Sort.Count == 0) { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs index 7f1752e9b..48f054e97 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs @@ -99,7 +99,7 @@ public class ContentEnricherTests : GivenContext [Fact] public async Task Should_clone_data_if_requested() { - var source = CreateContent(new ContentData()); + var source = CreateContent([]); var sut = new ContentEnricher(Enumerable.Empty(), AppProvider); @@ -111,7 +111,7 @@ public class ContentEnricherTests : GivenContext [Fact] public async Task Should_not_clone_data_if_not_requested() { - var source = CreateContent(new ContentData()); + var source = CreateContent([]); var sut = new ContentEnricher(Enumerable.Empty(), AppProvider); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs index 2cd11559f..5b24c9e85 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs @@ -119,7 +119,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_full_text_query_to_filter_with_other_filter() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, A.That.Matches(x => x.Text == "Hello"), ApiContext.Scope(), CancellationToken)) - .Returns(new List { DomainId.Create("1"), DomainId.Create("2") }); + .Returns([DomainId.Create("1"), DomainId.Create("2")]); var query = Q.Empty.WithODataQuery("$search=Hello&$filter=data/firstName/iv eq 'ABC'"); @@ -132,7 +132,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_full_text_query_to_filter() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, A.That.Matches(x => x.Text == "Hello"), ApiContext.Scope(), CancellationToken)) - .Returns(new List { DomainId.Create("1"), DomainId.Create("2") }); + .Returns([DomainId.Create("1"), DomainId.Create("2")]); var query = Q.Empty.WithODataQuery("$search=Hello"); @@ -145,7 +145,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_full_text_query_to_filter_if_single_id_found() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, A.That.Matches(x => x.Text == "Hello"), ApiContext.Scope(), CancellationToken)) - .Returns(new List { DomainId.Create("1") }); + .Returns([DomainId.Create("1")]); var query = Q.Empty.WithODataQuery("$search=Hello"); @@ -171,7 +171,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_full_text_query_to_filter_if_index_returns_empty() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, A.That.Matches(x => x.Text == "Hello"), ApiContext.Scope(), CancellationToken)) - .Returns(new List()); + .Returns([]); var query = Q.Empty.WithODataQuery("$search=Hello"); @@ -184,7 +184,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_geo_query_to_filter() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, new GeoQuery(SchemaId.Id, "geo.iv", 10, 20, 30, 1000), ApiContext.Scope(), CancellationToken)) - .Returns(new List { DomainId.Create("1"), DomainId.Create("2") }); + .Returns([DomainId.Create("1"), DomainId.Create("2")]); var query = Q.Empty.WithODataQuery("$filter=geo.distance(data/geo/iv, geography'POINT(20 10)') lt 30.0"); @@ -197,7 +197,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_geo_query_to_filter_if_single_id_found() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, new GeoQuery(SchemaId.Id, "geo.iv", 10, 20, 30, 1000), ApiContext.Scope(), CancellationToken)) - .Returns(new List { DomainId.Create("1") }); + .Returns([DomainId.Create("1")]); var query = Q.Empty.WithODataQuery("$filter=geo.distance(data/geo/iv, geography'POINT(20 10)') lt 30.0"); @@ -223,7 +223,7 @@ public class ContentQueryParserTests : GivenContext public async Task Should_convert_geo_query_to_filter_if_index_returns_empty() { A.CallTo(() => textIndex.SearchAsync(ApiContext.App, new GeoQuery(SchemaId.Id, "geo.iv", 10, 20, 30, 1000), ApiContext.Scope(), CancellationToken)) - .Returns(new List()); + .Returns([]); var query = Q.Empty.WithODataQuery("$filter=geo.distance(data/geo/iv, geography'POINT(20 10)') lt 30.0"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryServiceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryServiceTests.cs index aba1c70e1..50093369d 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryServiceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryServiceTests.cs @@ -23,7 +23,7 @@ public class ContentQueryServiceTests : GivenContext private readonly IContentEnricher contentEnricher = A.Fake(); private readonly IContentRepository contentRepository = A.Fake(); private readonly IContentLoader contentVersionLoader = A.Fake(); - private readonly ContentData contentData = new ContentData(); + private readonly ContentData contentData = []; private readonly ContentQueryParser queryParser = A.Fake(); private readonly ContentQueryService sut; @@ -40,7 +40,7 @@ public class ContentQueryServiceTests : GivenContext SetupEnricher(); A.CallTo(() => AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { Schema }); + .Returns([Schema]); A.CallTo(() => queryParser.ParseAsync(A._, A._, A._, CancellationToken)) .ReturnsLazily(c => Task.FromResult(c.GetArgument(1)!)); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs index 124acbd45..ec93a01e8 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs @@ -48,7 +48,7 @@ public class ConvertDataTests : GivenContext [Fact] public async Task Should_convert_data_and_data_draft_if_frontend_user() { - var content = CreateContent(new ContentData()); + var content = CreateContent([]); await sut.EnrichAsync(FrontendContext, new[] { content }, SchemaProvider(), CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichForCachingTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichForCachingTests.cs index 3a7a6b345..819151915 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichForCachingTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichForCachingTests.cs @@ -33,8 +33,8 @@ public class EnrichForCachingTests : GivenContext await sut.EnrichAsync(ApiContext, CancellationToken); - Assert.Equal(new List - { + Assert.Equal( + [ "X-Fields", "X-Flatten", "X-Languages", @@ -44,7 +44,7 @@ public class EnrichForCachingTests : GivenContext "X-ResolveFlow", "X-ResolveUrls", "X-Unpublished" - }, headers); + ], headers); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveAssetsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveAssetsTests.cs index 0139fdc65..e28e7c311 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveAssetsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveAssetsTests.cs @@ -74,11 +74,11 @@ public class ResolveAssetsTests : GivenContext var contents = new[] { CreateContent( - new[] { doc1.Id }, - new[] { doc1.Id }), + [doc1.Id], + [doc1.Id]), CreateContent( - new[] { doc2.Id }, - new[] { doc2.Id }) + [doc2.Id], + [doc2.Id]) }; A.CallTo(() => assetQuery.QueryAsync( @@ -106,11 +106,11 @@ public class ResolveAssetsTests : GivenContext var contents = new[] { CreateContent( - new[] { img1.Id }, - new[] { img2.Id, img1.Id }), + [img1.Id], + [img2.Id, img1.Id]), CreateContent( - new[] { doc1.Id }, - new[] { doc2.Id, doc1.Id }) + [doc1.Id], + [doc2.Id, doc1.Id]) }; A.CallTo(() => assetQuery.QueryAsync( @@ -145,7 +145,7 @@ public class ResolveAssetsTests : GivenContext { var contents = new[] { - CreateContent(new[] { DomainId.NewGuid() }, Array.Empty()) + CreateContent([DomainId.NewGuid()], []) }; await sut.EnrichAsync(ApiContext, contents, schemaProvider, CancellationToken); @@ -161,7 +161,7 @@ public class ResolveAssetsTests : GivenContext { var contents = new[] { - CreateContent(new[] { DomainId.NewGuid() }, Array.Empty()) + CreateContent([DomainId.NewGuid()], []) }; await sut.EnrichAsync(FrontendContext.Clone(b => b.WithNoEnrichment(true)), contents, schemaProvider, CancellationToken); @@ -177,7 +177,7 @@ public class ResolveAssetsTests : GivenContext { var contents = new[] { - CreateContent(Array.Empty(), Array.Empty()) + CreateContent([], []) }; await sut.EnrichAsync(FrontendContext, contents, schemaProvider, CancellationToken); @@ -196,7 +196,7 @@ public class ResolveAssetsTests : GivenContext var contents = new[] { - CreateContent(new[] { id1, id2 }, Array.Empty()) + CreateContent([id1, id2], []) }; await sut.EnrichAsync(FrontendContext, contents, schemaProvider, CancellationToken); @@ -224,7 +224,7 @@ public class ResolveAssetsTests : GivenContext }; } - private IEnrichedAssetEntity CreateAsset(DomainId id, int version, AssetType type, string fileName, string? fileType = null, int fileSize = 100) + private AssetEntity CreateAsset(DomainId id, int version, AssetType type, string fileName, string? fileType = null, int fileSize = 100) { return new AssetEntity { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs index 454668957..75ababc54 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs @@ -90,8 +90,8 @@ public class ResolveReferencesTests : GivenContext, IClassFixture contentQuery.QueryAsync( @@ -129,8 +129,8 @@ public class ResolveReferencesTests : GivenContext, IClassFixture contentQuery.QueryAsync( @@ -182,8 +182,8 @@ public class ResolveReferencesTests : GivenContext, IClassFixture contentQuery.QueryAsync( @@ -230,7 +230,7 @@ public class ResolveReferencesTests : GivenContext, IClassFixture()) + CreateContent([DomainId.NewGuid()], []) }; await sut.EnrichAsync(ApiContext, contents, schemaProvider, CancellationToken); @@ -246,7 +246,7 @@ public class ResolveReferencesTests : GivenContext, IClassFixture()) + CreateContent([DomainId.NewGuid()], []) }; await sut.EnrichAsync(FrontendContext.Clone(b => b.WithNoEnrichment(true)), contents, schemaProvider, CancellationToken); @@ -262,7 +262,7 @@ public class ResolveReferencesTests : GivenContext, IClassFixture(), Array.Empty()) + CreateContent([], []) }; await sut.EnrichAsync(FrontendContext, contents, schemaProvider, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs index 4eac37853..ba8fbc3cc 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs @@ -165,7 +165,7 @@ public class ScriptContentTests : GivenContext private ContentEntity CreateContent() { - return new ContentEntity { Data = new ContentData(), SchemaId = SchemaId }; + return new ContentEntity { Data = [], SchemaId = SchemaId }; } private ProvideSchema SchemaProvider() diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/AtlasTextIndexFixture.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/AtlasTextIndexFixture.cs index 9d912e488..68806e575 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/AtlasTextIndexFixture.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/AtlasTextIndexFixture.cs @@ -38,9 +38,9 @@ public sealed class AtlasTextIndexFixture : IAsyncLifetime { options.BaseAddress = new Uri("https://cloud.mongodb.com/"); }) - .ConfigureHttpMessageHandlerBuilder(builder => + .ConfigurePrimaryHttpMessageHandler(() => { - builder.PrimaryHandler = new HttpClientHandler + return new HttpClientHandler { Credentials = new NetworkCredential(options.PublicKey, options.PrivateKey, "cloud.mongodb.com") }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs index ffa2a418e..4ec240f59 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs @@ -54,7 +54,7 @@ public class CachingTextIndexerStateTests : GivenContext var contentIds = HashSet.Of(contentId); A.CallTo(() => inner.GetAsync(A>.That.Is(contentIds), CancellationToken)) - .Returns(new Dictionary()); + .Returns([]); var found1 = await sut.GetAsync(HashSet.Of(contentId), CancellationToken); var found2 = await sut.GetAsync(HashSet.Of(contentId), CancellationToken); @@ -73,7 +73,7 @@ public class CachingTextIndexerStateTests : GivenContext var state = new TextContentState { UniqueContentId = contentId }; - await sut.SetAsync(new List { state }, CancellationToken); + await sut.SetAsync([state], CancellationToken); var found1 = await sut.GetAsync(contentIds, CancellationToken); var found2 = await sut.GetAsync(contentIds, CancellationToken); @@ -95,15 +95,15 @@ public class CachingTextIndexerStateTests : GivenContext var state = new TextContentState { UniqueContentId = contentId }; - await sut.SetAsync(new List - { + await sut.SetAsync( + [ state - }, CancellationToken); + ], CancellationToken); - await sut.SetAsync(new List - { + await sut.SetAsync( + [ new TextContentState { UniqueContentId = contentId, IsDeleted = true } - }, CancellationToken); + ], CancellationToken); var found1 = await sut.GetAsync(contentIds, CancellationToken); var found2 = await sut.GetAsync(contentIds, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTestsBase.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTestsBase.cs index 82f0324c5..1d70dd0b0 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTestsBase.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTestsBase.cs @@ -20,8 +20,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text; public abstract class TextIndexerTestsBase : GivenContext { - protected readonly List ids1 = new List { DomainId.NewGuid() }; - protected readonly List ids2 = new List { DomainId.NewGuid() }; + protected readonly List ids1 = [DomainId.NewGuid()]; + protected readonly List ids2 = [DomainId.NewGuid()]; private readonly Lazy sut; protected TextIndexingProcess Sut diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.Designer.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.Designer.cs index ba0facdd3..0fcda2945 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.Designer.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.Designer.cs @@ -8,87 +8,83 @@ // //------------------------------------------------------------------------------ -namespace Squidex.Domain.Apps.Entities.Properties; -using System; - - -/// -/// A strongly-typed resource class, for looking up localized strings, etc. -/// -// This class was auto-generated by the StronglyTypedResourceBuilder -// class via a tool like ResGen or Visual Studio. -// To add or remove a member, edit your .ResX file then rerun ResGen -// with the /str option, or rebuild your VS project. -[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] -[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] -[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] -internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; +namespace Squidex.Domain.Apps.Entities.Properties { + using System; - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } /// - /// Returns the cached ResourceManager instance used by this class. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Squidex.Domain.Apps.Entities.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Squidex.Domain.Apps.Entities.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } } - set { - resourceCulture = value; + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } } - } - - /// - /// Looks up a localized string similar to <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" onload="alert(localStorage.getItem('oidc.user:https://cloud.squidex.io/identity-server/:squidex-frontend'))"> - /// <path d="M30,1h40l29,29v40l-29,29h-40l-29-29v-40z" stroke="#000" fill="none"/> - /// <path d="M31,3h38l28,28v38l-28,28h-38l-28-28v-38z" fill="#a23"/> - /// <text x="50" y="68" font-size="48" fill="#FFF" text-anchor="middle"><![CDATA[410]]></text> - ///</svg>. - /// - internal static string SvgInvalid { - get { - return ResourceManager.GetString("SvgInvalid", resourceCulture); + + /// + /// Looks up a localized string similar to <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" onload="alert(localStorage.getItem('oidc.user:https://cloud.squidex.io/identity-server/:squidex-frontend'))"> + /// <path d="M30,1h40l29,29v40l-29,29h-40l-29-29v-40z" stroke="#000" fill="none"/> + /// <path d="M31,3h38l28,28v38l-28,28h-38l-28-28v-38z" fill="#a23"/> + /// <text x="50" y="68" font-size="48" fill="#FFF" text-anchor="middle"><![CDATA[410]]></text> + ///</svg>. + /// + internal static string SvgInvalid { + get { + return ResourceManager.GetString("SvgInvalid", resourceCulture); + } } - } - - /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-8" standalone="no"?> - ///<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> - /// - ///<svg - /// xmlns:dc="http://purl.org/dc/elements/1.1/" - /// xmlns:cc="http://creativecommons.org/ns#" - /// xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - /// xmlns:svg="http://www.w3.org/2000/svg" - /// xmlns="http://www.w3.org/2000/svg" - /// xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - /// xmlns:inkscape="http://www.inkscape.org/n [rest of string was truncated]";. - /// - internal static string SvgValid { - get { - return ResourceManager.GetString("SvgValid", resourceCulture); + + /// + /// Looks up a localized string similar to <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> + /// <path d="M30,1h40l29,29v40l-29,29h-40l-29-29v-40z" stroke="#000" fill="none"/> + /// <path d="M31,3h38l28,28v38l-28,28h-38l-28-28v-38z" fill="#a23"/> + /// <text x="50" y="68" font-size="48" fill="#FFF" text-anchor="middle"><![CDATA[410]]></text> + /// <use id="#other"/> + ///</svg>. + /// + internal static string SvgValid { + get { + return ResourceManager.GetString("SvgValid", resourceCulture); + } } } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.resx b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.resx index 2a348720d..ca1e8db98 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.resx +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Properties/Resources.resx @@ -125,80 +125,11 @@ </svg> - <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - width="110" - height="110" - viewBox="0 0 110 110" - enable-background="new 0 0 494 111" - xml:space="preserve" - inkscape:version="0.91 r13725" - sodipodi:docname="logo-squared.svg" - inkscape:export-filename="C:\Users\mail2\Downloads\logo-squared.png" - inkscape:export-xdpi="490.91" - inkscape:export-ydpi="490.91"><metadata - id="metadata45"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs - id="defs43" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1017" - id="namedview41" - showgrid="false" - inkscape:zoom="2.3319838" - inkscape:cx="-70.482725" - inkscape:cy="106.27906" - inkscape:window-x="1912" - inkscape:window-y="-8" - inkscape:window-maximized="1" - inkscape:current-layer="Layer_1" /><g - id="g19" - transform="matrix(1.0069983,0,0,1.0058932,11.091568,0.44387448)"><g - id="g21"><path - d="m 21.267,80.827 c -0.473,0 -0.971,-0.031 -1.494,-0.096 -3.67,-0.459 -6.484,-2.862 -7.531,-6.428 -1.109,-3.789 0.053,-8.048 2.826,-10.359 1.144,-0.955 2.844,-0.799 3.797,0.345 0.953,1.145 0.798,2.844 -0.346,3.797 -1.138,0.948 -1.611,2.968 -1.104,4.7 0.309,1.051 1.083,2.353 3.025,2.596 1.399,0.175 2.459,-0.063 3.246,-0.724 1.435,-1.209 1.869,-3.684 1.922,-4.596 l 0,-16.985 c 0,-1.489 1.207,-2.695 2.695,-2.695 1.488,0 2.697,1.206 2.697,2.695 l 0,17.051 c 0,0.033 0,0.065 -0.001,0.098 -0.02,0.558 -0.297,5.538 -3.803,8.525 -1.165,0.991 -3.089,2.076 -5.929,2.076 z" - id="path23" - inkscape:connector-curvature="0" - style="fill:#3389ff" /></g><g - id="g25"><path - d="m 31.435,99.967 c -0.473,0 -0.971,-0.031 -1.494,-0.096 -3.67,-0.46 -6.486,-2.862 -7.531,-6.428 -1.109,-3.789 0.051,-8.048 2.826,-10.358 1.144,-0.955 2.845,-0.8 3.797,0.342 0.953,1.146 0.798,2.845 -0.346,3.799 -1.138,0.947 -1.612,2.968 -1.104,4.701 0.308,1.049 1.082,2.351 3.025,2.594 1.404,0.177 2.473,-0.065 3.259,-0.735 1.638,-1.394 1.887,-4.275 1.909,-4.586 l 0,-36.962 c 0,-1.489 1.207,-2.696 2.695,-2.696 1.488,0 2.695,1.207 2.695,2.696 l 0,37.031 c 0,0.032 0,0.062 -0.002,0.097 -0.019,0.558 -0.296,5.538 -3.803,8.525 -1.162,0.991 -3.086,2.076 -5.926,2.076 z" - id="path27" - inkscape:connector-curvature="0" - style="fill:#3389ff" /></g><g - id="g29"><path - d="m 65.941,80.827 c -2.84,0 -4.764,-1.085 -5.928,-2.076 -3.507,-2.987 -3.784,-7.968 -3.803,-8.525 -0.002,-0.032 -0.002,-0.064 -0.002,-0.098 l 0,-17.051 c 0,-1.489 1.206,-2.695 2.695,-2.695 1.488,0 2.695,1.207 2.695,2.695 l 0,16.991 c 0.05,0.889 0.482,3.377 1.923,4.591 0.786,0.66 1.849,0.899 3.245,0.723 1.942,-0.242 2.718,-1.544 3.025,-2.595 0.509,-1.732 0.034,-3.752 -1.104,-4.7 -1.144,-0.953 -1.299,-2.652 -0.345,-3.797 0.951,-1.144 2.65,-1.299 3.796,-0.345 2.774,2.312 3.936,6.57 2.826,10.359 -1.045,3.565 -3.861,5.969 -7.53,6.428 -0.522,0.064 -1.02,0.095 -1.493,0.095 z" - id="path31" - inkscape:connector-curvature="0" - style="fill:#3389ff" /></g><g - id="g33"><path - d="m 55.773,99.967 c -2.84,0 -4.764,-1.085 -5.928,-2.076 C 46.338,94.904 46.062,89.923 46.042,89.366 46.04,89.332 46.04,89.302 46.04,89.269 l 0,-37.031 c 0,-1.489 1.207,-2.696 2.696,-2.696 1.488,0 2.694,1.207 2.694,2.696 l 0,36.967 c 0.051,0.891 0.482,3.379 1.923,4.592 0.786,0.661 1.847,0.9 3.245,0.724 1.942,-0.243 2.718,-1.545 3.025,-2.594 0.509,-1.733 0.034,-3.754 -1.104,-4.701 -1.144,-0.954 -1.298,-2.652 -0.345,-3.799 0.952,-1.141 2.651,-1.297 3.797,-0.342 2.774,2.311 3.935,6.569 2.825,10.358 -1.045,3.565 -3.861,5.968 -7.53,6.428 -0.522,0.065 -1.019,0.096 -1.493,0.096 z" - id="path35" - inkscape:connector-curvature="0" - style="fill:#3389ff" /></g><g - id="g37"><path - d="M 64.793,38.868 C 64.615,36.921 68.58,37.699 68.104,35.928 63.147,17.484 43.646,8.512 43.632,8.506 43.617,8.512 24.116,17.484 19.16,35.928 c -0.478,1.771 3.487,0.993 3.31,2.94 -0.217,2.364 -4.765,3.333 -4.172,10.121 0.641,7.341 7.182,14.765 7.418,18.873 l 5.295,0 0,-0.153 c 0,-1.319 1.069,-2.388 2.389,-2.388 1.32,0 2.388,1.068 2.388,2.388 l 0,0.153 5.39,-2.695 0,-0.107 c 0,-1.345 1.09,-2.435 2.436,-2.435 1.344,0 2.434,1.09 2.434,2.435 l 0,0.107 5.375,2.695 0,-0.153 c 0,-1.319 1.069,-2.388 2.389,-2.388 1.32,0 2.389,1.068 2.389,2.388 l 0,0.153 5.391,0 c 0.542,-5.791 6.735,-11.532 7.376,-18.873 0.59,-6.788 -3.959,-7.757 -4.175,-10.121 z" - id="path39" - inkscape:connector-curvature="0" - style="fill:#3389ff" /></g></g></svg> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> + <path d="M30,1h40l29,29v40l-29,29h-40l-29-29v-40z" stroke="#000" fill="none"/> + <path d="M31,3h38l28,28v38l-28,28h-38l-28-28v-38z" fill="#a23"/> + <text x="50" y="68" font-size="48" fill="#FFF" text-anchor="middle"><![CDATA[410]]></text> + <use id="#other"/> +</svg> \ No newline at end of file diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/BackupRulesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/BackupRulesTests.cs index 7fbc0c78e..c4f51c750 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/BackupRulesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/BackupRulesTests.cs @@ -67,11 +67,11 @@ public class BackupRulesTests : GivenContext await sut.RestoreAsync(context, CancellationToken); - Assert.Equal(new HashSet - { + Assert.Equal( + [ DomainId.Combine(AppId, ruleId1), DomainId.Combine(AppId, ruleId2) - }, rebuildAssets); + ], rebuildAssets); } private Envelope AppEvent(RuleEvent @event) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/GuardRuleTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/GuardRuleTests.cs index 4f634e9b8..884e93f78 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/GuardRuleTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/GuardRuleTests.cs @@ -49,7 +49,7 @@ public class GuardRuleTests : GivenContext, IClassFixture { Trigger = new ContentChangedTriggerV2 { - Schemas = ReadonlyList.Empty() + Schemas = [] }, Action = null! }); @@ -65,7 +65,7 @@ public class GuardRuleTests : GivenContext, IClassFixture { Trigger = new ContentChangedTriggerV2 { - Schemas = ReadonlyList.Empty() + Schemas = [] }, Action = new TestAction { @@ -99,7 +99,7 @@ public class GuardRuleTests : GivenContext, IClassFixture { Trigger = new ContentChangedTriggerV2 { - Schemas = ReadonlyList.Empty() + Schemas = [] }, Action = new TestAction { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/Triggers/ContentChangedTriggerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/Triggers/ContentChangedTriggerTests.cs index df86101d6..6f7e96015 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/Triggers/ContentChangedTriggerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/Guards/Triggers/ContentChangedTriggerTests.cs @@ -72,7 +72,7 @@ public class ContentChangedTriggerTests : GivenContext, IClassFixture() + Schemas = [] }; var errors = await RuleTriggerValidator.ValidateAsync(AppId.Id, trigger, AppProvider); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs index 4b692d45d..893c5b3fb 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs @@ -26,7 +26,7 @@ public class RulesIndexTests : GivenContext var rule = SetupRule(0); A.CallTo(() => ruleRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { rule }); + .Returns([rule]); var actual = await sut.GetRulesAsync(AppId.Id, CancellationToken); @@ -39,7 +39,7 @@ public class RulesIndexTests : GivenContext var rule = SetupRule(-1); A.CallTo(() => ruleRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { rule }); + .Returns([rule]); var actual = await sut.GetRulesAsync(AppId.Id, CancellationToken); @@ -52,7 +52,7 @@ public class RulesIndexTests : GivenContext var rule = SetupRule(0, true); A.CallTo(() => ruleRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { rule }); + .Returns([rule]); var actual = await sut.GetRulesAsync(AppId.Id, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs index fa738f598..1048b5364 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs @@ -289,7 +289,7 @@ public class RuleEnqueuerTests : GivenContext var rule = CreateRule(); A.CallTo(() => AppProvider.GetRulesAsync(AppId.Id, A._)) - .Returns(new List { rule }); + .Returns([rule]); A.CallTo(() => ruleService.CreateJobsAsync(@event, MatchingContext(rule), default)) .Returns(Enumerable.Repeat(new JobResult diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/BackupSchemasTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/BackupSchemasTests.cs index bb7e3a2d2..32ec63b1b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/BackupSchemasTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/BackupSchemasTests.cs @@ -68,11 +68,11 @@ public class BackupSchemasTests : GivenContext await sut.RestoreAsync(context, CancellationToken); - Assert.Equal(new HashSet - { + Assert.Equal( + [ DomainId.Combine(AppId, schemaId1.Id), DomainId.Combine(AppId, schemaId2.Id) - }, rebuildContents); + ], rebuildContents); } private Envelope AppEvent(SchemaEvent @event) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaTests.cs index 4a21e5823..42bca4bad 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaTests.cs @@ -45,15 +45,15 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "invalid name", Properties = new StringFieldProperties(), Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], Name = "new-schema" }); @@ -67,15 +67,15 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", Properties = null!, Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], Name = "new-schema" }); @@ -89,15 +89,15 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties { MinLength = 10, MaxLength = 5 }, Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], Name = "new-schema" }); @@ -112,15 +112,15 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties(), Partitioning = "INVALID" - } - }, + }, + ], Name = "new-schema" }); @@ -134,8 +134,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", @@ -147,8 +147,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture Name = "field1", Properties = new StringFieldProperties(), Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], Name = "new-schema" }); @@ -162,23 +162,23 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "invalid name", Properties = new StringFieldProperties() - } - } - } - }, + }, + ] + }, + ], Name = "new-schema" }); @@ -192,23 +192,23 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", Properties = null! - } - } - } - }, + }, + ] + }, + ], Name = "new-schema" }); @@ -222,23 +222,23 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", Properties = new ArrayFieldProperties() - } - } - } - }, + }, + ] + }, + ], Name = "new-schema" }); @@ -252,23 +252,23 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", Properties = new StringFieldProperties { MinLength = 10, MaxLength = 5 } - } - } - } - }, + }, + ] + }, + ], Name = "new-schema" }); @@ -283,15 +283,15 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", @@ -301,10 +301,10 @@ public class GuardSchemaTests : GivenContext, IClassFixture { Name = "nested1", Properties = new StringFieldProperties() - } - } - } - }, + }, + ] + }, + ], Name = "new-schema" }); @@ -318,8 +318,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", @@ -327,8 +327,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture IsHidden = true, IsDisabled = true, Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], FieldsInLists = FieldNames.Create("field1"), FieldsInReferences = FieldNames.Create("field1"), Name = "new-schema" @@ -350,8 +350,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", @@ -363,8 +363,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture Name = "field4", Properties = new UIFieldProperties(), Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], FieldsInLists = FieldNames.Create(null!, null!, "field3", "field1", "field1", "field4"), FieldsInReferences = null, Name = "new-schema" @@ -388,8 +388,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", @@ -401,8 +401,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture Name = "field4", Properties = new UIFieldProperties(), Partitioning = Partitioning.Invariant.Key - } - }, + }, + ], FieldsInLists = null, FieldsInReferences = FieldNames.Create(null!, null!, "field3", "field1", "field1", "field4"), Name = "new-schema" @@ -441,8 +441,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = CreateCommand(new CreateSchema { - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "field1", @@ -462,8 +462,8 @@ public class GuardSchemaTests : GivenContext, IClassFixture Name = "field3", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", @@ -473,10 +473,10 @@ public class GuardSchemaTests : GivenContext, IClassFixture { Name = "nested2", Properties = ValidProperties() - } - } - } - }, + }, + ] + }, + ], FieldsInLists = FieldNames.Create("field1", "meta.id"), FieldsInReferences = FieldNames.Create("field1"), Name = "new-schema" @@ -560,11 +560,11 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = new ConfigureFieldRules { - FieldRules = new[] - { + FieldRules = + [ new FieldRuleCommand { Field = "field", Action = (FieldRuleAction)5 }, new FieldRuleCommand() - } + ] }; ValidationAssert.Throws(() => GuardSchema.CanConfigureFieldRules(command), @@ -579,11 +579,11 @@ public class GuardSchemaTests : GivenContext, IClassFixture { var command = new ConfigureFieldRules { - FieldRules = new[] - { + FieldRules = + [ new FieldRuleCommand { Field = "field1", Action = FieldRuleAction.Disable, Condition = "a == b" }, new FieldRuleCommand { Field = "field2" } - } + ] }; GuardSchema.CanConfigureFieldRules(command); @@ -603,7 +603,7 @@ public class GuardSchemaTests : GivenContext, IClassFixture [Fact] public void CanReorder_should_throw_exception_if_field_ids_contains_invalid_id() { - var command = new ReorderFields { FieldIds = new[] { 1L, 3L } }; + var command = new ReorderFields { FieldIds = [1L, 3L] }; ValidationAssert.Throws(() => GuardSchema.CanReorder(command, schema_0), new ValidationError("Field ids do not cover all fields.", "FieldIds")); @@ -612,7 +612,7 @@ public class GuardSchemaTests : GivenContext, IClassFixture [Fact] public void CanReorder_should_throw_exception_if_field_ids_do_not_covers_all_fields() { - var command = new ReorderFields { FieldIds = new[] { 1L } }; + var command = new ReorderFields { FieldIds = [1L] }; ValidationAssert.Throws(() => GuardSchema.CanReorder(command, schema_0), new ValidationError("Field ids do not cover all fields.", "FieldIds")); @@ -630,7 +630,7 @@ public class GuardSchemaTests : GivenContext, IClassFixture [Fact] public void CanReorder_should_throw_exception_if_parent_field_not_found() { - var command = new ReorderFields { FieldIds = new[] { 1L, 2L }, ParentFieldId = 99 }; + var command = new ReorderFields { FieldIds = [1L, 2L], ParentFieldId = 99 }; Assert.Throws(() => GuardSchema.CanReorder(command, schema_0)); } @@ -638,7 +638,7 @@ public class GuardSchemaTests : GivenContext, IClassFixture [Fact] public void CanReorder_should_not_throw_exception_if_field_ids_are_valid() { - var command = new ReorderFields { FieldIds = new[] { 1L, 2L, 4L } }; + var command = new ReorderFields { FieldIds = [1L, 2L, 4L] }; GuardSchema.CanReorder(command, schema_0); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs index a27022042..c8fba1ad7 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs @@ -85,11 +85,11 @@ public class SchemaDomainObjectTests : HandlerTestBase Name = "field3", Partitioning = Partitioning.Language.Key, Properties = new ArrayFieldProperties(), - Nested = new[] - { + Nested = + [ new UpsertSchemaNestedField { Name = "nested1", Properties = ValidProperties() }, new UpsertSchemaNestedField { Name = "nested2", Properties = ValidProperties() } - } + ] } }; @@ -157,10 +157,10 @@ public class SchemaDomainObjectTests : HandlerTestBase { var command = new ConfigureFieldRules { - FieldRules = new[] - { + FieldRules = + [ new FieldRuleCommand { Field = "field1" } - } + ] }; await ExecuteCreateAsync(); @@ -328,7 +328,7 @@ public class SchemaDomainObjectTests : HandlerTestBase [Fact] public async Task Reorder_should_create_events_and_reorder_fields() { - var command = new ReorderFields { FieldIds = new[] { 2L, 1L } }; + var command = new ReorderFields { FieldIds = [2L, 1L] }; await ExecuteCreateAsync(); await ExecuteAddFieldAsync("field1"); @@ -347,7 +347,7 @@ public class SchemaDomainObjectTests : HandlerTestBase [Fact] public async Task Reorder_should_create_events_and_reorder_nestedy_fields() { - var command = new ReorderFields { ParentFieldId = 1, FieldIds = new[] { 3L, 2L } }; + var command = new ReorderFields { ParentFieldId = 1, FieldIds = [3L, 2L] }; await ExecuteCreateAsync(); await ExecuteAddArrayFieldAsync(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs index 48cf58a63..c38836fce 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs @@ -110,7 +110,7 @@ public class SchemasIndexTests : GivenContext public async Task Should_resolve_schemas() { A.CallTo(() => schemaRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { Schema }); + .Returns([Schema]); var actual = await sut.GetSchemasAsync(AppId.Id, CancellationToken); @@ -124,7 +124,7 @@ public class SchemasIndexTests : GivenContext .Returns(EtagVersion.Empty); A.CallTo(() => schemaRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { Schema }); + .Returns([Schema]); var actual = await sut.GetSchemasAsync(AppId.Id, CancellationToken); @@ -138,7 +138,7 @@ public class SchemasIndexTests : GivenContext .Returns(true); A.CallTo(() => schemaRepository.QueryAllAsync(AppId.Id, CancellationToken)) - .Returns(new List { Schema }); + .Returns([Schema]); var actual = await sut.GetSchemasAsync(AppId.Id, CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaCommandsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaCommandsTests.cs index a0f91bb69..91db79ec5 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaCommandsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaCommandsTests.cs @@ -21,8 +21,8 @@ public class SchemaCommandsTests { IsPublished = true, Properties = new SchemaProperties { Hints = "MyHints" }, - Fields = new[] - { + Fields = + [ new UpsertSchemaField { Name = "myString", @@ -34,8 +34,8 @@ public class SchemaCommandsTests IsRequired = true }, Partitioning = "language" - } - }, + }, + ], FieldsInLists = FieldNames.Create("meta.id", "myString"), FieldsInReferences = FieldNames.Create("myString"), Scripts = new SchemaScripts diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemasSearchSourceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemasSearchSourceTests.cs index 1784296ad..084125f2f 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemasSearchSourceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemasSearchSourceTests.cs @@ -31,7 +31,7 @@ public class SchemasSearchSourceTests : GivenContext, IClassFixture AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { schema1 }); + .Returns([schema1]); A.CallTo(() => urlGenerator.SchemaUI(AppId, schema1.NamedId())) .Returns("schemaA1-url"); @@ -51,7 +51,7 @@ public class SchemasSearchSourceTests : GivenContext, IClassFixture AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { schema1 }); + .Returns([schema1]); A.CallTo(() => urlGenerator.SchemaUI(AppId, schema1.NamedId())) .Returns("schemaA1-url"); @@ -73,7 +73,7 @@ public class SchemasSearchSourceTests : GivenContext, IClassFixture AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { schema1, schema2, schema3 }); + .Returns([schema1, schema2, schema3]); A.CallTo(() => urlGenerator.SchemaUI(AppId, schema1.NamedId())) .Returns("schemaA1-url"); @@ -101,7 +101,7 @@ public class SchemasSearchSourceTests : GivenContext, IClassFixture AppProvider.GetSchemasAsync(AppId.Id, CancellationToken)) - .Returns(new List { schema1 }); + .Returns([schema1]); A.CallTo(() => urlGenerator.SchemaUI(AppId, schema1.NamedId())) .Returns("schemaA1-url"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj index ab58226c5..c2c30d265 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj @@ -1,13 +1,19 @@  Exe - net7.0 + net8.0 Squidex.Domain.Apps.Entities latest enable enable en + + 1701;1702;NETSDK1206 + + + 1701;1702;NETSDK1206 + @@ -21,33 +27,33 @@ - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + - - + + all runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Teams/Indexes/TeamsIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Teams/Indexes/TeamsIndexTests.cs index 6e1d6e3c8..44aea8920 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Teams/Indexes/TeamsIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Teams/Indexes/TeamsIndexTests.cs @@ -27,7 +27,7 @@ public class TeamsIndexTests : GivenContext var team = SetupTeam(0); A.CallTo(() => teamRepository.QueryAllAsync("user1", CancellationToken)) - .Returns(new List { team }); + .Returns([team]); var actual = await sut.GetTeamsAsync("user1", CancellationToken); @@ -40,7 +40,7 @@ public class TeamsIndexTests : GivenContext var team = SetupTeam(-1); A.CallTo(() => teamRepository.QueryAllAsync("user1", CancellationToken)) - .Returns(new List { team }); + .Returns([team]); var actual = await sut.GetTeamsAsync("user1", CancellationToken); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/ValidationAssert.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/ValidationAssert.cs index 77a12ed72..3d42f372c 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/ValidationAssert.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/ValidationAssert.cs @@ -18,7 +18,7 @@ public static class ValidationAssert { action(); - Assert.True(false, $"Expected {typeof(ValidationException)} but succeeded"); + Assert.Fail($"Expected {typeof(ValidationException)} but succeeded"); } catch (ValidationException ex) { @@ -30,7 +30,7 @@ public static class ValidationAssert } catch (Exception ex) { - Assert.True(false, $"Excepted {typeof(ValidationException)}, but got {ex.GetType()}"); + Assert.Fail($"Excepted {typeof(ValidationException)}, but got {ex.GetType()}"); } } @@ -40,7 +40,7 @@ public static class ValidationAssert { await action(); - Assert.True(false, $"Expected {typeof(ValidationException)} but succeeded"); + Assert.Fail($"Expected {typeof(ValidationException)} but succeeded"); } catch (ValidationException ex) { @@ -52,7 +52,7 @@ public static class ValidationAssert } catch (Exception ex) { - Assert.True(false, $"Excepted {typeof(ValidationException)}, but got {ex.GetType()}"); + Assert.Fail($"Excepted {typeof(ValidationException)}, but got {ex.GetType()}"); } } } diff --git a/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj b/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj index 5a1e6d530..569d0e893 100644 --- a/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj +++ b/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj @@ -1,7 +1,7 @@  Exe - net7.0 + net8.0 Squidex.Domain.Users latest enable @@ -14,25 +14,25 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + all runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs index c7eb256e2..0561db952 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs @@ -9,8 +9,8 @@ namespace Squidex.Infrastructure; public class CollectionExtensionsTests { - private readonly Dictionary valueDictionary = new Dictionary(); - private readonly Dictionary> listDictionary = new Dictionary>(); + private readonly Dictionary valueDictionary = []; + private readonly Dictionary> listDictionary = []; [Fact] public void SetEquals_should_return_false_if_subset() diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/CustomCommandMiddlewareRunnerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/CustomCommandMiddlewareRunnerTests.cs index ebeefdfbe..40edcb6b6 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/CustomCommandMiddlewareRunnerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/CustomCommandMiddlewareRunnerTests.cs @@ -11,7 +11,7 @@ public class CustomCommandMiddlewareRunnerTests { public sealed class Command : ICommand { - public List Values { get; set; } = new List(); + public List Values { get; set; } = []; public long ExpectedVersion { get; set; } } diff --git a/backend/tests/Squidex.Infrastructure.Tests/DomainObjectExceptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/DomainObjectExceptionTests.cs deleted file mode 100644 index c835cf7bf..000000000 --- a/backend/tests/Squidex.Infrastructure.Tests/DomainObjectExceptionTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using Squidex.Infrastructure.TestHelpers; - -namespace Squidex.Infrastructure; - -public class DomainObjectExceptionTests -{ - [Fact] - public void Should_serialize_and_deserialize_DomainException() - { - var source = new DomainException("Message", "ErrorCode"); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.Equal(actual.ErrorCode, source.ErrorCode); - Assert.Equal(actual.Message, source.Message); - } - - [Fact] - public void Should_serialize_and_deserialize_DomainObjectDeletedException() - { - var source = new DomainObjectDeletedException("123"); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.Equal(actual.Id, source.Id); - Assert.Equal(actual.Message, source.Message); - } - - [Fact] - public void Should_serialize_and_deserialize_DomainObjectNotFoundException() - { - var source = new DomainObjectNotFoundException("123"); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.Equal(actual.Id, source.Id); - Assert.Equal(actual.Message, source.Message); - } - - [Fact] - public void Should_serialize_and_deserialize_DomainObjectVersionExceptionn() - { - var source = new DomainObjectVersionException("123", 100, 200); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.Equal(actual.Id, source.Id); - Assert.Equal(actual.ExpectedVersion, source.ExpectedVersion); - Assert.Equal(actual.CurrentVersion, source.CurrentVersion); - Assert.Equal(actual.Message, source.Message); - } -} diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorIntegrationTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorIntegrationTests.cs index 7b2abe24d..8e3e6ad88 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorIntegrationTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorIntegrationTests.cs @@ -20,7 +20,7 @@ public abstract class EventConsumerProcessorIntegrationTests public sealed class EventConsumer : IEventConsumer { - public List Events { get; } = new List(); + public List Events { get; } = []; public string Name => "Consumer"; diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorTests.cs index 9f41151c5..606842dec 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumerProcessorTests.cs @@ -46,7 +46,7 @@ public class EventConsumerProcessorTests private readonly IEventSubscription eventSubscription = A.Fake(); private readonly TestState state; private readonly StoredEvent storedEvent; - private readonly EventData eventData = new EventData("Type", new EnvelopeHeaders(), "Payload"); + private readonly EventData eventData = new EventData("Type", [], "Payload"); private readonly Envelope envelope = new Envelope(new MyEvent()); private readonly MyEventConsumerProcessor sut; private readonly string consumerName = Guid.NewGuid().ToString(); diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumersHealthCheckTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumersHealthCheckTests.cs index f534702d1..423f6da08 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumersHealthCheckTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Consume/EventConsumersHealthCheckTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Infrastructure.EventSourcing.Consume; public class EventConsumersHealthCheckTests { private readonly IEventConsumerManager eventConsumerManager = A.Fake(); - private readonly List consumers = new List(); + private readonly List consumers = []; private readonly CancellationTokenSource cts = new CancellationTokenSource(); private readonly CancellationToken ct; private readonly EventConsumersHealthCheck sut; diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs index 0a19c38d6..a33c32cc6 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs @@ -16,7 +16,7 @@ public abstract class EventStoreTests where T : IEventStore public sealed class EventSubscriber : IEventSubscriber { - public List LastEvents { get; } = new List(); + public List LastEvents { get; } = []; public string LastPosition { get; set; } diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoParallelInsertTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoParallelInsertTests.cs index b72f177fa..63b0d323e 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoParallelInsertTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoParallelInsertTests.cs @@ -28,7 +28,7 @@ public sealed class MongoParallelInsertTests : IClassFixture uniqueReceivedEvents = new HashSet(); + private readonly HashSet uniqueReceivedEvents = []; private readonly TaskCompletionSource tcs = new TaskCompletionSource(); private readonly int expectedCount; diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs index 8317e4513..50a73fed9 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs @@ -96,7 +96,7 @@ public class RetrySubscriptionTests [Fact] public async Task Should_forward_event_from_inner_subscription() { - var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", new EnvelopeHeaders(), "Payload")); + var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", [], "Payload")); await OnNextAsync(eventSubscription, @event); @@ -109,7 +109,7 @@ public class RetrySubscriptionTests [Fact] public async Task Should_not_forward_event_if_message_is_from_another_subscription() { - var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", new EnvelopeHeaders(), "Payload")); + var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", [], "Payload")); await OnNextAsync(A.Fake(), @event); @@ -135,7 +135,7 @@ public class RetrySubscriptionTests [Fact] public async Task Should_be_able_to_unsubscribe_within_event_handler() { - var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", new EnvelopeHeaders(), "Payload")); + var @event = new StoredEvent("Stream", "1", 2, new EventData("Type", [], "Payload")); A.CallTo(() => eventSubscriber.OnNextAsync(A._, A._)) .Invokes(() => sut.Dispose()); diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/WrongEventVersionExceptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/WrongEventVersionExceptionTests.cs deleted file mode 100644 index 1bc88a409..000000000 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/WrongEventVersionExceptionTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using Squidex.Infrastructure.TestHelpers; - -namespace Squidex.Infrastructure.EventSourcing; - -public class WrongEventVersionExceptionTests -{ - [Fact] - public void Should_serialize_and_deserialize() - { - var source = new WrongEventVersionException(100, 200); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.Equal(actual.ExpectedVersion, source.ExpectedVersion); - Assert.Equal(actual.CurrentVersion, source.CurrentVersion); - - Assert.Equal(actual.Message, source.Message); - } -} diff --git a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs index 44d4ca71b..416b84b85 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs @@ -16,7 +16,7 @@ public class MigratorTests private readonly IMigrationStatus status = A.Fake(); private readonly IMigrationPath path = A.Fake(); private readonly ILogger log = A.Fake>(); - private readonly List<(int From, int To, IMigration Migration)> migrations = new List<(int From, int To, IMigration Migration)>(); + private readonly List<(int From, int To, IMigration Migration)> migrations = []; public sealed class InMemoryStatus : IMigrationStatus { diff --git a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/BsonJsonSerializerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/BsonJsonSerializerTests.cs index 392e77887..1108fa06d 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/BsonJsonSerializerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/BsonJsonSerializerTests.cs @@ -88,7 +88,7 @@ public class BsonJsonSerializerTests { Bool = true, Byte = 0x2, - Bytes = new byte[] { 0x10, 0x12, 0x13 }, + Bytes = [0x10, 0x12, 0x13], DateTimeOffset = new DateTimeOffset(2022, 12, 11, 10, 9, 8, TimeSpan.Zero), DateTime = new DateTime(2022, 12, 11), Float32 = 32.5f, @@ -98,7 +98,7 @@ public class BsonJsonSerializerTests Int32 = 32, Int16 = 16, String = "squidex", - Strings = new[] { "hello", "squidex " }, + Strings = ["hello", "squidex "], TimeSpan = TimeSpan.FromSeconds(123), UInt64 = 164, UInt32 = 132, diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs index f15a22380..8592f7a1f 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure.Queries; public sealed class QueryFromJsonTests { private static readonly (string Name, string Operator, string Output)[] AllOps = - { + [ ("Contains", "contains", "contains($FIELD, $VALUE)"), ("Empty", "empty", "empty($FIELD)"), ("Exists", "exists", "exists($FIELD)"), @@ -28,7 +28,7 @@ public sealed class QueryFromJsonTests ("LessThan", "lt", "$FIELD < $VALUE"), ("NotEquals", "ne", "$FIELD != $VALUE"), ("StartsWith", "startswith", "startsWith($FIELD, $VALUE)") - }; + ]; private static readonly QueryModel Model = new QueryModel(); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryTests.cs index 05ce64301..188aed6b8 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryTests.cs @@ -14,12 +14,12 @@ public class QueryTests { var query = new ClrQuery { - Sort = new List - { + Sort = + [ new SortNode("field1", SortOrder.Ascending), new SortNode("field1", SortOrder.Ascending), new SortNode("field2", SortOrder.Ascending) - } + ] }; var fields = query.GetAllFields(); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs index 269f2c251..267b151dc 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs @@ -160,7 +160,7 @@ public class PermissionTests var sorted = source.OrderBy(x => x).ToList(); - Assert.Equal(new List { source[2], source[1], source[0] }, sorted); + Assert.Equal([source[2], source[1], source[0]], sorted); } [Theory] diff --git a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj index 31ae26342..7b97af756 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj +++ b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj @@ -1,7 +1,7 @@  Exe - net7.0 + net8.0 Squidex.Infrastructure latest enable @@ -14,30 +14,30 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + - - + + all runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/backend/tests/Squidex.Infrastructure.Tests/States/InconsistentStateExceptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/States/InconsistentStateExceptionTests.cs deleted file mode 100644 index 1bf72ebc9..000000000 --- a/backend/tests/Squidex.Infrastructure.Tests/States/InconsistentStateExceptionTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using Squidex.Infrastructure.TestHelpers; - -namespace Squidex.Infrastructure.States; - -public class InconsistentStateExceptionTests -{ - [Fact] - public void Should_serialize_and_deserialize() - { - var source = new InconsistentStateException(100, 200, new InvalidOperationException("Inner")); - var actual = source.SerializeAndDeserializeBinary(); - - Assert.IsType(actual.InnerException); - - Assert.Equal("Inner", actual.InnerException?.Message); - - Assert.Equal(actual.VersionExpected, source.VersionExpected); - Assert.Equal(actual.VersionCurrent, source.VersionCurrent); - - Assert.Equal(actual.Message, source.Message); - } -} diff --git a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceBatchTests.cs b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceBatchTests.cs index 1e2b24b2c..3f520a187 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceBatchTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceBatchTests.cs @@ -42,8 +42,8 @@ public class PersistenceBatchTests SetupEventStore(new Dictionary> { - [key1] = new List { event1_1, event1_2 }, - [key2] = new List { event2_1, event2_2 } + [key1] = [event1_1, event1_2], + [key2] = [event2_1, event2_2] }); await bulk.LoadAsync(new[] { key1, key2 }); @@ -193,7 +193,7 @@ public class PersistenceBatchTests foreach (var @event in stream) { - var eventData = new EventData("Type", new EnvelopeHeaders(), "Payload"); + var eventData = new EventData("Type", [], "Payload"); var eventStored = new StoredEvent(id.ToString(), i.ToString(CultureInfo.InvariantCulture), i, eventData); A.CallTo(() => eventFormatter.Parse(eventStored)) diff --git a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs index f640b0349..02068790b 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs @@ -63,7 +63,7 @@ public class PersistenceEventSourcingTests [Fact] public async Task Should_ignore_old_events() { - var storedEvent = new StoredEvent("1", "1", 0, new EventData("Type", new EnvelopeHeaders(), "Payload")); + var storedEvent = new StoredEvent("1", "1", 0, new EventData("Type", [], "Payload")); A.CallTo(() => eventStore.QueryStreamAsync(key.ToString(), -1, A._)) .Returns(new List { storedEvent }); @@ -368,7 +368,7 @@ public class PersistenceEventSourcingTests foreach (var @event in events) { - var eventData = new EventData("Type", new EnvelopeHeaders(), "Payload"); + var eventData = new EventData("Type", [], "Payload"); var eventStored = new StoredEvent(key.ToString(), i.ToString(CultureInfo.InvariantCulture), i, eventData); eventsStored.Add(eventStored); diff --git a/backend/tests/Squidex.Infrastructure.Tests/TaskExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/TaskExtensionsTests.cs index 347ebcd76..f7d7126a4 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/TaskExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/TaskExtensionsTests.cs @@ -18,6 +18,8 @@ public class TaskExtensionsTests task.Forget(); +#pragma warning disable xUnit1031 // Do not use blocking task operations in test method Assert.Equal(123, task.Result); +#pragma warning restore xUnit1031 // Do not use blocking task operations in test method } } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Tasks/PartitionedActionBlockTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Tasks/PartitionedActionBlockTests.cs index 3038e22ef..d8505c9ee 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Tasks/PartitionedActionBlockTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Tasks/PartitionedActionBlockTests.cs @@ -18,7 +18,7 @@ public class PartitionedActionBlockTests for (var i = 0; i < Partitions; i++) { - lists[i] = new List(); + lists[i] = []; } var scheduler = new PartitionedScheduler<(int Partition, int Value)>((item, ct) => diff --git a/backend/tests/Squidex.Infrastructure.Tests/Tasks/SchedulerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Tasks/SchedulerTests.cs index 265f801fd..a93b2f4ec 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Tasks/SchedulerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Tasks/SchedulerTests.cs @@ -13,7 +13,7 @@ namespace Squidex.Infrastructure.Tasks; public class SchedulerTests { - private readonly ConcurrentBag actuals = new ConcurrentBag(); + private readonly ConcurrentBag actuals = []; private readonly Scheduler sut = new Scheduler(); [Fact] diff --git a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestState.cs b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestState.cs index 493bd810e..27df69261 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestState.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestState.cs @@ -12,7 +12,7 @@ namespace Squidex.Infrastructure.TestHelpers; public sealed class TestState where T : class, new() { - private readonly List> events = new List>(); + private readonly List> events = []; private readonly ISnapshotStore snapshotStore = A.Fake>(); private HandleSnapshot? handleSnapshot; private HandleEvent? handleEvent; diff --git a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestUtils.cs b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestUtils.cs index f02b04d32..39e57d21b 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestUtils.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/TestUtils.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System.Runtime.Serialization.Formatters.Binary; using System.Security.Claims; using System.Text.Json; using System.Text.Json.Serialization; @@ -88,20 +87,6 @@ public static class TestUtils return options; } - public static T SerializeAndDeserializeBinary(this T source) - { - using (var stream = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - - formatter.Serialize(stream, source!); - - stream.Position = 0; - - return (T)formatter.Deserialize(stream); - } - } - public static T SerializeAndDeserializeBson(this T value) { return SerializeAndDeserializeBson(value); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs index 3e0bbc9d4..25fe7fd2c 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs @@ -22,7 +22,9 @@ public class CompletionTimerTests }, 2000); timer.SkipCurrentDelay(); +#pragma warning disable xUnit1031 // Do not use blocking task operations in test method timer.StopAsync().Wait(); +#pragma warning restore xUnit1031 // Do not use blocking task operations in test method Assert.True(called); } diff --git a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/ApiUsageTrackerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/ApiUsageTrackerTests.cs index 9a5becfd0..73511fe6b 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/ApiUsageTrackerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/ApiUsageTrackerTests.cs @@ -94,22 +94,22 @@ public class ApiUsageTrackerTests var counters = new Dictionary> { - ["my-category"] = new List<(DateOnly Date, Counters Counters)> - { + ["my-category"] = + [ (dateFrom.AddDays(0), Counters(0, 0, 0)), (dateFrom.AddDays(1), Counters(4, 100, 2048)), (dateFrom.AddDays(2), Counters(0, 0, 0)), (dateFrom.AddDays(3), Counters(2, 60, 1024)), (dateFrom.AddDays(4), Counters(3, 30, 512)) - }, - ["*"] = new List<(DateOnly Date, Counters Counters)> - { + ], + ["*"] = + [ (dateFrom.AddDays(0), Counters(1, 20, 128)), (dateFrom.AddDays(1), Counters(0, 0, 0)), (dateFrom.AddDays(2), Counters(5, 90, 16)), (dateFrom.AddDays(3), Counters(0, 0, 0)), (dateFrom.AddDays(4), Counters(0, 0, 0)) - } + ] }; var forMonth = new Counters @@ -128,22 +128,22 @@ public class ApiUsageTrackerTests stats.Should().BeEquivalentTo(new Dictionary> { - ["my-category"] = new List - { + ["my-category"] = + [ new ApiStats(dateFrom.AddDays(0), 0, 0, 0), new ApiStats(dateFrom.AddDays(1), 4, 25, 2048), new ApiStats(dateFrom.AddDays(2), 0, 0, 0), new ApiStats(dateFrom.AddDays(3), 2, 30, 1024), new ApiStats(dateFrom.AddDays(4), 3, 10, 512) - }, - ["*"] = new List - { + ], + ["*"] = + [ new ApiStats(dateFrom.AddDays(0), 1, 20, 128), new ApiStats(dateFrom.AddDays(1), 0, 0, 0), new ApiStats(dateFrom.AddDays(2), 5, 18, 16), new ApiStats(dateFrom.AddDays(3), 0, 0, 0), new ApiStats(dateFrom.AddDays(4), 0, 0, 0) - } + ] }); summary.Should().BeEquivalentTo(new ApiStatsSummary(20, 15, 3728, 120, 400)); diff --git a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs index 1fcf082aa..965cc5d96 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs @@ -30,7 +30,7 @@ public class BackgroundUsageTrackerTests { sut.Dispose(); - await Assert.ThrowsAsync(() => sut.TrackAsync(date, key, "category1", new Counters(), ct)); + await Assert.ThrowsAsync(() => sut.TrackAsync(date, key, "category1", [], ct)); } [Fact] @@ -146,14 +146,14 @@ public class BackgroundUsageTrackerTests var expected = new Dictionary> { - ["*"] = new List<(DateOnly Date, Counters Counters)> - { + ["*"] = + [ (dateFrom.AddDays(0), new Counters()), (dateFrom.AddDays(1), new Counters()), (dateFrom.AddDays(2), new Counters()), (dateFrom.AddDays(3), new Counters()), (dateFrom.AddDays(4), new Counters()) - } + ] }; actual.Should().BeEquivalentTo(expected); @@ -181,22 +181,22 @@ public class BackgroundUsageTrackerTests var expected = new Dictionary> { - ["my-category"] = new List<(DateOnly Date, Counters Counters)> - { + ["my-category"] = + [ (dateFrom.AddDays(0), Counters()), (dateFrom.AddDays(1), Counters(a: 10, b: 15)), (dateFrom.AddDays(2), Counters()), (dateFrom.AddDays(3), Counters(a: 13, b: 18)), (dateFrom.AddDays(4), Counters(a: 15, b: 20)) - }, - ["*"] = new List<(DateOnly Date, Counters Counters)> - { + ], + ["*"] = + [ (dateFrom.AddDays(0), Counters(a: 17, b: 22)), (dateFrom.AddDays(1), Counters()), (dateFrom.AddDays(2), Counters(a: 11, b: 14)), (dateFrom.AddDays(3), Counters()), (dateFrom.AddDays(4), Counters()) - } + ] }; actual.Should().BeEquivalentTo(expected); diff --git a/backend/tests/Squidex.Infrastructure.Tests/ValidationExceptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/ValidationExceptionTests.cs index e922bbfbf..2647ced35 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/ValidationExceptionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/ValidationExceptionTests.cs @@ -41,21 +41,4 @@ public class ValidationExceptionTests Assert.Equal("Error1. Error2.", ex.Message); } - - [Fact] - public void Should_serialize_and_deserialize() - { - var errors = new List - { - new ValidationError("Error1"), - new ValidationError("Error2") - }; - - var source = new ValidationException(errors); - var actual = source.SerializeAndDeserializeBinary(); - - actual.Errors.Should().BeEquivalentTo(source.Errors); - - Assert.Equal(source.Message, actual.Message); - } } diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs index db64ce309..23f8fd6a5 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs @@ -18,7 +18,7 @@ namespace Squidex.Web.Pipeline; public class CachingKeysMiddlewareTests { - private readonly List<(object, Func)> callbacks = new List<(object, Func)>(); + private readonly List<(object, Func)> callbacks = []; private readonly IHttpContextAccessor httpContextAccessor = A.Fake(); private readonly IHttpResponseBodyFeature httpResponseBodyFeature = A.Fake(); private readonly IHttpResponseFeature httpResponseFeature = A.Fake(); diff --git a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj index 8d0f198a4..9c32ff007 100644 --- a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj +++ b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj @@ -1,35 +1,42 @@ - + Exe - net7.0 + net8.0 Squidex.Web latest enable enable + + 1701;1702;NETSDK1206 + + + 1701;1702;NETSDK1206 + - - + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + all runtime; build; native; contentfiles; analyzers - - - + + + diff --git a/backend/tools/GenerateLanguages/GenerateLanguages.csproj b/backend/tools/GenerateLanguages/GenerateLanguages.csproj index 078cbdd9f..5c8d2f889 100644 --- a/backend/tools/GenerateLanguages/GenerateLanguages.csproj +++ b/backend/tools/GenerateLanguages/GenerateLanguages.csproj @@ -1,18 +1,18 @@ - + Exe - net7.0 + net8.0 latest enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - +