diff --git a/backend/.editorconfig b/backend/.editorconfig index 87e22c7d4..81fc8479e 100644 --- a/backend/.editorconfig +++ b/backend/.editorconfig @@ -84,9 +84,6 @@ dotnet_diagnostic.MA0038.severity = none # MA0039: Do not write your own certificate validation method dotnet_diagnostic.MA0039.severity = none - -# MA0048: File name must match type name -dotnet_diagnostic.MA0048.severity = none # MA0049: Type name should not match containing namespace dotnet_diagnostic.MA0049.severity = none diff --git a/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs index 016d9987f..48fa7720f 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs @@ -13,6 +13,7 @@ using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Domain.Apps.Core.Scripting; #pragma warning disable IDE0059 // Value assigned to symbol is never used +#pragma warning disable MA0048 // File name must match type name namespace Squidex.Extensions.Actions.Algolia { diff --git a/backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs index 23fd6bf69..f796f713e 100644 --- a/backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs @@ -10,6 +10,8 @@ using Microsoft.WindowsAzure.Storage.Queue; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.AzureQueue { public sealed class AzureQueueActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Discourse/DiscourseActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Discourse/DiscourseActionHandler.cs index 35e0ccea9..ead5b802c 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Discourse/DiscourseActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Discourse/DiscourseActionHandler.cs @@ -9,6 +9,8 @@ using System.Text; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Discourse { public sealed class DiscourseActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs index 51bbe6175..e07e0900c 100644 --- a/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs @@ -12,6 +12,7 @@ using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Domain.Apps.Core.Scripting; #pragma warning disable IDE0059 // Value assigned to symbol is never used +#pragma warning disable MA0048 // File name must match type name namespace Squidex.Extensions.Actions.ElasticSearch { diff --git a/backend/extensions/Squidex.Extensions/Actions/Email/EmailActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Email/EmailActionHandler.cs index 6ea960591..fee3d2e9e 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Email/EmailActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Email/EmailActionHandler.cs @@ -11,6 +11,8 @@ using MimeKit.Text; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Email { public sealed class EmailActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Fastly/FastlyActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Fastly/FastlyActionHandler.cs index d2a98cf3d..bd0e3c2e7 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Fastly/FastlyActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Fastly/FastlyActionHandler.cs @@ -9,6 +9,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Infrastructure; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Fastly { public sealed class FastlyActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaActionHandler.cs index 635ded180..edf6fd173 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Kafka/KafkaActionHandler.cs @@ -8,6 +8,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Kafka { public sealed class KafkaActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Medium/MediumActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Medium/MediumActionHandler.cs index 4ee971249..1554d665d 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Medium/MediumActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Medium/MediumActionHandler.cs @@ -11,6 +11,8 @@ using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Infrastructure.Http; using Squidex.Infrastructure.Json; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Medium { public sealed class MediumActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Prerender/PrerenderActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Prerender/PrerenderActionHandler.cs index a5eaf0425..f4827cc1c 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Prerender/PrerenderActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Prerender/PrerenderActionHandler.cs @@ -9,6 +9,8 @@ using System.Text; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Prerender { public sealed class PrerenderActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Script/ScriptActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Script/ScriptActionHandler.cs index f769da74d..38e2a4829 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Script/ScriptActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Script/ScriptActionHandler.cs @@ -9,6 +9,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Domain.Apps.Core.Scripting; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Script { public sealed class ScriptActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRAction.cs b/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRAction.cs index e6ec8bc7b..8824941a4 100644 --- a/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRAction.cs +++ b/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRAction.cs @@ -11,6 +11,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules; using Squidex.Infrastructure.Validation; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.SignalR { [RuleAction( diff --git a/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRActionHandler.cs index a301383b7..c2a1ae044 100644 --- a/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/SignalR/SignalRActionHandler.cs @@ -10,6 +10,8 @@ using Microsoft.Azure.SignalR.Management; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.SignalR { public sealed class SignalRActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Slack/SlackActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Slack/SlackActionHandler.cs index 8c6a812f6..75ae57fa4 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Slack/SlackActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Slack/SlackActionHandler.cs @@ -9,6 +9,8 @@ using System.Text; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Slack { public sealed class SlackActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Twitter/TweetActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Twitter/TweetActionHandler.cs index 038277d75..0ed64e0a4 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Twitter/TweetActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Twitter/TweetActionHandler.cs @@ -10,6 +10,8 @@ using Microsoft.Extensions.Options; using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Twitter { public sealed class TweetActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs b/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs index b7d46a121..fd3305169 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs @@ -10,6 +10,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules; using Squidex.Infrastructure.Validation; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Webhook { [RuleAction( diff --git a/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookActionHandler.cs b/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookActionHandler.cs index 2cfcc2898..8be80f740 100644 --- a/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookActionHandler.cs +++ b/backend/extensions/Squidex.Extensions/Actions/Webhook/WebhookActionHandler.cs @@ -10,6 +10,8 @@ using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Infrastructure; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Extensions.Actions.Webhook { public sealed class WebhookActionHandler : RuleActionHandler diff --git a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj index cc3f42e8a..190df1f11 100644 --- a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj +++ b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj @@ -15,18 +15,18 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/backend/extensions/Squidex.Extensions/Text/Azure/AzureTextIndex.cs b/backend/extensions/Squidex.Extensions/Text/Azure/AzureTextIndex.cs index 6eff08ff3..6d36cd28f 100644 --- a/backend/extensions/Squidex.Extensions/Text/Azure/AzureTextIndex.cs +++ b/backend/extensions/Squidex.Extensions/Text/Azure/AzureTextIndex.cs @@ -73,8 +73,8 @@ namespace Squidex.Extensions.Text.Azure public async Task> SearchAsync(IAppEntity app, GeoQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var result = new List<(DomainId Id, double Score)>(); @@ -86,8 +86,8 @@ namespace Squidex.Extensions.Text.Azure public async Task> SearchAsync(IAppEntity app, TextQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var parsed = queryParser.Parse(query.Text); diff --git a/backend/extensions/Squidex.Extensions/Text/ElasticSearch/ElasticSearchTextIndex.cs b/backend/extensions/Squidex.Extensions/Text/ElasticSearch/ElasticSearchTextIndex.cs index dadf08252..f6996ee67 100644 --- a/backend/extensions/Squidex.Extensions/Text/ElasticSearch/ElasticSearchTextIndex.cs +++ b/backend/extensions/Squidex.Extensions/Text/ElasticSearch/ElasticSearchTextIndex.cs @@ -71,8 +71,8 @@ namespace Squidex.Extensions.Text.ElasticSearch public async Task> SearchAsync(IAppEntity app, GeoQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var serveField = GetServeField(scope); @@ -133,8 +133,8 @@ namespace Squidex.Extensions.Text.ElasticSearch public async Task> SearchAsync(IAppEntity app, TextQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var parsed = queryParser.Parse(query.Text); diff --git a/backend/src/Migrations/Migrations.csproj b/backend/src/Migrations/Migrations.csproj index 58e6bc72b..5f7d52abb 100644 --- a/backend/src/Migrations/Migrations.csproj +++ b/backend/src/Migrations/Migrations.csproj @@ -6,7 +6,7 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs index 75a3e5fba..25d6e1cb7 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs @@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public AppClients Revoke(string id) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); if (!this.TryRemove(id, out var updated)) { @@ -40,8 +40,8 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public AppClients Add(string id, string secret, string? role = null) { - Guard.NotNullOrEmpty(id, nameof(id)); - Guard.NotNullOrEmpty(secret, nameof(secret)); + Guard.NotNullOrEmpty(id); + Guard.NotNullOrEmpty(secret); var newClient = new AppClient(id, secret) { @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Core.Apps long? apiTrafficLimit = null, bool? allowAnonymous = false) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); if (!TryGetValue(id, out var client)) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppContributors.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppContributors.cs index afe05154a..bdc6bfe5f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppContributors.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppContributors.cs @@ -27,8 +27,8 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public AppContributors Assign(string contributorId, string role) { - Guard.NotNullOrEmpty(contributorId, nameof(contributorId)); - Guard.NotNullOrEmpty(role, nameof(role)); + Guard.NotNullOrEmpty(contributorId); + Guard.NotNullOrEmpty(role); if (!this.TrySet(contributorId, role, out var updated)) { @@ -41,7 +41,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public AppContributors Remove(string contributorId) { - Guard.NotNullOrEmpty(contributorId, nameof(contributorId)); + Guard.NotNullOrEmpty(contributorId); if (!this.TryRemove(contributorId, out var updated)) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppImage.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppImage.cs index addf2a2cf..c203ca02f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppImage.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppImage.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Apps public AppImage(string mimeType, string? etag = null) { - Guard.NotNullOrEmpty(mimeType, nameof(mimeType)); + Guard.NotNullOrEmpty(mimeType); MimeType = mimeType; diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs index 820968bec..87de5d003 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs @@ -40,8 +40,8 @@ namespace Squidex.Domain.Apps.Core.Apps public LanguagesConfig(Dictionary languages, string master) { - Guard.NotNull(languages, nameof(languages)); - Guard.NotNullOrEmpty(master, nameof(master)); + Guard.NotNull(languages); + Guard.NotNullOrEmpty(master); Cleanup(languages, ref master); @@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public LanguagesConfig MakeMaster(Language language) { - Guard.NotNull(language, nameof(language)); + Guard.NotNull(language); return Build(languages, language); } @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public LanguagesConfig Set(Language language, bool isOptional = false, params Language[]? fallbacks) { - Guard.NotNull(language, nameof(language)); + Guard.NotNull(language); var newLanguages = new Dictionary(languages) { @@ -74,7 +74,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public LanguagesConfig Remove(Language language) { - Guard.NotNull(language, nameof(language)); + Guard.NotNull(language); var newLanguages = new Dictionary(languages); 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 32eb7efff..8befb86c9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs @@ -45,8 +45,8 @@ namespace Squidex.Domain.Apps.Core.Apps public Role(string name, PermissionSet permissions, JsonObject properties) : base(name) { - Guard.NotNull(permissions, nameof(permissions)); - Guard.NotNull(properties, nameof(properties)); + Guard.NotNull(permissions); + Guard.NotNull(properties); Permissions = permissions; Properties = properties; @@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Core.Apps public Role ForApp(string app, bool isFrontend = false) { - Guard.NotNullOrEmpty(app, nameof(app)); + Guard.NotNullOrEmpty(app); var result = new HashSet(); diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs index 2d1464e35..9db7bedf1 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs @@ -118,7 +118,7 @@ namespace Squidex.Domain.Apps.Core.Apps [Pure] public Roles Update(string name, PermissionSet? permissions = null, JsonObject? properties = null) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); if (!inner.TryGetValue(name, out var role)) { @@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Core.Apps public bool TryGet(string app, string name, bool isFrontend, [MaybeNullWhen(false)] out Role value) { - Guard.NotNull(app, nameof(app)); + Guard.NotNull(app); value = null!; 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 9819facf0..3a9dad1b6 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs @@ -28,7 +28,7 @@ namespace Squidex.Domain.Apps.Core.Contents public ContentData AddField(string name, ContentFieldData? data) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); this[name] = data; @@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Core.Contents private static ContentData MergeTo(ContentData target, params ContentData[] sources) { - Guard.NotEmpty(sources, nameof(sources)); + Guard.NotEmpty(sources); if (sources.Length == 1 || sources.Skip(1).All(x => ReferenceEquals(x, sources[0]))) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs index 1d48d217e..e07f71819 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs @@ -19,8 +19,8 @@ namespace Squidex.Domain.Apps.Core.Contents { public static GeoJsonParseResult TryParse(IJsonValue value, IJsonSerializer serializer, out GeoJSONObject? geoJSON) { - Guard.NotNull(serializer, nameof(serializer)); - Guard.NotNull(value, nameof(value)); + Guard.NotNull(serializer); + Guard.NotNull(value); geoJSON = null; diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflows.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflows.cs index 815f1852e..3cc344178 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflows.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflows.cs @@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Core.Contents [Pure] public Workflows Add(DomainId workflowId, string name) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); if (!this.TryAdd(workflowId, Workflow.CreateDefault(name), out var updated)) { @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Core.Contents [Pure] public Workflows Set(Workflow workflow) { - Guard.NotNull(workflow, nameof(workflow)); + Guard.NotNull(workflow); if (!this.TrySet(default, workflow, out var updated)) { @@ -64,7 +64,7 @@ namespace Squidex.Domain.Apps.Core.Contents [Pure] public Workflows Set(DomainId id, Workflow workflow) { - Guard.NotNull(workflow, nameof(workflow)); + Guard.NotNull(workflow); if (!this.TrySet(id, workflow, out var updated)) { @@ -77,7 +77,7 @@ namespace Squidex.Domain.Apps.Core.Contents [Pure] public Workflows Update(DomainId id, Workflow workflow) { - Guard.NotNull(workflow, nameof(workflow)); + Guard.NotNull(workflow); if (id == DomainId.Empty) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Named.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Named.cs index 40b747388..6c8168b3c 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Named.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Named.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Core protected Named(string name) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); Name = name; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Partitioning.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Partitioning.cs index 76dfc6442..8a4a4fb0a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Partitioning.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Partitioning.cs @@ -7,6 +7,8 @@ using Squidex.Infrastructure; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core { public delegate IFieldPartitioning PartitionResolver(Partitioning key); @@ -20,7 +22,7 @@ namespace Squidex.Domain.Apps.Core public Partitioning(string key) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); Key = key; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs index 5a67c6fa3..41ca58bea 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs @@ -22,8 +22,8 @@ namespace Squidex.Domain.Apps.Core.Rules public Rule(RuleTrigger trigger, RuleAction action) { - Guard.NotNull(trigger, nameof(trigger)); - Guard.NotNull(action, nameof(action)); + Guard.NotNull(trigger); + Guard.NotNull(action); Action = action; @@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Core.Rules [Pure] public Rule Update(RuleTrigger newTrigger) { - Guard.NotNull(newTrigger, nameof(newTrigger)); + Guard.NotNull(newTrigger); if (newTrigger.GetType() != Trigger.GetType()) { @@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Core.Rules [Pure] public Rule Update(RuleAction newAction) { - Guard.NotNull(newAction, nameof(newAction)); + Guard.NotNull(newAction); if (newAction.GetType() != Action.GetType()) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldBase.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldBase.cs index 13b8da28b..9f52197e9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldBase.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldBase.cs @@ -17,8 +17,8 @@ namespace Squidex.Domain.Apps.Core.Schemas protected FieldBase(long id, string name) { - Guard.NotNullOrEmpty(name, nameof(name)); - Guard.GreaterThan(id, 0, nameof(id)); + Guard.NotNullOrEmpty(name); + Guard.GreaterThan(id, 0); Id = id; 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 906a803f0..a7b0914e8 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs @@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.Schemas public FieldCollection(T[] fields) { - Guard.NotNull(fields, nameof(fields)); + Guard.NotNull(fields); fieldsOrdered = fields; } @@ -97,7 +97,7 @@ namespace Squidex.Domain.Apps.Core.Schemas [Pure] public FieldCollection Reorder(List ids) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); if (ids.Count != fieldsOrdered.Length || ids.Any(x => !ById.ContainsKey(x))) { @@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Core.Schemas [Pure] public FieldCollection Add(T field) { - Guard.NotNull(field, nameof(field)); + Guard.NotNull(field); if (ByName.ContainsKey(field.Name)) { @@ -133,7 +133,7 @@ namespace Squidex.Domain.Apps.Core.Schemas [Pure] public FieldCollection Update(long fieldId, Func updater) { - Guard.NotNull(updater, nameof(updater)); + Guard.NotNull(updater); if (!ById.TryGetValue(fieldId, out var field)) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRule.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRule.cs index f71cd9c12..f64398fdc 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRule.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRule.cs @@ -19,8 +19,8 @@ namespace Squidex.Domain.Apps.Core.Schemas public FieldRule(FieldRuleAction action, string field) { - Guard.Enum(action, nameof(action)); - Guard.NotNullOrEmpty(field, nameof(field)); + Guard.Enum(action); + Guard.NotNullOrEmpty(field); Action = action; diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/NestedField{T}.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/NestedField{T}.cs index 60742ff14..8978396c1 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/NestedField{T}.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/NestedField{T}.cs @@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Core.Schemas private static T ValidateProperties(FieldProperties newProperties) { - Guard.NotNull(newProperties, nameof(newProperties)); + Guard.NotNull(newProperties); if (newProperties is not T typedProperties) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField.cs index 4534b4be0..f2b42a9cb 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField.cs @@ -25,7 +25,7 @@ namespace Squidex.Domain.Apps.Core.Schemas protected RootField(long id, string name, Partitioning partitioning, IFieldSettings? settings = null) : base(id, name) { - Guard.NotNull(partitioning, nameof(partitioning)); + Guard.NotNull(partitioning); Partitioning = partitioning; diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField{T}.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField{T}.cs index f38a1ba0f..f4b8f6ae0 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField{T}.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/RootField{T}.cs @@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Core.Schemas private static T ValidateProperties(FieldProperties newProperties) { - Guard.NotNull(newProperties, nameof(newProperties)); + Guard.NotNull(newProperties); if (newProperties is not T typedProperties) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs index 23d03929a..6d11d4dc6 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs @@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Core.Schemas public Schema(string name, SchemaProperties? properties = null, SchemaType type = SchemaType.Default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); Name = name; @@ -67,7 +67,7 @@ namespace Squidex.Domain.Apps.Core.Schemas public Schema(string name, RootField[] fields, SchemaProperties? properties, bool isPublished = false, SchemaType type = SchemaType.Default) : this(name, properties, type) { - Guard.NotNull(fields, nameof(fields)); + Guard.NotNull(fields); FieldCollection = new FieldCollection(fields); 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 b08ffbbfa..950043ca2 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 @@ -4,6 +4,7 @@ Squidex.Domain.Apps.Core 10.0 enable + en enable @@ -11,7 +12,7 @@ True - + all runtime; build; native; contentfiles; analyzers; buildtransitive 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 c3c654eeb..67e2eac22 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent { public static ContentData Convert(this ContentData content, Schema schema, params FieldConverter[] converters) { - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(schema); var result = new ContentData(content.Count); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs index b61ca3e48..11b57e7d3 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs @@ -13,6 +13,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json.Objects; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ConvertContent { public delegate ContentFieldData? FieldConverter(ContentFieldData data, IRootField field); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs index 2241f40a1..9422a7d71 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs @@ -25,7 +25,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent public static string Format(IField field, IJsonValue? value) { - Guard.NotNull(field, nameof(field)); + Guard.NotNull(field); if (value == null || value is JsonNull) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs index 488375bf5..269021ad9 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs @@ -11,6 +11,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json.Objects; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ConvertContent { public delegate IJsonValue? ValueConverter(IJsonValue value, IField field, IArrayField? parent); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueExtensions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueExtensions.cs index 756b6bb74..9d6375598 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueExtensions.cs @@ -17,8 +17,8 @@ namespace Squidex.Domain.Apps.Core.DefaultValues { public static void GenerateDefaultValues(this ContentData data, Schema schema, PartitionResolver partitionResolver) { - Guard.NotNull(schema, nameof(schema)); - Guard.NotNull(partitionResolver, nameof(partitionResolver)); + Guard.NotNull(schema); + Guard.NotNull(partitionResolver); foreach (var field in schema.Fields) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueFactory.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueFactory.cs index 6a07dd6c4..1b4152d33 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueFactory.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueFactory.cs @@ -27,8 +27,8 @@ namespace Squidex.Domain.Apps.Core.DefaultValues public static IJsonValue CreateDefaultValue(IField field, Instant now, string partition) { - Guard.NotNull(field, nameof(field)); - Guard.NotNull(partition, nameof(partition)); + Guard.NotNull(field); + Guard.NotNull(partition); return field.RawProperties.Accept(Instance, new Args(now, partition)); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/EventSynchronization/SchemaSynchronizer.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/EventSynchronization/SchemaSynchronizer.cs index 739286115..70634effc 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/EventSynchronization/SchemaSynchronizer.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/EventSynchronization/SchemaSynchronizer.cs @@ -17,8 +17,8 @@ namespace Squidex.Domain.Apps.Core.EventSynchronization public static IEnumerable Synchronize(this Schema source, Schema? target, Func idGenerator, SchemaSynchronizationOptions? options = null) { - Guard.NotNull(source, nameof(source)); - Guard.NotNull(idGenerator, nameof(idGenerator)); + Guard.NotNull(source); + Guard.NotNull(idGenerator); if (target == null) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs index fd4067805..e87c12a3a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs @@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds public static HashSet GetReferencedIds(this ContentData source, Schema schema, ResolvedComponents components, int referencesPerField = int.MaxValue) { - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(schema); var ids = new HashSet(); @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds public static void AddReferencedIds(this ContentData source, Schema schema, HashSet result, ResolvedComponents components, int referencesPerField = int.MaxValue) { - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(schema); AddReferencedIds(source, schema.Fields, result, components, referencesPerField); } @@ -69,9 +69,9 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds public static void AddReferencedIds(this ContentData source, IEnumerable fields, HashSet result, ResolvedComponents components, int referencesPerField = int.MaxValue) { - Guard.NotNull(fields, nameof(fields)); - Guard.NotNull(result, nameof(result)); - Guard.NotNull(components, nameof(components)); + Guard.NotNull(fields); + Guard.NotNull(result); + Guard.NotNull(components); foreach (var field in fields) { @@ -82,7 +82,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds private static void AddReferencedIds(IField field, ContentData source, HashSet result, ResolvedComponents components, int referencesPerField = int.MaxValue) { - Guard.NotNull(components, nameof(components)); + Guard.NotNull(components); if (source.TryGetValue(field.Name, out var fieldData) && fieldData != null) { @@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds public static HashSet GetReferencedIds(this IField field, IJsonValue? value, ResolvedComponents components, int referencesPerField = int.MaxValue) { - Guard.NotNull(components, nameof(components)); + Guard.NotNull(components); var result = new HashSet(); @@ -110,8 +110,8 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds public static JsonObject FormatReferences(this ContentData data, Schema schema, IFieldPartitioning partitioning, string separator = ", ") { - Guard.NotNull(schema, nameof(schema)); - Guard.NotNull(partitioning, nameof(partitioning)); + Guard.NotNull(schema); + Guard.NotNull(partitioning); var result = JsonValue.Object(); @@ -125,7 +125,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds private static string FormatReferenceFields(this ContentData data, Schema schema, string partitionKey, string separator) { - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(schema); var sb = new StringBuilder(); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateFilters/FilterExtensions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateFilters/FilterExtensions.cs index ccf95b944..6cdb35c59 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateFilters/FilterExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateFilters/FilterExtensions.cs @@ -13,13 +13,13 @@ using Squidex.Infrastructure.Queries; namespace Squidex.Domain.Apps.Core.GenerateFilters { - public static class JsonSchemaExtensions + public static class FilterExtensions { public static FilterSchema BuildDataSchema(this Schema schema, PartitionResolver partitionResolver, ResolvedComponents components) { - Guard.NotNull(partitionResolver, nameof(partitionResolver)); - Guard.NotNull(components, nameof(components)); + Guard.NotNull(partitionResolver); + Guard.NotNull(components); var fields = new List(); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonSchemaExtensions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonSchemaExtensions.cs index ce9fd25e2..f867f6446 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonSchemaExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonSchemaExtensions.cs @@ -10,6 +10,8 @@ using Squidex.Domain.Apps.Core.Schemas; using Squidex.Infrastructure; using Squidex.Text; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.GenerateJsonSchema { public delegate (JsonSchema Reference, JsonSchema? Actual) JsonTypeFactory(string name); @@ -29,8 +31,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema bool withHidden = false, bool withComponents = false) { - Guard.NotNull(partitionResolver, nameof(partitionResolver)); - Guard.NotNull(components, nameof(components)); + Guard.NotNull(partitionResolver); + Guard.NotNull(components); factory ??= DefaultFactory; @@ -64,8 +66,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema bool withHidden = false, bool withComponents = false) { - Guard.NotNull(partitionResolver, nameof(partitionResolver)); - Guard.NotNull(components, nameof(components)); + Guard.NotNull(partitionResolver); + Guard.NotNull(components); factory ??= DefaultFactory; @@ -102,8 +104,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema bool withHidden = false, bool withComponents = false) { - Guard.NotNull(partitionResolver, nameof(partitionResolver)); - Guard.NotNull(components, nameof(components)); + Guard.NotNull(partitionResolver); + Guard.NotNull(components); factory ??= DefaultFactory; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/EventJsonSchemaGenerator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/EventJsonSchemaGenerator.cs index 506e52010..0ac51c3de 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/EventJsonSchemaGenerator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/EventJsonSchemaGenerator.cs @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules public JsonSchema? GetSchema(string typeName) { - Guard.NotNull(typeName, nameof(typeName)); + Guard.NotNull(typeName); return schemas.Value.GetOrDefault(typeName); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs index 9dae6eb77..d78769e6c 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules internal RuleActionRegistration(Type actionType) { - Guard.NotNull(actionType, nameof(actionType)); + Guard.NotNull(actionType); ActionType = actionType; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/IScriptDescriptor.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/IScriptDescriptor.cs index a4c821c45..d2827573a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/IScriptDescriptor.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/IScriptDescriptor.cs @@ -5,6 +5,8 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.Scripting { public delegate void AddDescription(JsonType type, string name, string description); 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 e52807a57..4c418bd05 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs @@ -42,8 +42,8 @@ namespace Squidex.Domain.Apps.Core.Scripting public async Task ExecuteAsync(ScriptVars vars, string script, ScriptOptions options = default, CancellationToken ct = default) { - Guard.NotNull(vars, nameof(vars)); - Guard.NotNullOrEmpty(script, nameof(script)); + Guard.NotNull(vars); + Guard.NotNullOrEmpty(script); using (var cts = new CancellationTokenSource(timeoutExecution)) { @@ -80,8 +80,8 @@ namespace Squidex.Domain.Apps.Core.Scripting public async Task TransformAsync(ScriptVars vars, string script, ScriptOptions options = default, CancellationToken ct = default) { - Guard.NotNull(vars, nameof(vars)); - Guard.NotNullOrEmpty(script, nameof(script)); + Guard.NotNull(vars); + Guard.NotNullOrEmpty(script); using (var cts = new CancellationTokenSource(timeoutExecution)) { @@ -137,8 +137,8 @@ namespace Squidex.Domain.Apps.Core.Scripting public IJsonValue Execute(ScriptVars vars, string script, ScriptOptions options = default) { - Guard.NotNull(vars, nameof(vars)); - Guard.NotNullOrEmpty(script, nameof(script)); + Guard.NotNull(vars); + Guard.NotNullOrEmpty(script); var context = CreateEngine(options) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptContext.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptContext.cs index 0c04b0680..b4f9cdf8f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptContext.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptContext.cs @@ -24,7 +24,7 @@ namespace Squidex.Domain.Apps.Core.Scripting public bool TryGetValue(string key, [MaybeNullWhen(false)] out T value) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); value = default!; 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 ecf324440..c0c01dd72 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptingCompleter.cs @@ -21,14 +21,14 @@ namespace Squidex.Domain.Apps.Core.Scripting public IReadOnlyList ContentScript(FilterSchema dataSchema) { - Guard.NotNull(dataSchema, nameof(dataSchema)); + Guard.NotNull(dataSchema); return new Process(descriptors).Content(dataSchema, ScriptScope.ContentScript | ScriptScope.Transform); } public IReadOnlyList ContentTrigger(FilterSchema dataSchema) { - Guard.NotNull(dataSchema, nameof(dataSchema)); + Guard.NotNull(dataSchema); return new Process(descriptors).Content(dataSchema, ScriptScope.ContentTrigger); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/WritableContext.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/WritableContext.cs index 618b83fcb..fe842af7e 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/WritableContext.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/WritableContext.cs @@ -12,7 +12,7 @@ using Squidex.Text; namespace Squidex.Domain.Apps.Core.Scripting { - internal class WritableContext : ObjectInstance + internal sealed class WritableContext : ObjectInstance { private readonly ScriptVars vars; 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 10ca06fef..47d2fd8be 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 @@ -4,6 +4,7 @@ Squidex.Domain.Apps.Core 10.0 enable + en enable @@ -20,16 +21,16 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagNormalizer.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagNormalizer.cs index bf9c90ea6..ae8ee9f5a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagNormalizer.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Tags/TagNormalizer.cs @@ -16,9 +16,9 @@ namespace Squidex.Domain.Apps.Core.Tags { public static async Task NormalizeAsync(this ITagService tagService, DomainId appId, DomainId schemaId, Schema schema, ContentData newData, ContentData? oldData) { - Guard.NotNull(tagService, nameof(tagService)); - Guard.NotNull(schema, nameof(schema)); - Guard.NotNull(newData, nameof(newData)); + Guard.NotNull(tagService); + Guard.NotNull(schema); + Guard.NotNull(newData); var newValues = new HashSet(); var newArrays = new List(); @@ -52,8 +52,8 @@ namespace Squidex.Domain.Apps.Core.Tags public static async Task DenormalizeAsync(this ITagService tagService, DomainId appId, DomainId schemaId, Schema schema, params ContentData[] datas) { - Guard.NotNull(tagService, nameof(tagService)); - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(tagService); + Guard.NotNull(schema); var tagsValues = new HashSet(); var tagsArrays = new List(); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/FluidTemplateEngine.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/FluidTemplateEngine.cs index 6943fe9d3..9b92ff5d3 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/FluidTemplateEngine.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Templates/FluidTemplateEngine.cs @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Templates public async Task RenderAsync(string template, TemplateVars variables) { - Guard.NotNull(variables, nameof(variables)); + Guard.NotNull(variables); if (SquidexTemplate.TryParse(template, out var parsed, out var errors)) { diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ContentValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ContentValidator.cs index d5faf31c5..f7ec866ee 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ContentValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ContentValidator.cs @@ -31,10 +31,10 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public ContentValidator(PartitionResolver partitionResolver, ValidationContext context, IEnumerable factories, ISemanticLog log) { - Guard.NotNull(context, nameof(context)); - Guard.NotNull(factories, nameof(factories)); - Guard.NotNull(partitionResolver, nameof(partitionResolver)); - Guard.NotNull(log, nameof(log)); + Guard.NotNull(context); + Guard.NotNull(factories); + Guard.NotNull(partitionResolver); + Guard.NotNull(log); this.context = context; this.factories = factories; @@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public ValueTask ValidateInputPartialAsync(ContentData data) { - Guard.NotNull(data, nameof(data)); + Guard.NotNull(data); var validator = CreateSchemaValidator(true); @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public ValueTask ValidateInputAsync(ContentData data) { - Guard.NotNull(data, nameof(data)); + Guard.NotNull(data); var validator = CreateSchemaValidator(false); @@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public ValueTask ValidateContentAsync(ContentData data) { - Guard.NotNull(data, nameof(data)); + Guard.NotNull(data); var validator = new AggregateValidator(CreateContentValidators(), log); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidator.cs index 39c0c812b..c13481bce 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidator.cs @@ -5,6 +5,8 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ValidateContent { public delegate void AddError(IEnumerable path, string message); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidatorsFactory.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidatorsFactory.cs index 0f0faef63..e96f1f797 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidatorsFactory.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/IValidatorsFactory.cs @@ -7,6 +7,8 @@ using Squidex.Domain.Apps.Core.Schemas; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ValidateContent { public delegate IValidator ValidatorFactory(IField field); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueConverter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueConverter.cs index 21daddb57..0e065bf51 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueConverter.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueConverter.cs @@ -31,8 +31,8 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public static (object? Result, JsonError? Error) ConvertValue(IField field, IJsonValue value, IJsonSerializer jsonSerializer, ResolvedComponents components) { - Guard.NotNull(field, nameof(field)); - Guard.NotNull(value, nameof(value)); + Guard.NotNull(field); + Guard.NotNull(value); var args = new Args(value, jsonSerializer, components); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueValidator.cs index 35efc377e..7bf3d1a4c 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/JsonValueValidator.cs @@ -28,8 +28,8 @@ namespace Squidex.Domain.Apps.Core.ValidateContent public static bool IsValid(IField field, IJsonValue value, IJsonSerializer jsonSerializer) { - Guard.NotNull(field, nameof(field)); - Guard.NotNull(value, nameof(value)); + Guard.NotNull(field); + Guard.NotNull(value); var args = new Args(value, jsonSerializer); diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs index b2976f9a7..70ad35f65 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs @@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public AllowedValuesValidator(IEnumerable allowedValues) { - Guard.NotNull(allowedValues, nameof(allowedValues)); + Guard.NotNull(allowedValues); this.allowedValues = allowedValues; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs index d4a3639de..da49495ca 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs @@ -11,6 +11,8 @@ using Squidex.Domain.Apps.Core.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.Translations; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { public delegate Task> CheckAssets(IEnumerable ids); @@ -24,8 +26,8 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public AssetsValidator(bool isRequired, AssetsFieldProperties properties, CheckAssets checkAssets) { - Guard.NotNull(properties, nameof(properties)); - Guard.NotNull(checkAssets, nameof(checkAssets)); + Guard.NotNull(properties); + Guard.NotNull(checkAssets); this.properties = properties; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs index 0e9fc6228..7d01ab6d8 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public CollectionItemValidator(IValidator itemValidator) { - Guard.NotNull(itemValidator, nameof(itemValidator)); + Guard.NotNull(itemValidator); this.itemValidator = itemValidator; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs index 17b76177d..8d51467a6 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs @@ -19,8 +19,8 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public FieldValidator(IValidator validator, IField field) { - Guard.NotNull(field, nameof(field)); - Guard.NotNull(validator, nameof(validator)); + Guard.NotNull(field); + Guard.NotNull(validator); this.field = field; this.validator = validator; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs index 4305302b0..301a8931f 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs @@ -19,7 +19,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public PatternValidator(string pattern, string? errorMessage = null, bool capture = false) { - Guard.NotNullOrEmpty(pattern, nameof(pattern)); + Guard.NotNullOrEmpty(pattern); this.errorMessage = errorMessage; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs index 5ca432637..db7378e2d 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs @@ -10,6 +10,8 @@ using Squidex.Domain.Apps.Core.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.Translations; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { public delegate Task> CheckContentsByIds(HashSet ids); @@ -23,8 +25,8 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators public ReferencesValidator(bool isRequired, ReferencesFieldProperties properties, CheckContentsByIds checkReferences) { - Guard.NotNull(properties, nameof(properties)); - Guard.NotNull(checkReferences, nameof(checkReferences)); + Guard.NotNull(properties); + Guard.NotNull(checkReferences); this.properties = properties; diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValidator.cs index d90a31299..86d9bf9d6 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValidator.cs @@ -10,6 +10,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Translations; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { public delegate Task> CheckUniqueness(FilterNode filter); diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs index c66e76618..0ba263993 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs @@ -14,6 +14,8 @@ using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.States; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.MongoDb.Assets { public sealed partial class MongoAssetFolderRepository : ISnapshotStore, IDeleter diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs index dde8cdd60..6042de55c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs @@ -14,6 +14,8 @@ using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.States; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.MongoDb.Assets { public sealed partial class MongoAssetRepository : ISnapshotStore, IDeleter diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs index e2100513a..a706db0d5 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs @@ -13,6 +13,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.States; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.MongoDb.Contents { public partial class MongoContentRepository : ISnapshotStore, IDeleter diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryById.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryById.cs index 89fcb6dd8..9d02698ad 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryById.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryById.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task QueryAsync(ISchemaEntity schema, DomainId id, CancellationToken ct) { - Guard.NotNull(schema, nameof(schema)); + Guard.NotNull(schema); var documentId = DomainId.Combine(schema.AppId, id); diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByIds.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByIds.cs index 671997771..e48c8a11f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByIds.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByIds.cs @@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task> QueryAsync(DomainId appId, List schemas, Q q, CancellationToken ct) { - Guard.NotNull(q, nameof(q)); + Guard.NotNull(q); if (q.Ids == null || q.Ids.Count == 0) { diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs index 785064444..309150f75 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs @@ -56,7 +56,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task> QueryIdsAsync(DomainId appId, DomainId schemaId, FilterNode filterNode, CancellationToken ct) { - Guard.NotNull(filterNode, nameof(filterNode)); + Guard.NotNull(filterNode); try { @@ -86,8 +86,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task> QueryAsync(IAppEntity app, List schemas, Q q, CancellationToken ct) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(q, nameof(q)); + Guard.NotNull(app); + Guard.NotNull(q); try { @@ -122,9 +122,9 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task> QueryAsync(IAppEntity app, ISchemaEntity schema, Q q, CancellationToken ct) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(schema, nameof(schema)); - Guard.NotNull(q, nameof(q)); + Guard.NotNull(app); + Guard.NotNull(schema); + Guard.NotNull(q); try { diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs index d0257c901..bf57c1b2b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs @@ -28,7 +28,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations public async Task> QueryAsync(DomainId appId, List schemas, Q q, CancellationToken ct) { - Guard.NotNull(q, nameof(q)); + Guard.NotNull(q); if (q.ScheduledFrom == null || q.ScheduledTo == null) { diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs index 93cba3ba2..aabda00b3 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs @@ -147,8 +147,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Rules public Task UpdateAsync(RuleJob job, RuleJobUpdate update, CancellationToken ct = default) { - Guard.NotNull(job, nameof(job)); - Guard.NotNull(update, nameof(update)); + Guard.NotNull(job); + Guard.NotNull(update); return Task.WhenAll( UpdateStatisticsAsync(job, update, ct), diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemasHash.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemasHash.cs index 900eebd37..409901e8e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemasHash.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemasHash.cs @@ -91,7 +91,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Schemas public async Task<(Instant Create, string Hash)> GetCurrentHashAsync(IAppEntity app, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); + Guard.NotNull(app); var entity = await Collection.Find(x => x.AppId == app.Id).FirstOrDefaultAsync(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 f5567f1e1..d0933051a 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 @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasTextIndex.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasTextIndex.cs index fe59c57f3..55a264678 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasTextIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/AtlasTextIndex.cs @@ -67,8 +67,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Text public override async Task?> SearchAsync(IAppEntity app, TextQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var (search, take) = query; 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 c5c9a52f6..9504580bf 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoTextIndexBase.cs @@ -103,8 +103,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Text public virtual async Task?> SearchAsync(IAppEntity app, GeoQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var findFilter = Filter.And( @@ -123,8 +123,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Text public virtual async Task?> SearchAsync(IAppEntity app, TextQuery query, SearchScope scope, CancellationToken ct = default) { - Guard.NotNull(app, nameof(app)); - Guard.NotNull(query, nameof(query)); + Guard.NotNull(app); + Guard.NotNull(query); var (search, take) = query; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs index aee96993d..cd1b88847 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs @@ -74,7 +74,7 @@ namespace Squidex.Domain.Apps.Entities.Apps private JsonObject? GetContainer(string path, bool add, out string key) { - Guard.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path); var segments = path.Split('.'); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppLogStore.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppLogStore.cs index b1b037c68..33701d1fe 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppLogStore.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppLogStore.cs @@ -83,7 +83,7 @@ namespace Squidex.Domain.Apps.Entities.Apps public async Task ReadLogAsync(DomainId appId, DateTime fromDate, DateTime toDate, Stream stream, CancellationToken ct = default) { - Guard.NotNull(appId, nameof(appId)); + Guard.NotNull(appId); var writer = new StreamWriter(stream, Encoding.UTF8, 4096, true); try diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs index 0a43c1c28..e7ed342e4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static void CanCreate(CreateApp command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUploadImage(UploadAppImage command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -44,22 +44,22 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUpdate(UpdateApp command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); } public static void CanRemoveImage(RemoveAppImage command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); } public static void CanUpdateAssetScripts(ConfigureAssetScripts command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); } public static void CanUpdateSettings(UpdateAppSettings command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -125,7 +125,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanChangePlan(ChangePlan command, IAppEntity app, IAppPlansProvider appPlans) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs index c7a870e13..97d86b8c6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static void CanAttach(AttachClient command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanRevoke(RevokeClient command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); GetClientOrThrow(app.Clients, command.Id); @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUpdate(UpdateClient command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); GetClientOrThrow(app.Clients, command.Id); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs index f075c46b8..7b4ead6f1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs @@ -19,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static Task CanAssign(AssignContributor command, IAppEntity app, IUserResolver users, IAppLimitsPlan plan) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var contributors = app.Contributors; @@ -64,7 +64,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanRemove(RemoveContributor command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var contributors = app.Contributors; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs index 209e7c718..3ce3142ea 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static void CanAdd(AddLanguage command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -37,7 +37,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanRemove(RemoveLanguage command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUpdate(UpdateLanguage command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs index 026c28e18..6ad268a7a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static void CanAdd(AddRole command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var roles = app.Roles; @@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanDelete(DeleteRole command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var roles = app.Roles; @@ -67,7 +67,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUpdate(UpdateRole command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var roles = app.Roles; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs index ec02d4ef9..8984d2c0e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards { public static void CanAdd(AddWorkflow command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanUpdate(UpdateWorkflow command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var workflows = app.Workflows; @@ -94,7 +94,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards public static void CanDelete(DeleteWorkflow command, IAppEntity app) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var workflows = app.Workflows; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/ConfigAppPlansProvider.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/ConfigAppPlansProvider.cs index b5e1ab7d2..8fdaf15c3 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/ConfigAppPlansProvider.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/ConfigAppPlansProvider.cs @@ -63,7 +63,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans public IAppLimitsPlan? GetPlanUpgradeForApp(IAppEntity app) { - Guard.NotNull(app, nameof(app)); + Guard.NotNull(app); return GetPlanUpgrade(app.Plan?.PlanId); } @@ -84,7 +84,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans public (IAppLimitsPlan Plan, string PlanId) GetPlanForApp(IAppEntity app) { - Guard.NotNull(app, nameof(app)); + Guard.NotNull(app); var planId = app.Plan?.PlanId; var plan = GetPlanCore(planId); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/RedirectToCheckoutResult.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/RedirectToCheckoutResult.cs index e91a5c05f..c6b84bf60 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/RedirectToCheckoutResult.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/RedirectToCheckoutResult.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans public RedirectToCheckoutResult(Uri url) { - Guard.NotNull(url, nameof(url)); + Guard.NotNull(url); Url = url; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/UsageGate.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/UsageGate.cs index 28e44d3a6..0310a789a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/UsageGate.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Plans/UsageGate.cs @@ -32,7 +32,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans public virtual async Task IsBlockedAsync(IAppEntity app, string? clientId, DateTime today) { - Guard.NotNull(app, nameof(app)); + Guard.NotNull(app); var appId = app.Id; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs index ac91b4c1a..59a6904f0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs @@ -9,6 +9,8 @@ using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.Apps.Templates { public delegate Task PublishTemplate(IAppCommand command); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs index 30fa34f3d..cbd821ead 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs @@ -10,6 +10,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.UsageTracking; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.Assets { public partial class AssetUsageTracker : IEventConsumer diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs index f79b047da..6df6b5bd7 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs @@ -81,7 +81,7 @@ namespace Squidex.Domain.Apps.Entities.Assets private async Task GetTextAsync(ScriptExecutionContext context, JsValue input, Action callback, JsValue encoding) { - Guard.NotNull(callback, nameof(callback)); + Guard.NotNull(callback); if (input is not ObjectWrapper objectWrapper) { @@ -137,7 +137,7 @@ namespace Squidex.Domain.Apps.Entities.Assets private async Task GetReferencesAsync(ScriptExecutionContext context, DomainId appId, ClaimsPrincipal user, JsValue references, Action callback) { - Guard.NotNull(callback, nameof(callback)); + Guard.NotNull(callback); var ids = new List(); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs index 681405f78..53d8b1f7d 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs @@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject { await assetFileStore.DeleteAsync(tempFile); - createAsset.File.Dispose(); + await createAsset.File.DisposeAsync(); } break; @@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject { await assetFileStore.DeleteAsync(tempFile); - upload.File.Dispose(); + await upload.File.DisposeAsync(); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderOperation.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderOperation.cs index af51adef0..3a9226086 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderOperation.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderOperation.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject public AssetFolderOperation(IServiceProvider serviceProvider, Func snapshot) : base(serviceProvider, snapshot) { - Guard.NotNull(serviceProvider, nameof(serviceProvider)); + Guard.NotNull(serviceProvider); } public static async Task CreateAsync(IServiceProvider services, AssetFolderCommand command, Func snapshot) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetOperation.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetOperation.cs index 405d8a812..1c0cf03e6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetOperation.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetOperation.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject public AssetOperation(IServiceProvider serviceProvider, Func snapshot) : base(serviceProvider, snapshot) { - Guard.NotNull(serviceProvider, nameof(serviceProvider)); + Guard.NotNull(serviceProvider); } public static async Task CreateAsync(IServiceProvider services, AssetCommand command, Func snapshot) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/TagsExtensions.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/TagsExtensions.cs index 75270ce16..90ff4beda 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/TagsExtensions.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/TagsExtensions.cs @@ -9,7 +9,7 @@ using Squidex.Domain.Apps.Core.Tags; namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards { - public static class TagService + public static class TagsExtensions { public static async Task> NormalizeTags(this AssetOperation operation, HashSet tags) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs index 366e3da41..4e3b11119 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs @@ -36,8 +36,8 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task EnrichAsync(IAssetEntity asset, Context context, CancellationToken ct) { - Guard.NotNull(asset, nameof(asset)); - Guard.NotNull(context, nameof(context)); + Guard.NotNull(asset); + Guard.NotNull(context); var enriched = await EnrichAsync(Enumerable.Repeat(asset, 1), context, ct); @@ -47,8 +47,8 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task> EnrichAsync(IEnumerable assets, Context context, CancellationToken ct) { - Guard.NotNull(assets, nameof(assets)); - Guard.NotNull(context, nameof(context)); + Guard.NotNull(assets); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("ContentQueryService/EnrichAsync")) { 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 bfe10cc3d..f4e766357 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryParser.cs @@ -40,8 +40,8 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public virtual async Task ParseAsync(Context context, Q q) { - Guard.NotNull(context, nameof(context)); - Guard.NotNull(q, nameof(q)); + Guard.NotNull(context); + Guard.NotNull(q); using (Telemetry.Activities.StartActivity("AssetQueryParser/ParseAsync")) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs index 5c56c2371..74498f8af 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs @@ -88,7 +88,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task FindByHashAsync(Context context, string hash, string fileName, long fileSize, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("AssetQueryService/FindByHashAsync")) { @@ -106,7 +106,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task FindBySlugAsync(Context context, string slug, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("AssetQueryService/FindBySlugAsync")) { @@ -124,7 +124,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task FindGlobalAsync(Context context, DomainId id, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("AssetQueryService/FindGlobalAsync")) { @@ -142,7 +142,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task FindAsync(Context context, DomainId id, long version = EtagVersion.Any, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("AssetQueryService/FindAsync")) { @@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries public async Task> QueryAsync(Context context, DomainId? parentId, Q q, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); if (q == null) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContext.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContext.cs index 417cad7c4..ec1553d7b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContext.cs @@ -16,7 +16,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public BackupContext(DomainId appId, IUserMapping userMapping, IBackupWriter writer) : base(appId, userMapping) { - Guard.NotNull(writer, nameof(writer)); + Guard.NotNull(writer); Writer = writer; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContextBase.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContextBase.cs index aa99c5ea0..415d21115 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContextBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupContextBase.cs @@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Entities.Backup protected BackupContextBase(DomainId appId, IUserMapping userMapping) { - Guard.NotNull(userMapping, nameof(userMapping)); + Guard.NotNull(userMapping); AppId = appId; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs index d400bb373..a7286f188 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs @@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public BackupReader(IJsonSerializer serializer, Stream stream) { - Guard.NotNull(serializer, nameof(serializer)); + Guard.NotNull(serializer); this.serializer = serializer; @@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public Task OpenBlobAsync(string name, CancellationToken ct = default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); var entry = GetEntry(name); @@ -63,7 +63,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public async Task ReadJsonAsync(string name, CancellationToken ct = default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); var entry = GetEntry(name); @@ -76,7 +76,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public Task HasFileAsync(string name, CancellationToken ct = default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); var attachmentEntry = archive.GetEntry(ArchiveHelper.GetAttachmentPath(name)); @@ -100,8 +100,8 @@ namespace Squidex.Domain.Apps.Entities.Backup public async IAsyncEnumerable<(string Stream, Envelope Event)> ReadEventsAsync(IStreamNameResolver streamNameResolver, IEventDataFormatter formatter, [EnumeratorCancellation] CancellationToken ct = default) { - Guard.NotNull(formatter, nameof(formatter)); - Guard.NotNull(streamNameResolver, nameof(streamNameResolver)); + Guard.NotNull(formatter); + Guard.NotNull(streamNameResolver); while (!ct.IsCancellationRequested) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs index c67cf5269..6bbfb44a1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs @@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public BackupWriter(IJsonSerializer serializer, Stream stream, bool keepOpen = false, BackupVersion version = BackupVersion.V2) { - Guard.NotNull(serializer, nameof(serializer)); + Guard.NotNull(serializer); this.serializer = serializer; @@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public Task OpenBlobAsync(string name, CancellationToken ct = default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); writtenAttachments++; @@ -69,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public async Task WriteJsonAsync(string name, object value, CancellationToken ct = default) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); writtenAttachments++; @@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public void WriteEvent(StoredEvent storedEvent, CancellationToken ct = default) { - Guard.NotNull(storedEvent, nameof(storedEvent)); + Guard.NotNull(storedEvent); var eventEntry = archive.CreateEntry(ArchiveHelper.GetEventPath(writtenEvents)); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs index 723224f35..03a002aa9 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/Model/CompatibleStoredEvent.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq; using Squidex.Infrastructure.EventSourcing; #pragma warning disable SA1401 // Fields must be private +#pragma warning disable MA0048 // File name must match type name namespace Squidex.Domain.Apps.Entities.Backup.Model { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreContext.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreContext.cs index b0746c6de..8e58b555e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreContext.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public RestoreContext(DomainId appId, IUserMapping userMapping, IBackupReader reader, DomainId previousAppId) : base(appId, userMapping) { - Guard.NotNull(reader, nameof(reader)); + Guard.NotNull(reader); Reader = reader; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs index c1cf479cf..860ec1239 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs @@ -90,12 +90,12 @@ namespace Squidex.Domain.Apps.Entities.Backup public async Task RestoreAsync(Uri url, RefToken actor, string? newAppName = null) { - Guard.NotNull(url, nameof(url)); - Guard.NotNull(actor, nameof(actor)); + Guard.NotNull(url); + Guard.NotNull(actor); if (!string.IsNullOrWhiteSpace(newAppName)) { - Guard.ValidSlug(newAppName, nameof(newAppName)); + Guard.ValidSlug(newAppName); } if (CurrentJob?.Status == JobStatus.Started) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/StreamMapper.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/StreamMapper.cs index cab67724e..d448e4ad6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/StreamMapper.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/StreamMapper.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public StreamMapper(RestoreContext context) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); this.context = context; @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public (string Stream, DomainId) Map(string stream) { - Guard.NotNullOrEmpty(stream, nameof(stream)); + Guard.NotNullOrEmpty(stream); var typeIndex = stream.IndexOf("-", StringComparison.Ordinal); var typeName = stream[..typeIndex]; @@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public long GetStreamOffset(string streamName) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); if (!streams.TryGetValue(streamName, out var offset)) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs index 5b7aa1a9c..426c01794 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs @@ -23,14 +23,14 @@ namespace Squidex.Domain.Apps.Entities.Backup public UserMapping(RefToken initiator) { - Guard.NotNull(initiator, nameof(initiator)); + Guard.NotNull(initiator); this.initiator = initiator; } public void Backup(RefToken token) { - Guard.NotNull(token, nameof(token)); + Guard.NotNull(token); if (!token.IsUser) { @@ -42,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public void Backup(string userId) { - Guard.NotNullOrEmpty(userId, nameof(userId)); + Guard.NotNullOrEmpty(userId); if (!userMap.ContainsKey(userId)) { @@ -53,8 +53,8 @@ namespace Squidex.Domain.Apps.Entities.Backup public async Task StoreAsync(IBackupWriter writer, IUserResolver userResolver, CancellationToken ct = default) { - Guard.NotNull(writer, nameof(writer)); - Guard.NotNull(userResolver, nameof(userResolver)); + Guard.NotNull(writer); + Guard.NotNull(userResolver); var users = await userResolver.QueryManyAsync(userMap.Keys.ToArray(), ct); @@ -66,8 +66,8 @@ namespace Squidex.Domain.Apps.Entities.Backup public async Task RestoreAsync(IBackupReader reader, IUserResolver userResolver, CancellationToken ct = default) { - Guard.NotNull(reader, nameof(reader)); - Guard.NotNull(userResolver, nameof(userResolver)); + Guard.NotNull(reader); + Guard.NotNull(userResolver); var json = await reader.ReadJsonAsync>(UsersFile, ct); @@ -84,7 +84,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public bool TryMap(string userId, out RefToken result) { - Guard.NotNullOrEmpty(userId, nameof(userId)); + Guard.NotNullOrEmpty(userId); result = initiator; @@ -99,7 +99,7 @@ namespace Squidex.Domain.Apps.Entities.Backup public bool TryMap(RefToken token, out RefToken result) { - Guard.NotNull(token, nameof(token)); + Guard.NotNull(token); result = initiator; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs index 4fdc260bb..17d633cd8 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs @@ -94,8 +94,8 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject private async Task Upsert(TCommand command, Action handler) where TCommand : CommentsCommand { - Guard.NotNull(command, nameof(command)); - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(command); + Guard.NotNull(handler); if (command.ExpectedVersion > EtagVersion.Any && command.ExpectedVersion != Version) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs b/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs index ebb315863..8e8572ae1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject.Guards { public static void CanCreate(CreateComment command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject.Guards public static void CanUpdate(UpdateComment command, string commentsId, List> events) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var comment = FindComment(events, command.CommentId); @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject.Guards public static void CanDelete(DeleteComment command, string commentsId, List> events) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var comment = FindComment(events, command.CommentId); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Comments/GrainWatchingService.cs b/backend/src/Squidex.Domain.Apps.Entities/Comments/GrainWatchingService.cs index 6b7df3baf..746e0ab6c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Comments/GrainWatchingService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Comments/GrainWatchingService.cs @@ -21,8 +21,8 @@ namespace Squidex.Domain.Apps.Entities.Comments public Task GetWatchingUsersAsync(DomainId appId, string resource, string userId) { - Guard.NotNullOrEmpty(resource, nameof(resource)); - Guard.NotNullOrEmpty(userId, nameof(userId)); + Guard.NotNullOrEmpty(resource); + Guard.NotNullOrEmpty(userId); return GetGrain(appId).GetWatchingUsersAsync(resource, userId); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Comments/WatchingGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Comments/WatchingGrain.cs index ce0c7a2ac..35b8c799a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Comments/WatchingGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Comments/WatchingGrain.cs @@ -38,8 +38,8 @@ namespace Squidex.Domain.Apps.Entities.Comments public Task GetWatchingUsersAsync(string resource, string userId) { - Guard.NotNullOrEmpty(resource, nameof(resource)); - Guard.NotNullOrEmpty(userId, nameof(userId)); + Guard.NotNullOrEmpty(resource); + Guard.NotNullOrEmpty(userId); var usersByResource = users.GetOrAddNew(resource); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultWorkflowsValidator.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultWorkflowsValidator.cs index c29a28786..8e09916c4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultWorkflowsValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultWorkflowsValidator.cs @@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Entities.Contents public async Task> ValidateAsync(DomainId appId, Workflows workflows) { - Guard.NotNull(workflows, nameof(workflows)); + Guard.NotNull(workflows); var errors = new List(); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs index 417909fd3..e0f6b3569 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject public ContentVersion(Status status, ContentData data) { - Guard.NotNull(data, nameof(data)); + Guard.NotNull(data); Status = status; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLService.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLResolver.cs similarity index 71% rename from backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLService.cs rename to backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLResolver.cs index 7db0922e4..38d0cd365 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/CachingGraphQLResolver.cs @@ -7,6 +7,7 @@ using System.Globalization; using GraphQL; +using GraphQL.DI; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using NodaTime; @@ -15,14 +16,14 @@ using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types; using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Infrastructure; -using Squidex.Log; +using GraphQLSchema = GraphQL.Types.Schema; #pragma warning disable SA1313 // Parameter names should begin with lower-case letter #pragma warning disable RECS0082 // Parameter has the same name as a member and hides it namespace Squidex.Domain.Apps.Entities.Contents.GraphQL { - public sealed class CachingGraphQLService : IGraphQLService + public sealed class CachingGraphQLResolver : IConfigureExecution { private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(10); private readonly IBackgroundCache cache; @@ -30,14 +31,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL private readonly IServiceProvider serviceProvider; private readonly GraphQLOptions options; - private sealed record CacheEntry(GraphQLModel Model, string Hash, Instant Created); + private sealed record CacheEntry(GraphQLSchema Model, string Hash, Instant Created); public IServiceProvider Services { get => serviceProvider; } - public CachingGraphQLService(IBackgroundCache cache, ISchemasHash schemasHash, IServiceProvider serviceProvider, IOptions options) + public CachingGraphQLResolver(IBackgroundCache cache, ISchemasHash schemasHash, IServiceProvider serviceProvider, + IOptions options) { this.cache = cache; this.schemasHash = schemasHash; @@ -45,16 +47,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL this.options = options.Value; } - public async Task ExecuteAsync(ExecutionOptions options) + public async Task ConfigureAsync(ExecutionOptions executionOptions) { - var context = ((GraphQLExecutionContext)options.UserContext!).Context; + var context = ((GraphQLExecutionContext)executionOptions.UserContext!).Context; - var model = await GetModelAsync(context.App); - - return await model.ExecuteAsync(options); + executionOptions.Schema = await GetSchemaAsync(context.App); } - public async Task GetModelAsync(IAppEntity app) + public async Task GetSchemaAsync(IAppEntity app) { var entry = await GetModelEntryAsync(app); @@ -84,15 +84,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL private async Task CreateModelAsync(IAppEntity app) { - var allSchemas = await serviceProvider.GetRequiredService().GetSchemasAsync(app.Id); + var schemas = await serviceProvider.GetRequiredService().GetSchemasAsync(app.Id); - var hash = await schemasHash.ComputeHashAsync(app, allSchemas); + var hash = await schemasHash.ComputeHashAsync(app, schemas); return new CacheEntry( - new GraphQLModel(app, - allSchemas, - serviceProvider.GetRequiredService(), - serviceProvider.GetRequiredService()), + new Builder(app, serviceProvider.GetRequiredService()).BuildSchema(schemas), hash, SystemClock.Instance.GetCurrentInstant()); } 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 67ac6c29d..5b776dbfd 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs @@ -35,7 +35,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL public GraphQLExecutionContext(IAssetQueryService assetQuery, IContentQueryService contentQuery, Context context, IDataLoaderContextAccessor dataLoaders, - ICommandBus commandBus, IUrlGenerator urlGenerator, IUserResolver userResolver, + ICommandBus commandBus, + IUrlGenerator urlGenerator, + IUserResolver userResolver, ISemanticLog log) : base(assetQuery, contentQuery) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs deleted file mode 100644 index 1a0f7ded8..000000000 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs +++ /dev/null @@ -1,55 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using GraphQL; -using Squidex.Domain.Apps.Entities.Apps; -using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types; -using Squidex.Domain.Apps.Entities.Schemas; -using Squidex.Log; -using GraphQLSchema = GraphQL.Types.Schema; - -namespace Squidex.Domain.Apps.Entities.Contents.GraphQL -{ - public sealed class GraphQLModel - { - private static readonly IDocumentExecuter Executor = new DocumentExecuter(); - private readonly GraphQLSchema schema; - private readonly ISemanticLog log; - - public GraphQLSchema Schema => schema; - - public GraphQLModel(IAppEntity app, IEnumerable schemas, SharedTypes typeFactory, ISemanticLog log) - { - this.log = log; - - schema = new Builder(app, typeFactory).BuildSchema(schemas); - } - - public async Task ExecuteAsync(ExecutionOptions options) - { - options.Schema = schema; - - var result = await Executor.ExecuteAsync(options); - - if (result.Errors != null && result.Errors.Any()) - { - log.LogWarning(w => w - .WriteProperty("action", "GraphQL") - .WriteProperty("status", "Failed") - .WriteArray("errors", a => - { - foreach (var error in result.Errors) - { - a.WriteObject(error, (error, e) => e.WriteException(error)); - } - })); - } - - return result; - } - } -} diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/IGraphQLService.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/IGraphQLService.cs deleted file mode 100644 index 7c4cbdef1..000000000 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/IGraphQLService.cs +++ /dev/null @@ -1,16 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using GraphQL; - -namespace Squidex.Domain.Apps.Entities.Contents.GraphQL -{ - public interface IGraphQLService - { - Task ExecuteAsync(ExecutionOptions options); - } -} diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs index f2c6d6f4f..dd303dc26 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs @@ -13,6 +13,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Collections; using Squidex.Infrastructure.Json.Objects; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public delegate object ValueResolver(IJsonValue value, IResolveFieldContext fieldContext, GraphQLExecutionContext context); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfo.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfo.cs index 7a36f9316..48098e28c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfo.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfo.cs @@ -10,6 +10,8 @@ using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Infrastructure; using Squidex.Text; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { internal sealed class SchemaInfo @@ -175,7 +177,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents private string GetName(string name, bool isEntity) { - Guard.NotNullOrEmpty(name, nameof(name)); + Guard.NotNullOrEmpty(name); if (!char.IsLetter(name[0])) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs index 68de8c722..73592ca3c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs @@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public async Task EnrichAsync(IContentEntity content, bool cloneData, Context context, CancellationToken ct) { - Guard.NotNull(content, nameof(content)); + Guard.NotNull(content); var enriched = await EnrichInternalAsync(Enumerable.Repeat(content, 1), cloneData, context, ct); @@ -37,8 +37,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public Task> EnrichAsync(IEnumerable contents, Context context, CancellationToken ct) { - Guard.NotNull(contents, nameof(contents)); - Guard.NotNull(context, nameof(context)); + Guard.NotNull(contents); + Guard.NotNull(context); return EnrichInternalAsync(contents, false, context, ct); } 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 6ec9255d1..db9da77b6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs @@ -47,8 +47,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public virtual async Task ParseAsync(Context context, Q q, ISchemaEntity? schema = null) { - Guard.NotNull(context, nameof(context)); - Guard.NotNull(q, nameof(q)); + Guard.NotNull(context); + Guard.NotNull(q); using (Telemetry.Activities.StartActivity("ContentQueryParser/ParseAsync")) { 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 057d0cae4..7289e8a1f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs @@ -45,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public async Task FindAsync(Context context, string schemaIdOrName, DomainId id, long version = EtagVersion.Any, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("ContentQueryService/FindAsync")) { @@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public async Task> QueryAsync(Context context, string schemaIdOrName, Q q, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("ContentQueryService/QueryAsync")) { @@ -111,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public async Task> QueryAsync(Context context, Q q, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("ContentQueryService/QueryAsync")) { @@ -181,8 +181,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public async Task GetSchemaAsync(Context context, string schemaIdOrName, CancellationToken ct = default) { - Guard.NotNull(context, nameof(context)); - Guard.NotNullOrEmpty(schemaIdOrName, nameof(schemaIdOrName)); + Guard.NotNull(context); + Guard.NotNullOrEmpty(schemaIdOrName); ISchemaEntity? schema = null; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs index ac468eac1..e93930ff9 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs @@ -9,6 +9,8 @@ using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Infrastructure; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities.Contents.Queries { public delegate Task<(ISchemaEntity Schema, ResolvedComponents Components)> ProvideSchema(DomainId id); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs index 215717c66..e244f0e6a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs @@ -23,8 +23,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries protected QueryExecutionContext(IAssetQueryService assetQuery, IContentQueryService contentQuery) { - Guard.NotNull(assetQuery, nameof(assetQuery)); - Guard.NotNull(contentQuery, nameof(contentQuery)); + Guard.NotNull(assetQuery); + Guard.NotNull(contentQuery); this.assetQuery = assetQuery; this.contentQuery = contentQuery; @@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public virtual async Task> GetReferencedAssetsAsync(ICollection ids, CancellationToken ct) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); var notLoadedAssets = new HashSet(ids.Where(id => !cachedAssets.ContainsKey(id))); @@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries public virtual async Task> GetReferencedContentsAsync(ICollection ids, CancellationToken ct) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); var notLoadedContents = ids.Where(id => !cachedContents.ContainsKey(id)).ToList(); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/ReferencesJintExtension.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/ReferencesJintExtension.cs index c52662bab..b8a9bb798 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/ReferencesJintExtension.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/ReferencesJintExtension.cs @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents private async Task GetReferencesAsync(ScriptExecutionContext context, DomainId appId, ClaimsPrincipal user, JsValue references, Action callback) { - Guard.NotNull(callback, nameof(callback)); + Guard.NotNull(callback); var ids = new List(); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/CachingTextIndexerState.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/CachingTextIndexerState.cs index 5378edd48..d5b48c70a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/CachingTextIndexerState.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/CachingTextIndexerState.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State public CachingTextIndexerState(ITextIndexerState inner) { - Guard.NotNull(inner, nameof(inner)); + Guard.NotNull(inner); this.inner = inner; } @@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State public async Task> GetAsync(HashSet ids, CancellationToken ct = default) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); var missingIds = new HashSet(); @@ -77,7 +77,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State public Task SetAsync(List updates, CancellationToken ct = default) { - Guard.NotNull(updates, nameof(updates)); + Guard.NotNull(updates); foreach (var update in updates) { 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 08f66b58e..f8e067041 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 @@ -24,7 +24,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State public Task> GetAsync(HashSet ids, CancellationToken ct = default) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); var result = new Dictionary(); @@ -42,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State public Task SetAsync(List updates, CancellationToken ct = default) { - Guard.NotNull(updates, nameof(updates)); + Guard.NotNull(updates); foreach (var update in updates) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextSearch.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextQuery.cs similarity index 100% rename from backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextSearch.cs rename to backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextQuery.cs diff --git a/backend/src/Squidex.Domain.Apps.Entities/Context.cs b/backend/src/Squidex.Domain.Apps.Entities/Context.cs index e6ad03ca8..eaf3a8077 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Context.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Context.cs @@ -13,6 +13,8 @@ using Squidex.Shared; using Squidex.Shared.Identity; using ClaimsPermissions = Squidex.Infrastructure.Security.PermissionSet; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Entities { public sealed class Context @@ -32,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities public Context(ClaimsPrincipal user, IAppEntity app) : this(app, user, user.Claims.Permissions(), EmptyHeaders) { - Guard.NotNull(user, nameof(user)); + Guard.NotNull(user); } private Context(IAppEntity app, ClaimsPrincipal user, ClaimsPermissions userPermissions, IReadOnlyDictionary headers) diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs index a057214b9..d3cfacf7d 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEvent.cs @@ -34,8 +34,8 @@ namespace Squidex.Domain.Apps.Entities.History public HistoryEvent(string channel, string eventType) { - Guard.NotNullOrEmpty(channel, nameof(channel)); - Guard.NotNullOrEmpty(eventType, nameof(eventType)); + Guard.NotNullOrEmpty(channel); + Guard.NotNullOrEmpty(eventType); Channel = channel; diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs index 9c6a03052..4a0c0d2bd 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/HistoryEventsCreatorBase.cs @@ -23,14 +23,14 @@ namespace Squidex.Domain.Apps.Entities.History protected HistoryEventsCreatorBase(TypeNameRegistry typeNameRegistry) { - Guard.NotNull(typeNameRegistry, nameof(typeNameRegistry)); + Guard.NotNull(typeNameRegistry); this.typeNameRegistry = typeNameRegistry; } protected void AddEventMessage(string message) where TEvent : IEvent { - Guard.NotNullOrEmpty(message, nameof(message)); + Guard.NotNullOrEmpty(message); texts[typeNameRegistry.GetName()] = message; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs b/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs index 5bc79bda7..356e2dd75 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs @@ -151,7 +151,7 @@ namespace Squidex.Domain.Apps.Entities.History public async Task HandleEventsAsync(IEnumerable<(Envelope AppEvent, HistoryEvent? HistoryEvent)> events) { - Guard.NotNull(events, nameof(events)); + Guard.NotNull(events); if (client == null) { @@ -270,7 +270,7 @@ namespace Squidex.Domain.Apps.Entities.History { var publishRequest = new PublishDto { - Properties = new EventProperties() + Properties = new NotificationProperties() }; foreach (var (key, value) in historyEvent.Parameters) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs b/backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs index 1b004ef41..eae211f56 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs @@ -57,8 +57,8 @@ namespace Squidex.Domain.Apps.Entities.Notifications public Task SendUsageAsync(IUser user, string appName, long usage, long usageLimit) { - Guard.NotNull(user, nameof(user)); - Guard.NotNull(appName, nameof(appName)); + Guard.NotNull(user); + Guard.NotNull(appName); var vars = new TemplatesVars { @@ -75,9 +75,9 @@ namespace Squidex.Domain.Apps.Entities.Notifications public Task SendInviteAsync(IUser assigner, IUser user, string appName) { - Guard.NotNull(assigner, nameof(assigner)); - Guard.NotNull(user, nameof(user)); - Guard.NotNull(appName, nameof(appName)); + Guard.NotNull(assigner); + Guard.NotNull(user); + Guard.NotNull(appName); var vars = new TemplatesVars { Assigner = assigner, AppName = appName }; diff --git a/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs b/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs index 1bfcca667..573041171 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/OperationContextBase.cs @@ -34,8 +34,8 @@ namespace Squidex.Domain.Apps.Entities protected OperationContextBase(IServiceProvider serviceProvider, Func snapshot) { - Guard.NotNull(serviceProvider, nameof(serviceProvider)); - Guard.NotNull(snapshot, nameof(snapshot)); + Guard.NotNull(serviceProvider); + Guard.NotNull(snapshot); this.serviceProvider = serviceProvider; this.snapshot = snapshot; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Q.cs b/backend/src/Squidex.Domain.Apps.Entities/Q.cs index 24d5f7da9..f9d0be308 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Q.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Q.cs @@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities public Q WithQuery(ClrQuery query) { - Guard.NotNull(query, nameof(query)); + Guard.NotNull(query); return this with { Query = query }; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs index dc070dcfc..7a2cd0083 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs @@ -15,7 +15,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards { public static Task CanCreate(CreateRule command, IAppProvider appProvider) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); return Validate.It(async e => { @@ -45,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards public static Task CanUpdate(UpdateRule command, IRuleEntity rule, IAppProvider appProvider) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); return Validate.It(async e => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs index 5714bd20a..da4cbdcf4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs @@ -25,8 +25,8 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards public static Task> ValidateAsync(DomainId appId, RuleTrigger trigger, IAppProvider appProvider) { - Guard.NotNull(trigger, nameof(trigger)); - Guard.NotNull(appProvider, nameof(appProvider)); + Guard.NotNull(trigger); + Guard.NotNull(appProvider); var visitor = new RuleTriggerValidator(x => appProvider.GetSchemaAsync(appId, x)); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleEnricher.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleEnricher.cs index b4383b9e0..bbc1e5891 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleEnricher.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Queries/RuleEnricher.cs @@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Queries public async Task EnrichAsync(IRuleEntity rule, Context context, CancellationToken ct) { - Guard.NotNull(rule, nameof(rule)); + Guard.NotNull(rule); var enriched = await EnrichAsync(Enumerable.Repeat(rule, 1), context, ct); @@ -37,8 +37,8 @@ namespace Squidex.Domain.Apps.Entities.Rules.Queries public async Task> EnrichAsync(IEnumerable rules, Context context, CancellationToken ct) { - Guard.NotNull(rules, nameof(rules)); - Guard.NotNull(context, nameof(context)); + Guard.NotNull(rules); + Guard.NotNull(context); using (Telemetry.Activities.StartActivity("RuleEnricher/EnrichAsync")) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs index 8d9a3478f..1621e98ad 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs @@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Rules public async Task EnqueueAsync(Rule rule, DomainId ruleId, Envelope @event) { - Guard.NotNull(rule, nameof(rule)); + Guard.NotNull(rule); Guard.NotNull(@event, nameof(@event)); var ruleContext = new RuleContext diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/DefaultRuleRunnerService.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/DefaultRuleRunnerService.cs index ac868fb78..c06e31561 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/DefaultRuleRunnerService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/DefaultRuleRunnerService.cs @@ -37,7 +37,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Runner public async Task> SimulateAsync(IRuleEntity rule, CancellationToken ct = default) { - Guard.NotNull(rule, nameof(rule)); + Guard.NotNull(rule); var context = new RuleContext { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs index 64885f247..63817260f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs @@ -19,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards { public static void CanCreate(CreateSchema command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanSynchronize(SynchronizeSchema command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanReorder(ReorderFields command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); IArrayField? arrayField = null; @@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanConfigurePreviewUrls(ConfigurePreviewUrls command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -86,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanConfigureUIFields(ConfigureUIFields command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -97,7 +97,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanConfigureFieldRules(ConfigureFieldRules command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs index ae145b0e8..ebd75073a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards { public static void CanAdd(AddField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); Validate.It(e => { @@ -64,7 +64,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanUpdate(UpdateField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); @@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanHide(HideField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); @@ -97,7 +97,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanDisable(DisableField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); @@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanShow(ShowField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); @@ -121,7 +121,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanEnable(EnableField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); @@ -133,14 +133,14 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards public static void CanDelete(DeleteField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); } public static void CanLock(LockField command, Schema schema) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, true); } 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 541b45f37..5d95d7de1 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 @@ -3,6 +3,7 @@ net6.0 10.0 enable + en enable @@ -19,19 +20,19 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers - - + + diff --git a/backend/src/Squidex.Domain.Apps.Entities/Tags/GrainTagService.cs b/backend/src/Squidex.Domain.Apps.Entities/Tags/GrainTagService.cs index 035290358..3ebb7873f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Tags/GrainTagService.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Tags/GrainTagService.cs @@ -22,29 +22,29 @@ namespace Squidex.Domain.Apps.Entities.Tags public Task RenameTagAsync(DomainId appId, string group, string name, string newName) { - Guard.NotNullOrEmpty(name, nameof(name)); - Guard.NotNullOrEmpty(newName, nameof(newName)); + Guard.NotNullOrEmpty(name); + Guard.NotNullOrEmpty(newName); return GetGrain(appId, group).RenameTagAsync(name, newName); } public Task RebuildTagsAsync(DomainId appId, string group, TagsExport export) { - Guard.NotNull(export, nameof(export)); + Guard.NotNull(export); return GetGrain(appId, group).RebuildAsync(export); } public Task> GetTagIdsAsync(DomainId appId, string group, HashSet names) { - Guard.NotNull(names, nameof(names)); + Guard.NotNull(names); return GetGrain(appId, group).GetTagIdsAsync(names); } public Task> DenormalizeTagsAsync(DomainId appId, string group, HashSet ids) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); return GetGrain(appId, group).DenormalizeTagsAsync(ids); } @@ -71,7 +71,7 @@ namespace Squidex.Domain.Apps.Entities.Tags private ITagGrain GetGrain(DomainId appId, string group) { - Guard.NotNullOrEmpty(group, nameof(group)); + Guard.NotNullOrEmpty(group); return grainFactory.GetGrain($"{appId}_{group}"); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs index 95aed177f..ad4be99c0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs @@ -45,8 +45,8 @@ namespace Squidex.Domain.Apps.Entities.Tags public Task RenameTagAsync(string name, string newName) { - Guard.NotNull(name, nameof(name)); - Guard.NotNull(newName, nameof(newName)); + Guard.NotNull(name); + Guard.NotNull(newName); name = NormalizeName(name); @@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.Tags public Task> GetTagIdsAsync(HashSet names) { - Guard.NotNull(names, nameof(names)); + Guard.NotNull(names); var result = new Dictionary(); 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 8dbc65d90..2635111ac 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 @@ -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 777a2d92a..0303d6236 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs +++ b/backend/src/Squidex.Domain.Users.MongoDb/MongoUser.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Identity; using MongoDB.Bson.Serialization.Attributes; using Squidex.Infrastructure; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Users.MongoDb { public sealed class MongoUser : IdentityUser 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 355b0905e..a535a50c8 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 @@ -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 a7a171483..55edc96a4 100644 --- a/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs +++ b/backend/src/Squidex.Domain.Users/DefaultUserResolver.cs @@ -27,7 +27,7 @@ namespace Squidex.Domain.Users public async Task<(IUser? User, bool Created)> CreateUserIfNotExistsAsync(string email, bool invited = false, CancellationToken ct = default) { - Guard.NotNullOrEmpty(email, nameof(email)); + Guard.NotNullOrEmpty(email); await using (var scope = serviceProvider.CreateAsyncScope()) { @@ -57,9 +57,9 @@ namespace Squidex.Domain.Users public async Task SetClaimAsync(string id, string type, string value, bool silent = false, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); - Guard.NotNullOrEmpty(type, nameof(type)); - Guard.NotNullOrEmpty(value, nameof(value)); + Guard.NotNullOrEmpty(id); + Guard.NotNullOrEmpty(type); + Guard.NotNullOrEmpty(value); await using (var scope = serviceProvider.CreateAsyncScope()) { @@ -80,7 +80,7 @@ namespace Squidex.Domain.Users public async Task FindByIdAsync(string id, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); await using (var scope = serviceProvider.CreateAsyncScope()) { @@ -93,7 +93,7 @@ namespace Squidex.Domain.Users public async Task FindByIdOrEmailAsync(string idOrEmail, CancellationToken ct = default) { - Guard.NotNullOrEmpty(idOrEmail, nameof(idOrEmail)); + Guard.NotNullOrEmpty(idOrEmail); await using (var scope = serviceProvider.CreateAsyncScope()) { @@ -139,7 +139,7 @@ namespace Squidex.Domain.Users public async Task> QueryManyAsync(string[] ids, CancellationToken ct = default) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); await using (var scope = serviceProvider.CreateAsyncScope()) { diff --git a/backend/src/Squidex.Domain.Users/DefaultUserService.cs b/backend/src/Squidex.Domain.Users/DefaultUserService.cs index 488c9629f..3b82563b5 100644 --- a/backend/src/Squidex.Domain.Users/DefaultUserService.cs +++ b/backend/src/Squidex.Domain.Users/DefaultUserService.cs @@ -44,7 +44,7 @@ namespace Squidex.Domain.Users public string GetUserId(ClaimsPrincipal user, CancellationToken ct = default) { - Guard.NotNull(user, nameof(user)); + Guard.NotNull(user); return userManager.GetUserId(user); } @@ -52,7 +52,7 @@ namespace Squidex.Domain.Users public async Task> QueryAsync(IEnumerable ids, CancellationToken ct = default) { - Guard.NotNull(ids, nameof(ids)); + Guard.NotNull(ids); ids = ids.Where(userFactory.IsId); @@ -71,8 +71,8 @@ namespace Squidex.Domain.Users public async Task> QueryAsync(string? query = null, int take = 10, int skip = 0, CancellationToken ct = default) { - Guard.GreaterThan(take, 0, nameof(take)); - Guard.GreaterEquals(skip, 0, nameof(skip)); + Guard.GreaterThan(take, 0); + Guard.GreaterEquals(skip, 0); IQueryable QueryUsers(string? email = null) { @@ -99,7 +99,7 @@ namespace Squidex.Domain.Users public Task> GetLoginsAsync(IUser user, CancellationToken ct = default) { - Guard.NotNull(user, nameof(user)); + Guard.NotNull(user); return userManager.GetLoginsAsync((IdentityUser)user.Identity); } @@ -107,7 +107,7 @@ namespace Squidex.Domain.Users public Task HasPasswordAsync(IUser user, CancellationToken ct = default) { - Guard.NotNull(user, nameof(user)); + Guard.NotNull(user); return userManager.HasPasswordAsync((IdentityUser)user.Identity); } @@ -115,7 +115,7 @@ namespace Squidex.Domain.Users public async Task FindByLoginAsync(string provider, string key, CancellationToken ct = default) { - Guard.NotNullOrEmpty(provider, nameof(provider)); + Guard.NotNullOrEmpty(provider); var user = await userManager.FindByLoginAsync(provider, key); @@ -125,7 +125,7 @@ namespace Squidex.Domain.Users public async Task FindByEmailAsync(string email, CancellationToken ct = default) { - Guard.NotNullOrEmpty(email, nameof(email)); + Guard.NotNullOrEmpty(email); var user = await userManager.FindByEmailAsync(email); @@ -135,7 +135,7 @@ namespace Squidex.Domain.Users public async Task GetAsync(ClaimsPrincipal principal, CancellationToken ct = default) { - Guard.NotNull(principal, nameof(principal)); + Guard.NotNull(principal); var user = await userManager.GetUserAsync(principal); @@ -158,7 +158,7 @@ namespace Squidex.Domain.Users public async Task CreateAsync(string email, UserValues? values = null, bool lockAutomatically = false, CancellationToken ct = default) { - Guard.NotNullOrEmpty(email, nameof(email)); + Guard.NotNullOrEmpty(email); var isFirst = !userManager.Users.Any(); @@ -236,7 +236,7 @@ namespace Squidex.Domain.Users public Task SetPasswordAsync(string id, string password, string? oldPassword = null, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); return ForUserAsync(id, async user => { @@ -254,8 +254,8 @@ namespace Squidex.Domain.Users public async Task UpdateAsync(string id, UserValues values, bool silent = false, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); - Guard.NotNull(values, nameof(values)); + Guard.NotNullOrEmpty(id); + Guard.NotNull(values); var user = await GetUserAsync(id); @@ -303,7 +303,7 @@ namespace Squidex.Domain.Users public Task LockAsync(string id, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); return ForUserAsync(id, user => userManager.SetLockoutEndDateAsync(user, LockoutDate()).Throw(log)); } @@ -311,7 +311,7 @@ namespace Squidex.Domain.Users public Task UnlockAsync(string id, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); return ForUserAsync(id, user => userManager.SetLockoutEndDateAsync(user, null).Throw(log)); } @@ -319,7 +319,7 @@ namespace Squidex.Domain.Users public Task AddLoginAsync(string id, ExternalLoginInfo externalLogin, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); return ForUserAsync(id, user => userManager.AddLoginAsync(user, externalLogin).Throw(log)); } @@ -327,7 +327,7 @@ namespace Squidex.Domain.Users public Task RemoveLoginAsync(string id, string loginProvider, string providerKey, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); return ForUserAsync(id, user => userManager.RemoveLoginAsync(user, loginProvider, providerKey).Throw(log)); } @@ -335,7 +335,7 @@ namespace Squidex.Domain.Users public async Task DeleteAsync(string id, CancellationToken ct = default) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); var user = await GetUserAsync(id); diff --git a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj index 9cfda87bf..85d79ac66 100644 --- a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj +++ b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj @@ -17,12 +17,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs index a0d2ba21a..664139e92 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs +++ b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs @@ -48,7 +48,7 @@ namespace Squidex.Infrastructure.EventSourcing public IEventSubscription CreateSubscription(IEventSubscriber subscriber, string? streamFilter = null, string? position = null) { - Guard.NotNull(streamFilter, nameof(streamFilter)); + Guard.NotNull(streamFilter); return new GetEventStoreSubscription(subscriber, client, projectionClient, serializer, position, StreamPrefix, streamFilter); } @@ -92,7 +92,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task> QueryReverseAsync(string streamName, int count = int.MaxValue, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); if (count <= 0) { @@ -117,7 +117,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task> QueryAsync(string streamName, long streamPosition = 0, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); using (Telemetry.Activities.StartActivity("GetEventStore/QueryAsync")) { @@ -165,7 +165,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task DeleteStreamAsync(string streamName, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); await client.SoftDeleteAsync(GetStreamName(streamName), StreamState.Any, cancellationToken: ct); } @@ -179,7 +179,7 @@ namespace Squidex.Infrastructure.EventSourcing public Task AppendAsync(Guid commitId, string streamName, long expectedVersion, ICollection events, CancellationToken ct = default) { - Guard.GreaterEquals(expectedVersion, -1, nameof(expectedVersion)); + Guard.GreaterEquals(expectedVersion, -1); return AppendEventsInternalAsync(streamName, expectedVersion, events, ct); } @@ -187,8 +187,8 @@ namespace Squidex.Infrastructure.EventSourcing private async Task AppendEventsInternalAsync(string streamName, long expectedVersion, ICollection events, CancellationToken ct) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); - Guard.NotNull(events, nameof(events)); + Guard.NotNullOrEmpty(streamName); + Guard.NotNull(events); using (Telemetry.Activities.StartActivity("GetEventStore/AppendEventsInternalAsync")) { diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj index 8b715c375..d111ed3d7 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj +++ b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj @@ -14,8 +14,8 @@ - - + + 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 d6854c172..50d98576a 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs @@ -11,6 +11,8 @@ using NodaTime; using Squidex.Infrastructure.MongoDb; using EventFilter = MongoDB.Driver.FilterDefinition; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.EventSourcing { public delegate bool EventPredicate(MongoEvent data); @@ -21,7 +23,7 @@ namespace Squidex.Infrastructure.EventSourcing public IEventSubscription CreateSubscription(IEventSubscriber subscriber, string? streamFilter = null, string? position = null) { - Guard.NotNull(subscriber, nameof(subscriber)); + Guard.NotNull(subscriber); if (CanUseChangeStreams) { @@ -36,7 +38,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task> QueryReverseAsync(string streamName, int count = int.MaxValue, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); if (count <= 0) { @@ -60,7 +62,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task> QueryAsync(string streamName, long streamPosition = 0, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); using (Telemetry.Activities.StartActivity("MongoEventStore/QueryAsync")) { @@ -82,7 +84,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task>> QueryManyAsync(IEnumerable streamNames, CancellationToken ct = default) { - Guard.NotNull(streamNames, nameof(streamNames)); + Guard.NotNull(streamNames); using (Telemetry.Activities.StartActivity("MongoEventStore/QueryManyAsync")) { diff --git a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs index 86fcdc31d..5a44dc482 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Writer.cs @@ -8,6 +8,8 @@ using MongoDB.Bson; using MongoDB.Driver; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.EventSourcing { public partial class MongoEventStore @@ -19,7 +21,7 @@ namespace Squidex.Infrastructure.EventSourcing public Task DeleteStreamAsync(string streamName, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamName, nameof(streamName)); + Guard.NotNullOrEmpty(streamName); return Collection.DeleteManyAsync(x => x.EventStream == streamName, ct); } @@ -27,7 +29,7 @@ namespace Squidex.Infrastructure.EventSourcing public Task DeleteAsync(string streamFilter, CancellationToken ct = default) { - Guard.NotNullOrEmpty(streamFilter, nameof(streamFilter)); + Guard.NotNullOrEmpty(streamFilter); return Collection.DeleteManyAsync(FilterExtensions.ByStream(streamFilter), ct); } @@ -41,10 +43,10 @@ namespace Squidex.Infrastructure.EventSourcing public async Task AppendAsync(Guid commitId, string streamName, long expectedVersion, ICollection events, CancellationToken ct = default) { - Guard.NotEmpty(commitId, nameof(commitId)); - Guard.NotNullOrEmpty(streamName, nameof(streamName)); - Guard.NotNull(events, nameof(events)); - Guard.GreaterEquals(expectedVersion, EtagVersion.Any, nameof(expectedVersion)); + Guard.NotEmpty(commitId); + Guard.NotNullOrEmpty(streamName); + Guard.NotNull(events); + Guard.GreaterEquals(expectedVersion, EtagVersion.Any); using (Telemetry.Activities.StartActivity("ContentQueryService/AppendAsync")) { @@ -107,7 +109,7 @@ namespace Squidex.Infrastructure.EventSourcing public async Task AppendUnsafeAsync(IEnumerable commits, CancellationToken ct = default) { - Guard.NotNull(commits, nameof(commits)); + Guard.NotNull(commits); using (Telemetry.Activities.StartActivity("ContentQueryService/AppendUnsafeAsync")) { diff --git a/backend/src/Squidex.Infrastructure.MongoDb/Log/MongoRequestLogRepository.cs b/backend/src/Squidex.Infrastructure.MongoDb/Log/MongoRequestLogRepository.cs index 0d5378ba2..e92ec8489 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/Log/MongoRequestLogRepository.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/Log/MongoRequestLogRepository.cs @@ -19,7 +19,7 @@ namespace Squidex.Infrastructure.Log public MongoRequestLogRepository(IMongoDatabase database, IOptions options) : base(database) { - Guard.NotNull(options, nameof(options)); + Guard.NotNull(options); this.options = options.Value; } @@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.Log public Task InsertManyAsync(IEnumerable items, CancellationToken ct = default) { - Guard.NotNull(items, nameof(items)); + Guard.NotNull(items); var entities = items.Select(MongoRequest.FromRequest).ToList(); @@ -66,7 +66,7 @@ namespace Squidex.Infrastructure.Log public Task DeleteAsync(string key, CancellationToken ct = default) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); return Collection.DeleteManyAsync(Filter.Eq(x => x.Key, key), ct); } @@ -74,7 +74,7 @@ namespace Squidex.Infrastructure.Log public IAsyncEnumerable QueryAllAsync(string key, DateTime fromDate, DateTime toDate, CancellationToken ct = default) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); var timestampStart = Instant.FromDateTimeUtc(fromDate); var timestampEnd = Instant.FromDateTimeUtc(toDate.AddDays(1)); diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonReader.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonReader.cs index ae9bd5697..fcb03602b 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonReader.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonReader.cs @@ -18,7 +18,7 @@ namespace Squidex.Infrastructure.MongoDb public BsonJsonReader(IBsonReader bsonReader) { - Guard.NotNull(bsonReader, nameof(bsonReader)); + Guard.NotNull(bsonReader); this.bsonReader = bsonReader; } diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonSerializer.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonSerializer.cs index d92be529c..e0263e9ae 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonSerializer.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonSerializer.cs @@ -18,7 +18,7 @@ namespace Squidex.Infrastructure.MongoDb public BsonJsonSerializer(JsonSerializer serializer) { - Guard.NotNull(serializer, nameof(serializer)); + Guard.NotNull(serializer); this.serializer = serializer; } diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonWriter.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonWriter.cs index 67812bb66..a5452246e 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonWriter.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/BsonJsonWriter.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure.MongoDb public BsonJsonWriter(IBsonWriter bsonWriter) { - Guard.NotNull(bsonWriter, nameof(bsonWriter)); + Guard.NotNull(bsonWriter); this.bsonWriter = bsonWriter; } diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs index b162cfa3a..30782fd12 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs @@ -61,7 +61,7 @@ namespace Squidex.Infrastructure.MongoDb protected MongoRepositoryBase(IMongoDatabase database, bool setup = false) { - Guard.NotNull(database, nameof(database)); + Guard.NotNull(database); mongoDatabase = database; diff --git a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj index 2d3178a0f..1754a5e93 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj +++ b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj @@ -14,7 +14,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStoreBase.cs b/backend/src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStoreBase.cs index 686f8d6b3..f5bd670f8 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStoreBase.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStoreBase.cs @@ -22,7 +22,7 @@ namespace Squidex.Infrastructure.States private static bool Register(JsonSerializer jsonSerializer) { - Guard.NotNull(jsonSerializer, nameof(jsonSerializer)); + Guard.NotNull(jsonSerializer); BsonJsonConvention.Register(jsonSerializer); diff --git a/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs b/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs index 958087d8a..3f2dd6365 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs @@ -37,7 +37,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task DeleteAsync(string key, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return Collection.DeleteManyAsync(x => x.Key == key, ct); } @@ -45,7 +45,7 @@ namespace Squidex.Infrastructure.UsageTracking public async Task TrackUsagesAsync(UsageUpdate update, CancellationToken ct = default) { - Guard.NotNull(update, nameof(update)); + Guard.NotNull(update); if (update.Counters.Count > 0) { @@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.UsageTracking public async Task TrackUsagesAsync(UsageUpdate[] updates, CancellationToken ct = default) { - Guard.NotNull(updates, nameof(updates)); + Guard.NotNull(updates); if (updates.Length == 1) { diff --git a/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj b/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj index bec914e0b..311343fab 100644 --- a/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj +++ b/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj @@ -11,7 +11,7 @@ True - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs b/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs index 5fee1d59c..ba21aa4a8 100644 --- a/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs +++ b/backend/src/Squidex.Infrastructure/Collections/ReadonlyDictionary{TKey,TValue}.cs @@ -50,7 +50,7 @@ namespace Squidex.Infrastructure.Collections public ReadonlyDictionary(IDictionary inner) { - Guard.NotNull(inner, nameof(inner)); + Guard.NotNull(inner); this.inner = inner; } diff --git a/backend/src/Squidex.Infrastructure/Commands/CommandContext.cs b/backend/src/Squidex.Infrastructure/Commands/CommandContext.cs index 0aaedaf9a..71ce7bf65 100644 --- a/backend/src/Squidex.Infrastructure/Commands/CommandContext.cs +++ b/backend/src/Squidex.Infrastructure/Commands/CommandContext.cs @@ -24,8 +24,8 @@ namespace Squidex.Infrastructure.Commands public CommandContext(ICommand command, ICommandBus commandBus) { - Guard.NotNull(command, nameof(command)); - Guard.NotNull(commandBus, nameof(commandBus)); + Guard.NotNull(command); + Guard.NotNull(commandBus); Command = command; CommandBus = commandBus; diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObject.Execute.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObject.Execute.cs index f3f55b06b..e664c4e46 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObject.Execute.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObject.Execute.cs @@ -118,7 +118,7 @@ namespace Squidex.Infrastructure.Commands protected async Task Upsert(TCommand command, Action handler) where TCommand : ICommand { - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(handler); return await UpsertAsync(command, x => { @@ -130,7 +130,7 @@ namespace Squidex.Infrastructure.Commands protected async Task DeletePermanentAsync(TCommand command, Func handler) where TCommand : ICommand { - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(handler); await EnsureCanDeleteAsync(command); @@ -144,7 +144,7 @@ namespace Squidex.Infrastructure.Commands protected async Task DeletePermanent(TCommand command, Action handler) where TCommand : ICommand { - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(handler); return await DeletePermanentAsync(command, x => { @@ -156,7 +156,7 @@ namespace Squidex.Infrastructure.Commands private void EnsureCanCreate(TCommand command) where TCommand : ICommand { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); if (Version != EtagVersion.Empty && !(IsDeleted(Snapshot) && CanRecreate())) { @@ -169,7 +169,7 @@ namespace Squidex.Infrastructure.Commands private async Task EnsureCanUpdateAsync(TCommand command) where TCommand : ICommand { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); await EnsureLoadedAsync(); @@ -182,7 +182,7 @@ namespace Squidex.Infrastructure.Commands private async Task EnsureCanUpsertAsync(TCommand command) where TCommand : ICommand { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); await EnsureLoadedAsync(); @@ -205,7 +205,7 @@ namespace Squidex.Infrastructure.Commands private async Task EnsureCanDeleteAsync(TCommand command) where TCommand : ICommand { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); await EnsureLoadedAsync(); diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs index 56d455ae5..d0ccda6e4 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs @@ -44,8 +44,8 @@ namespace Squidex.Infrastructure.Commands protected DomainObject(IPersistenceFactory factory, ISemanticLog log) { - Guard.NotNull(factory, nameof(factory)); - Guard.NotNull(log, nameof(log)); + Guard.NotNull(factory); + Guard.NotNull(log); this.factory = factory; @@ -163,7 +163,7 @@ namespace Squidex.Infrastructure.Commands private async Task DeleteCoreAsync(TCommand command, Func> handler) where TCommand : ICommand { - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(handler); var previousSnapshot = Snapshot; var previousVersion = Version; @@ -206,7 +206,7 @@ namespace Squidex.Infrastructure.Commands private async Task UpsertCoreAsync(TCommand command, Func> handler, bool isCreation = false) where TCommand : ICommand { - Guard.NotNull(handler, nameof(handler)); + Guard.NotNull(handler); var wasDeleted = IsDeleted(Snapshot); diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs index a237a39fe..f8ae1f87c 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs @@ -26,7 +26,7 @@ namespace Squidex.Infrastructure.Commands protected DomainObjectGrain(IServiceProvider serviceProvider) { - Guard.NotNull(serviceProvider, nameof(serviceProvider)); + Guard.NotNull(serviceProvider); domainObject = serviceProvider.GetRequiredService(); } diff --git a/backend/src/Squidex.Infrastructure/Commands/ICommandMiddleware.cs b/backend/src/Squidex.Infrastructure/Commands/ICommandMiddleware.cs index 0794f48c3..5bdb61ad7 100644 --- a/backend/src/Squidex.Infrastructure/Commands/ICommandMiddleware.cs +++ b/backend/src/Squidex.Infrastructure/Commands/ICommandMiddleware.cs @@ -5,6 +5,8 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.Commands { public delegate Task NextDelegate(CommandContext context); diff --git a/backend/src/Squidex.Infrastructure/Commands/InMemoryCommandBus.cs b/backend/src/Squidex.Infrastructure/Commands/InMemoryCommandBus.cs index 72c3cbf21..266ec7d0d 100644 --- a/backend/src/Squidex.Infrastructure/Commands/InMemoryCommandBus.cs +++ b/backend/src/Squidex.Infrastructure/Commands/InMemoryCommandBus.cs @@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.Commands public async Task PublishAsync(ICommand command) { - Guard.NotNull(command, nameof(command)); + Guard.NotNull(command); var context = new CommandContext(command, this); diff --git a/backend/src/Squidex.Infrastructure/Commands/Rebuilder.cs b/backend/src/Squidex.Infrastructure/Commands/Rebuilder.cs index 34fc891e9..7b673d3e4 100644 --- a/backend/src/Squidex.Infrastructure/Commands/Rebuilder.cs +++ b/backend/src/Squidex.Infrastructure/Commands/Rebuilder.cs @@ -75,7 +75,7 @@ namespace Squidex.Infrastructure.Commands CancellationToken ct = default) where T : DomainObject where TState : class, IDomainState, new() { - Guard.NotNull(source, nameof(source)); + Guard.NotNull(source); var ids = source.ToAsyncEnumerable(); diff --git a/backend/src/Squidex.Infrastructure/DomainObjectException.cs b/backend/src/Squidex.Infrastructure/DomainObjectException.cs index 21702ba5a..eb5078347 100644 --- a/backend/src/Squidex.Infrastructure/DomainObjectException.cs +++ b/backend/src/Squidex.Infrastructure/DomainObjectException.cs @@ -17,7 +17,7 @@ namespace Squidex.Infrastructure public DomainObjectException(string message, string id, string errorCode, Exception? inner = null) : base(message, errorCode, inner) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); Id = id; } diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/DefaultEventDataFormatter.cs b/backend/src/Squidex.Infrastructure/EventSourcing/DefaultEventDataFormatter.cs index f54eb1193..1ba5cc0b5 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/DefaultEventDataFormatter.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/DefaultEventDataFormatter.cs @@ -38,7 +38,7 @@ namespace Squidex.Infrastructure.EventSourcing public Envelope Parse(StoredEvent storedEvent) { - Guard.NotNull(storedEvent, nameof(storedEvent)); + Guard.NotNull(storedEvent); var eventData = storedEvent.Data; diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs index 4276b2630..f5049aa91 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs @@ -24,7 +24,7 @@ namespace Squidex.Infrastructure.EventSourcing public Envelope(T payload, EnvelopeHeaders? headers = null) { - Guard.NotNull(payload, nameof(payload)); + Guard.NotNull(payload); this.payload = payload; diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs b/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs index 2d21220b8..a34c3f6ea 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs @@ -1,10 +1,12 @@ -// ========================================================================== +// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.EventSourcing { public delegate IEventConsumer EventConsumerFactory(string name); @@ -42,4 +44,4 @@ namespace Squidex.Infrastructure.EventSourcing } } } -} \ No newline at end of file +} diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/RetrySubscription.cs b/backend/src/Squidex.Infrastructure/EventSourcing/RetrySubscription.cs index 545a56761..7e6d2e325 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/RetrySubscription.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/RetrySubscription.cs @@ -22,8 +22,8 @@ namespace Squidex.Infrastructure.EventSourcing public RetrySubscription(IEventSubscriber eventSubscriber, Func eventSubscriptionFactory) { - Guard.NotNull(eventSubscriber, nameof(eventSubscriber)); - Guard.NotNull(eventSubscriptionFactory, nameof(eventSubscriptionFactory)); + Guard.NotNull(eventSubscriber); + Guard.NotNull(eventSubscriptionFactory); this.eventSubscriber = eventSubscriber; this.eventSubscriptionFactory = eventSubscriptionFactory; diff --git a/backend/src/Squidex.Infrastructure/Guard.cs b/backend/src/Squidex.Infrastructure/Guard.cs index 06ef832f9..72bd375e0 100644 --- a/backend/src/Squidex.Infrastructure/Guard.cs +++ b/backend/src/Squidex.Infrastructure/Guard.cs @@ -16,7 +16,8 @@ namespace Squidex.Infrastructure { [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ValidNumber(float target, string parameterName) + public static void ValidNumber(float target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (float.IsNaN(target) || float.IsPositiveInfinity(target) || float.IsNegativeInfinity(target)) { @@ -26,7 +27,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ValidNumber(double target, string parameterName) + public static void ValidNumber(double target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (double.IsNaN(target) || double.IsPositiveInfinity(target) || double.IsNegativeInfinity(target)) { @@ -36,7 +38,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ValidSlug(string? target, string parameterName) + public static void ValidSlug(string? target, + [CallerArgumentExpression("target")] string? parameterName = null) { NotNullOrEmpty(target, parameterName); @@ -48,7 +51,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ValidPropertyName(string? target, string parameterName) + public static void ValidPropertyName(string? target, + [CallerArgumentExpression("target")] string? parameterName = null) { NotNullOrEmpty(target, parameterName); @@ -60,7 +64,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasType(object? target, string parameterName) + public static void HasType(object? target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (target != null && target.GetType() != typeof(T)) { @@ -70,7 +75,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasType(object? target, Type? expectedType, string parameterName) + public static void HasType(object? target, Type? expectedType, + [CallerArgumentExpression("target")] string? parameterName = null) { if (target != null && expectedType != null && target.GetType() != expectedType) { @@ -80,7 +86,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Between(TValue target, TValue lower, TValue upper, string parameterName) where TValue : IComparable + public static void Between(TValue target, TValue lower, TValue upper, + [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable { if (!target.IsBetween(lower, upper)) { @@ -90,7 +97,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Enum(TEnum target, string parameterName) where TEnum : struct + public static void Enum(TEnum target, + [CallerArgumentExpression("target")] string? parameterName = null) where TEnum : struct { if (!target.IsEnumValue()) { @@ -100,7 +108,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void GreaterThan(TValue target, TValue lower, string parameterName) where TValue : IComparable + public static void GreaterThan(TValue target, TValue lower, + [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(lower) <= 0) { @@ -110,7 +119,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void GreaterEquals(TValue target, TValue lower, string parameterName) where TValue : IComparable + public static void GreaterEquals(TValue target, TValue lower, + [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(lower) < 0) { @@ -120,7 +130,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void LessThan(TValue target, TValue upper, string parameterName) where TValue : IComparable + public static void LessThan(TValue target, TValue upper, + [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(upper) >= 0) { @@ -130,7 +141,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void LessEquals(TValue target, TValue upper, string parameterName) where TValue : IComparable + public static void LessEquals(TValue target, TValue upper, + [CallerArgumentExpression("target")] string? parameterName = null) where TValue : IComparable { if (target.CompareTo(upper) > 0) { @@ -140,7 +152,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotEmpty(IReadOnlyCollection? target, string parameterName) + public static void NotEmpty(IReadOnlyCollection? target, + [CallerArgumentExpression("target")] string? parameterName = null) { NotNull(target, parameterName); @@ -152,7 +165,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotEmpty(Guid target, string parameterName) + public static void NotEmpty(Guid target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (target == Guid.Empty) { @@ -162,7 +176,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotEmpty(DomainId target, string parameterName) + public static void NotEmpty(DomainId target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (target == DomainId.Empty) { @@ -172,7 +187,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotNull(object? target, string parameterName) + public static void NotNull(object? target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (target == null) { @@ -182,7 +198,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotDefault(T target, string parameterName) + public static void NotDefault(T target, + [CallerArgumentExpression("target")] string? parameterName = null) { if (Equals(target, default(T)!)) { @@ -192,7 +209,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void NotNullOrEmpty(string? target, string parameterName) + public static void NotNullOrEmpty(string? target, + [CallerArgumentExpression("target")] string? parameterName = null) { NotNull(target, parameterName); @@ -204,7 +222,8 @@ namespace Squidex.Infrastructure [DebuggerStepThrough] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ValidFileName(string? target, string parameterName) + public static void ValidFileName(string? target, + [CallerArgumentExpression("target")] string? parameterName = null) { NotNullOrEmpty(target, parameterName); diff --git a/backend/src/Squidex.Infrastructure/Json/ClaimsPrincipalSurrogate.cs b/backend/src/Squidex.Infrastructure/Json/ClaimsPrincipalSurrogate.cs index b293a4314..94652c7f1 100644 --- a/backend/src/Squidex.Infrastructure/Json/ClaimsPrincipalSurrogate.cs +++ b/backend/src/Squidex.Infrastructure/Json/ClaimsPrincipalSurrogate.cs @@ -7,6 +7,8 @@ using System.Security.Claims; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.Json { public sealed class ClaimsPrincipalSurrogate : List, ISurrogate diff --git a/backend/src/Squidex.Infrastructure/Json/Newtonsoft/NewtonsoftJsonSerializer.cs b/backend/src/Squidex.Infrastructure/Json/Newtonsoft/NewtonsoftJsonSerializer.cs index 7c777ad80..59ec5fc2c 100644 --- a/backend/src/Squidex.Infrastructure/Json/Newtonsoft/NewtonsoftJsonSerializer.cs +++ b/backend/src/Squidex.Infrastructure/Json/Newtonsoft/NewtonsoftJsonSerializer.cs @@ -17,7 +17,7 @@ namespace Squidex.Infrastructure.Json.Newtonsoft public NewtonsoftJsonSerializer(JsonSerializerSettings settings) { - Guard.NotNull(settings, nameof(settings)); + Guard.NotNull(settings); this.settings = settings; diff --git a/backend/src/Squidex.Infrastructure/Json/Objects/JsonArray.cs b/backend/src/Squidex.Infrastructure/Json/Objects/JsonArray.cs index 9b8a09808..52f0d678e 100644 --- a/backend/src/Squidex.Infrastructure/Json/Objects/JsonArray.cs +++ b/backend/src/Squidex.Infrastructure/Json/Objects/JsonArray.cs @@ -104,7 +104,7 @@ namespace Squidex.Infrastructure.Json.Objects public bool TryGet(string pathSegment, [MaybeNullWhen(false)] out IJsonValue result) { - Guard.NotNull(pathSegment, nameof(pathSegment)); + Guard.NotNull(pathSegment); if (pathSegment != null && int.TryParse(pathSegment, NumberStyles.Integer, CultureInfo.InvariantCulture, out var index) && index >= 0 && index < Count) { diff --git a/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs b/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs index 462badcea..2bef80079 100644 --- a/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs +++ b/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs @@ -22,7 +22,7 @@ namespace Squidex.Infrastructure.Json.Objects } set { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); inner[key] = value ?? JsonValue.Null; } @@ -60,14 +60,14 @@ namespace Squidex.Infrastructure.Json.Objects public JsonObject(JsonObject obj) { - Guard.NotNull(obj, nameof(obj)); + Guard.NotNull(obj); inner = new Dictionary(obj.inner); } public JsonObject(Dictionary source) { - Guard.NotNull(source, nameof(source)); + Guard.NotNull(source); inner = source; } @@ -165,7 +165,7 @@ namespace Squidex.Infrastructure.Json.Objects public bool TryGet(string pathSegment, [MaybeNullWhen(false)] out IJsonValue result) { - Guard.NotNull(pathSegment, nameof(pathSegment)); + Guard.NotNull(pathSegment); return TryGetValue(pathSegment, out result!); } diff --git a/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs b/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs index 147fbbe6e..bff46f454 100644 --- a/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs +++ b/backend/src/Squidex.Infrastructure/Json/Objects/JsonValue.cs @@ -134,7 +134,7 @@ namespace Squidex.Infrastructure.Json.Objects public static IJsonValue Create(double value) { - Guard.ValidNumber(value, nameof(value)); + Guard.ValidNumber(value); if (value == 0) { diff --git a/backend/src/Squidex.Infrastructure/Language.cs b/backend/src/Squidex.Infrastructure/Language.cs index 04a0d5a66..45931a7b9 100644 --- a/backend/src/Squidex.Infrastructure/Language.cs +++ b/backend/src/Squidex.Infrastructure/Language.cs @@ -18,7 +18,7 @@ namespace Squidex.Infrastructure public static Language GetLanguage(string iso2Code) { - Guard.NotNullOrEmpty(iso2Code, nameof(iso2Code)); + Guard.NotNullOrEmpty(iso2Code); if (LanguageByCode.TryGetValue(iso2Code, out var result)) { @@ -52,14 +52,14 @@ namespace Squidex.Infrastructure public static bool IsDefault(string iso2Code) { - Guard.NotNull(iso2Code, nameof(iso2Code)); + Guard.NotNull(iso2Code); return LanguageByCode.ContainsKey(iso2Code); } public static bool TryGetLanguage(string iso2Code, [MaybeNullWhen(false)] out Language language) { - Guard.NotNull(iso2Code, nameof(iso2Code)); + Guard.NotNull(iso2Code); return LanguageByCode.TryGetValue(iso2Code, out language!); } diff --git a/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs b/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs index 818222d45..4803593dd 100644 --- a/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs +++ b/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure public LanguagesInitializer(IOptions options) { - Guard.NotNull(options, nameof(options)); + Guard.NotNull(options); this.options = options.Value; } diff --git a/backend/src/Squidex.Infrastructure/Log/BackgroundRequestLogStore.cs b/backend/src/Squidex.Infrastructure/Log/BackgroundRequestLogStore.cs index 931668ebd..3e6f6e7b6 100644 --- a/backend/src/Squidex.Infrastructure/Log/BackgroundRequestLogStore.cs +++ b/backend/src/Squidex.Infrastructure/Log/BackgroundRequestLogStore.cs @@ -110,7 +110,7 @@ namespace Squidex.Infrastructure.Log public Task LogAsync(Request request, CancellationToken ct = default) { - Guard.NotNull(request, nameof(request)); + Guard.NotNull(request); if (!IsEnabled) { diff --git a/backend/src/Squidex.Infrastructure/NamedId{T}.cs b/backend/src/Squidex.Infrastructure/NamedId{T}.cs index 57bee14bf..be4fb9c6c 100644 --- a/backend/src/Squidex.Infrastructure/NamedId{T}.cs +++ b/backend/src/Squidex.Infrastructure/NamedId{T}.cs @@ -8,6 +8,8 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure { public delegate bool Parser(ReadOnlySpan input, out T result); @@ -23,8 +25,8 @@ namespace Squidex.Infrastructure public NamedId(T id, string name) { - Guard.NotNull(id, nameof(id)); - Guard.NotNull(name, nameof(name)); + Guard.NotNull(id); + Guard.NotNull(name); Id = id; diff --git a/backend/src/Squidex.Infrastructure/Orleans/ActivationLimiter.cs b/backend/src/Squidex.Infrastructure/Orleans/ActivationLimiter.cs index 78061baad..4fb01c4ab 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/ActivationLimiter.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/ActivationLimiter.cs @@ -55,7 +55,7 @@ namespace Squidex.Infrastructure.Orleans public void Register(Type grainType, IDeactivater deactivater, int maxActivations) { - var byType = instances.GetOrAdd(grainType, t => new LastUsedInstances(maxActivations)); + var byType = instances.GetOrAdd(grainType, maxActivations, (t, a) => new LastUsedInstances(a)); byType.Register(deactivater); } diff --git a/backend/src/Squidex.Infrastructure/Orleans/GrainBootstrap.cs b/backend/src/Squidex.Infrastructure/Orleans/GrainBootstrap.cs index e082e3093..e7d8a949e 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/GrainBootstrap.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/GrainBootstrap.cs @@ -20,7 +20,7 @@ namespace Squidex.Infrastructure.Orleans public GrainBootstrap(IGrainFactory grainFactory) { - Guard.NotNull(grainFactory, nameof(grainFactory)); + Guard.NotNull(grainFactory); this.grainFactory = grainFactory; } diff --git a/backend/src/Squidex.Infrastructure/Orleans/GrainState.cs b/backend/src/Squidex.Infrastructure/Orleans/GrainState.cs index 786acc6af..4ac42a7c0 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/GrainState.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/GrainState.cs @@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.Orleans public GrainState(IGrainActivationContext context) { - Guard.NotNull(context, nameof(context)); + Guard.NotNull(context); this.context = context; diff --git a/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs b/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs index 923504bc0..0cd780553 100644 --- a/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs +++ b/backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs @@ -32,8 +32,8 @@ namespace Squidex.Infrastructure.Plugins public Assembly? Load(string path, AssemblyName[] sharedAssemblies) { - Guard.NotNullOrEmpty(path, nameof(path)); - Guard.NotNull(sharedAssemblies, nameof(sharedAssemblies)); + Guard.NotNullOrEmpty(path); + Guard.NotNull(sharedAssemblies); Assembly? assembly = null; @@ -93,8 +93,8 @@ namespace Squidex.Infrastructure.Plugins public void ConfigureServices(IServiceCollection services, IConfiguration config) { - Guard.NotNull(services, nameof(services)); - Guard.NotNull(config, nameof(config)); + Guard.NotNull(services); + Guard.NotNull(config); foreach (var plugin in loadedPlugins) { @@ -104,7 +104,7 @@ namespace Squidex.Infrastructure.Plugins public void Log(ISemanticLog log) { - Guard.NotNull(log, nameof(log)); + Guard.NotNull(log); if (loadedPlugins.Count > 0 || exceptions.Count > 0) { diff --git a/backend/src/Squidex.Infrastructure/Queries/SortNode.cs b/backend/src/Squidex.Infrastructure/Queries/SortNode.cs index fa4e47919..174bb7c22 100644 --- a/backend/src/Squidex.Infrastructure/Queries/SortNode.cs +++ b/backend/src/Squidex.Infrastructure/Queries/SortNode.cs @@ -15,8 +15,8 @@ namespace Squidex.Infrastructure.Queries public SortNode(PropertyPath path, SortOrder order) { - Guard.NotNull(path, nameof(path)); - Guard.Enum(order, nameof(order)); + Guard.NotNull(path); + Guard.Enum(order); Path = path; diff --git a/backend/src/Squidex.Infrastructure/RefToken.cs b/backend/src/Squidex.Infrastructure/RefToken.cs index 717e7d8b4..e07002290 100644 --- a/backend/src/Squidex.Infrastructure/RefToken.cs +++ b/backend/src/Squidex.Infrastructure/RefToken.cs @@ -31,7 +31,7 @@ namespace Squidex.Infrastructure public RefToken(RefTokenType type, string identifier) { - Guard.NotNullOrEmpty(identifier, nameof(identifier)); + Guard.NotNullOrEmpty(identifier); Type = type; diff --git a/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs b/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs index 5727bd43f..15e25b5c3 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/Internal/PropertyAccessor.cs @@ -59,8 +59,8 @@ namespace Squidex.Infrastructure.Reflection.Internal public PropertyAccessor(Type targetType, PropertyInfo propertyInfo) { - Guard.NotNull(targetType, nameof(targetType)); - Guard.NotNull(propertyInfo, nameof(propertyInfo)); + Guard.NotNull(targetType); + Guard.NotNull(propertyInfo); var type = typeof(PropertyWrapper<,>).MakeGenericType(propertyInfo.DeclaringType!, propertyInfo.PropertyType); @@ -69,14 +69,14 @@ namespace Squidex.Infrastructure.Reflection.Internal public object? Get(object target) { - Guard.NotNull(target, nameof(target)); + Guard.NotNull(target); return internalAccessor.Get(target); } public void Set(object target, object? value) { - Guard.NotNull(target, nameof(target)); + Guard.NotNull(target); internalAccessor.Set(target, value); } diff --git a/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs b/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs index dc1e1190b..8412a1fb6 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/SimpleMapper.cs @@ -176,9 +176,9 @@ namespace Squidex.Infrastructure.Reflection where TSource : class where TTarget : class { - Guard.NotNull(source, nameof(source)); - Guard.NotNull(culture, nameof(culture)); - Guard.NotNull(target, nameof(target)); + Guard.NotNull(source); + Guard.NotNull(culture); + Guard.NotNull(target); return ClassMapper.MapClass(source, target, culture); } diff --git a/backend/src/Squidex.Infrastructure/Reflection/TypeNameRegistry.cs b/backend/src/Squidex.Infrastructure/Reflection/TypeNameRegistry.cs index bac7114b7..cecaa1723 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/TypeNameRegistry.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/TypeNameRegistry.cs @@ -27,8 +27,8 @@ namespace Squidex.Infrastructure.Reflection public TypeNameRegistry MapObsolete(Type type, string name) { - Guard.NotNull(type, nameof(type)); - Guard.NotNull(name, nameof(name)); + Guard.NotNull(type); + Guard.NotNull(name); lock (namesByType) { @@ -47,7 +47,7 @@ namespace Squidex.Infrastructure.Reflection public TypeNameRegistry Map(ITypeProvider provider) { - Guard.NotNull(provider, nameof(provider)); + Guard.NotNull(provider); provider.Map(this); @@ -56,7 +56,7 @@ namespace Squidex.Infrastructure.Reflection public TypeNameRegistry Map(Type type) { - Guard.NotNull(type, nameof(type)); + Guard.NotNull(type); var typeNameAttribute = type.GetCustomAttribute(); @@ -70,8 +70,8 @@ namespace Squidex.Infrastructure.Reflection public TypeNameRegistry Map(Type type, string name) { - Guard.NotNull(type, nameof(type)); - Guard.NotNull(name, nameof(name)); + Guard.NotNull(type); + Guard.NotNull(name); lock (namesByType) { diff --git a/backend/src/Squidex.Infrastructure/Security/Permission.cs b/backend/src/Squidex.Infrastructure/Security/Permission.cs index c28b1ea3e..41bb6a9d6 100644 --- a/backend/src/Squidex.Infrastructure/Security/Permission.cs +++ b/backend/src/Squidex.Infrastructure/Security/Permission.cs @@ -23,7 +23,7 @@ namespace Squidex.Infrastructure.Security public Permission(string id) { - Guard.NotNullOrEmpty(id, nameof(id)); + Guard.NotNullOrEmpty(id); Id = id; } diff --git a/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs b/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs index 714e84b78..434577277 100644 --- a/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs +++ b/backend/src/Squidex.Infrastructure/Security/PermissionSet.cs @@ -43,14 +43,14 @@ namespace Squidex.Infrastructure.Security public PermissionSet Add(string permission) { - Guard.NotNullOrEmpty(permission, nameof(permission)); + Guard.NotNullOrEmpty(permission); return Add(new Permission(permission)); } public PermissionSet Add(Permission permission) { - Guard.NotNull(permission, nameof(permission)); + Guard.NotNull(permission); return new PermissionSet(this.Union(Enumerable.Repeat(permission, 1)).Distinct()); } diff --git a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj index cf03ee1b5..294017a71 100644 --- a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj +++ b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj @@ -3,6 +3,7 @@ net6.0 10.0 enable + en enable @@ -11,22 +12,22 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + all runtime; build; native; contentfiles; analyzers - - + + @@ -38,11 +39,11 @@ - + - + diff --git a/backend/src/Squidex.Infrastructure/States/DefaultStreamNameResolver.cs b/backend/src/Squidex.Infrastructure/States/DefaultStreamNameResolver.cs index 042d2bcc1..039963583 100644 --- a/backend/src/Squidex.Infrastructure/States/DefaultStreamNameResolver.cs +++ b/backend/src/Squidex.Infrastructure/States/DefaultStreamNameResolver.cs @@ -15,8 +15,8 @@ namespace Squidex.Infrastructure.States public string GetStreamName(Type aggregateType, string id) { - Guard.NotNullOrEmpty(id, nameof(id)); - Guard.NotNull(aggregateType, nameof(aggregateType)); + Guard.NotNullOrEmpty(id); + Guard.NotNull(aggregateType); return $"{aggregateType.TypeName(true, Suffixes)}-{id}"; } diff --git a/backend/src/Squidex.Infrastructure/States/IPersistenceFactory.cs b/backend/src/Squidex.Infrastructure/States/IPersistenceFactory.cs index eebe64b5b..508bfe826 100644 --- a/backend/src/Squidex.Infrastructure/States/IPersistenceFactory.cs +++ b/backend/src/Squidex.Infrastructure/States/IPersistenceFactory.cs @@ -7,6 +7,8 @@ using Squidex.Infrastructure.EventSourcing; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.States { public delegate bool HandleEvent(Envelope @event); @@ -21,4 +23,4 @@ namespace Squidex.Infrastructure.States IPersistence WithSnapshotsAndEventSourcing(Type owner, DomainId id, HandleSnapshot? applySnapshot, HandleEvent? applyEvent); } -} \ No newline at end of file +} diff --git a/backend/src/Squidex.Infrastructure/States/Persistence.cs b/backend/src/Squidex.Infrastructure/States/Persistence.cs index 1fa38f116..a35dcd0e7 100644 --- a/backend/src/Squidex.Infrastructure/States/Persistence.cs +++ b/backend/src/Squidex.Infrastructure/States/Persistence.cs @@ -189,7 +189,7 @@ namespace Squidex.Infrastructure.States public async Task WriteEventsAsync(IReadOnlyList> events) { - Guard.NotEmpty(events, nameof(events)); + Guard.NotEmpty(events); var oldVersion = EtagVersion.Any; diff --git a/backend/src/Squidex.Infrastructure/States/Store.cs b/backend/src/Squidex.Infrastructure/States/Store.cs index 70f3c5edd..194843e34 100644 --- a/backend/src/Squidex.Infrastructure/States/Store.cs +++ b/backend/src/Squidex.Infrastructure/States/Store.cs @@ -59,7 +59,7 @@ namespace Squidex.Infrastructure.States private IPersistence CreatePersistence(Type owner, DomainId key, PersistenceMode mode, HandleSnapshot? applySnapshot, HandleEvent? applyEvent) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return new Persistence(key, owner, snapshotStore, diff --git a/backend/src/Squidex.Infrastructure/StringExtensions.cs b/backend/src/Squidex.Infrastructure/StringExtensions.cs index 605527ee6..a0afdc2cb 100644 --- a/backend/src/Squidex.Infrastructure/StringExtensions.cs +++ b/backend/src/Squidex.Infrastructure/StringExtensions.cs @@ -32,7 +32,7 @@ namespace Squidex.Infrastructure public static string BuildFullUrl(this string baseUrl, string path, bool trailingSlash = false) { - Guard.NotNull(path, nameof(path)); + Guard.NotNull(path); var url = $"{baseUrl.TrimEnd('/')}/{path.Trim('/')}"; @@ -49,7 +49,7 @@ namespace Squidex.Infrastructure public static string JoinNonEmpty(string separator, params string?[] parts) { - Guard.NotNull(separator, nameof(separator)); + Guard.NotNull(separator); if (parts == null || parts.Length == 0) { diff --git a/backend/src/Squidex.Infrastructure/Tasks/PartitionedActionBlock.cs b/backend/src/Squidex.Infrastructure/Tasks/PartitionedActionBlock.cs index 9ebf51641..0e5df689a 100644 --- a/backend/src/Squidex.Infrastructure/Tasks/PartitionedActionBlock.cs +++ b/backend/src/Squidex.Infrastructure/Tasks/PartitionedActionBlock.cs @@ -26,9 +26,9 @@ namespace Squidex.Infrastructure.Tasks public PartitionedActionBlock(Func action, Func partitioner, ExecutionDataflowBlockOptions dataflowBlockOptions) { - Guard.NotNull(action, nameof(action)); - Guard.NotNull(partitioner, nameof(partitioner)); - Guard.NotNull(dataflowBlockOptions, nameof(dataflowBlockOptions)); + Guard.NotNull(action); + Guard.NotNull(partitioner); + Guard.NotNull(dataflowBlockOptions); Guard.GreaterThan(dataflowBlockOptions.MaxDegreeOfParallelism, 1, nameof(dataflowBlockOptions.MaxDegreeOfParallelism)); workers = new ActionBlock[dataflowBlockOptions.MaxDegreeOfParallelism]; diff --git a/backend/src/Squidex.Infrastructure/Timers/CompletionTimer.cs b/backend/src/Squidex.Infrastructure/Timers/CompletionTimer.cs index 1ff633f49..f4240ed89 100644 --- a/backend/src/Squidex.Infrastructure/Timers/CompletionTimer.cs +++ b/backend/src/Squidex.Infrastructure/Timers/CompletionTimer.cs @@ -19,8 +19,8 @@ namespace Squidex.Infrastructure.Timers public CompletionTimer(int delayInMs, Func callback, int initialDelay = 0) { - Guard.NotNull(callback, nameof(callback)); - Guard.GreaterThan(delayInMs, 0, nameof(delayInMs)); + Guard.NotNull(callback); + Guard.GreaterThan(delayInMs, 0); runTask = RunInternalAsync(delayInMs, initialDelay, callback); } diff --git a/backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs b/backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs index 56ab7707e..ade3f11cc 100644 --- a/backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs +++ b/backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs @@ -25,9 +25,9 @@ namespace Squidex.Infrastructure.Translations public (string Result, bool Found) Get(CultureInfo culture, string key, string fallback, object? args = null) { - Guard.NotNull(culture, nameof(culture)); - Guard.NotNullOrEmpty(key, nameof(key)); - Guard.NotNull(fallback, nameof(fallback)); + Guard.NotNull(culture); + Guard.NotNullOrEmpty(key); + Guard.NotNull(fallback); var translation = GetCore(culture, key); diff --git a/backend/src/Squidex.Infrastructure/Translations/T.cs b/backend/src/Squidex.Infrastructure/Translations/T.cs index 5da6cf894..34283634c 100644 --- a/backend/src/Squidex.Infrastructure/Translations/T.cs +++ b/backend/src/Squidex.Infrastructure/Translations/T.cs @@ -25,7 +25,7 @@ namespace Squidex.Infrastructure.Translations public static string Get(string key, string fallback, object? args = null) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); if (localizer == null) { diff --git a/backend/src/Squidex.Infrastructure/UsageTracking/ApiUsageTracker.cs b/backend/src/Squidex.Infrastructure/UsageTracking/ApiUsageTracker.cs index 3a4f43d2c..9231466a7 100644 --- a/backend/src/Squidex.Infrastructure/UsageTracking/ApiUsageTracker.cs +++ b/backend/src/Squidex.Infrastructure/UsageTracking/ApiUsageTracker.cs @@ -117,7 +117,7 @@ namespace Squidex.Infrastructure.UsageTracking private static string GetKey(string key) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); return $"{key}_API"; } diff --git a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs index 92a6af597..360ff94c4 100644 --- a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs +++ b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs @@ -87,7 +87,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task DeleteAsync(string key, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return usageRepository.DeleteAsync(key, ct); } @@ -95,14 +95,16 @@ namespace Squidex.Infrastructure.UsageTracking public Task TrackAsync(DateTime date, string key, string? category, Counters counters, CancellationToken ct = default) { - Guard.NotNullOrEmpty(key, nameof(key)); - Guard.NotNull(counters, nameof(counters)); + Guard.NotNullOrEmpty(key); + Guard.NotNull(counters); ThrowIfDisposed(); category = GetCategory(category); +#pragma warning disable MA0105 // Use the lambda parameters instead of using a closure jobs.AddOrUpdate((key, category, date), counters, (k, p) => p.SumUp(counters)); +#pragma warning restore MA0105 // Use the lambda parameters instead of using a closure return Task.CompletedTask; } @@ -110,7 +112,7 @@ namespace Squidex.Infrastructure.UsageTracking public async Task>> QueryAsync(string key, DateTime fromDate, DateTime toDate, CancellationToken ct = default) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); ThrowIfDisposed(); @@ -161,7 +163,7 @@ namespace Squidex.Infrastructure.UsageTracking public async Task GetAsync(string key, DateTime fromDate, DateTime toDate, string? category, CancellationToken ct = default) { - Guard.NotNullOrEmpty(key, nameof(key)); + Guard.NotNullOrEmpty(key); ThrowIfDisposed(); diff --git a/backend/src/Squidex.Infrastructure/UsageTracking/CachingUsageTracker.cs b/backend/src/Squidex.Infrastructure/UsageTracking/CachingUsageTracker.cs index ab186fa81..6e5b006aa 100644 --- a/backend/src/Squidex.Infrastructure/UsageTracking/CachingUsageTracker.cs +++ b/backend/src/Squidex.Infrastructure/UsageTracking/CachingUsageTracker.cs @@ -17,8 +17,8 @@ namespace Squidex.Infrastructure.UsageTracking public CachingUsageTracker(IUsageTracker inner, IMemoryCache cache) { - Guard.NotNull(inner, nameof(inner)); - Guard.NotNull(cache, nameof(cache)); + Guard.NotNull(inner); + Guard.NotNull(cache); this.inner = inner; this.cache = cache; @@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task DeleteAsync(string key, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return inner.DeleteAsync(key, ct); } @@ -35,7 +35,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task>> QueryAsync(string key, DateTime fromDate, DateTime toDate, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return inner.QueryAsync(key, fromDate, toDate, ct); } @@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task TrackAsync(DateTime date, string key, string? category, Counters counters, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); return inner.TrackAsync(date, key, category, counters, ct); } @@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task GetForMonthAsync(string key, DateTime date, string? category, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); var cacheKey = $"{typeof(CachingUsageTracker)}_UsageForMonth_{key}_{date}_{category}"; @@ -66,7 +66,7 @@ namespace Squidex.Infrastructure.UsageTracking public Task GetAsync(string key, DateTime fromDate, DateTime toDate, string? category, CancellationToken ct = default) { - Guard.NotNull(key, nameof(key)); + Guard.NotNull(key); var cacheKey = $"{typeof(CachingUsageTracker)}_Usage_{key}_{fromDate}_{toDate}_{category}"; diff --git a/backend/src/Squidex.Infrastructure/Validation/Validate.cs b/backend/src/Squidex.Infrastructure/Validation/Validate.cs index bea66d02c..839061e88 100644 --- a/backend/src/Squidex.Infrastructure/Validation/Validate.cs +++ b/backend/src/Squidex.Infrastructure/Validation/Validate.cs @@ -5,6 +5,8 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.Validation { public static class Validate @@ -47,4 +49,4 @@ namespace Squidex.Infrastructure.Validation } public delegate void AddValidation(string message, params string[] propertyNames); -} \ No newline at end of file +} diff --git a/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs b/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs index 0038840c6..a0015693e 100644 --- a/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs +++ b/backend/src/Squidex.Infrastructure/Validation/ValidationError.cs @@ -25,7 +25,7 @@ namespace Squidex.Infrastructure.Validation public ValidationError(string message, params string[] propertyNames) { - Guard.NotNullOrEmpty(message, nameof(message)); + Guard.NotNullOrEmpty(message); this.message = message; diff --git a/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs b/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs index 7a084afa3..983b7c275 100644 --- a/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs +++ b/backend/src/Squidex.Infrastructure/Validation/ValidationException.cs @@ -48,7 +48,7 @@ namespace Squidex.Infrastructure.Validation private static string FormatMessage(IReadOnlyList errors) { - Guard.NotNull(errors, nameof(errors)); + Guard.NotNull(errors); var sb = new StringBuilder(); diff --git a/backend/src/Squidex.Shared/Permissions.cs b/backend/src/Squidex.Shared/Permissions.cs index 4221011c0..f723e82d6 100644 --- a/backend/src/Squidex.Shared/Permissions.cs +++ b/backend/src/Squidex.Shared/Permissions.cs @@ -169,7 +169,7 @@ namespace Squidex.Shared public static Permission ForApp(string id, string app = Permission.Any, string schema = Permission.Any) { - Guard.NotNull(id, nameof(id)); + Guard.NotNull(id); return new Permission(id .Replace("{app}", app ?? Permission.Any, StringComparison.Ordinal) diff --git a/backend/src/Squidex.Shared/Squidex.Shared.csproj b/backend/src/Squidex.Shared/Squidex.Shared.csproj index 2e3675f06..ae360bdce 100644 --- a/backend/src/Squidex.Shared/Squidex.Shared.csproj +++ b/backend/src/Squidex.Shared/Squidex.Shared.csproj @@ -9,7 +9,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 2ed86807d..10d840253 100644 --- a/backend/src/Squidex.Shared/Users/ClientUser.cs +++ b/backend/src/Squidex.Shared/Users/ClientUser.cs @@ -43,7 +43,7 @@ namespace Squidex.Shared.Users public ClientUser(RefToken token) { - Guard.NotNull(token, nameof(token)); + Guard.NotNull(token); this.token = token; diff --git a/backend/src/Squidex.Web/ApiExceptionConverter.cs b/backend/src/Squidex.Web/ApiExceptionConverter.cs index 304ffb462..e2d5b5b78 100644 --- a/backend/src/Squidex.Web/ApiExceptionConverter.cs +++ b/backend/src/Squidex.Web/ApiExceptionConverter.cs @@ -44,7 +44,7 @@ namespace Squidex.Web public static (ErrorDto Error, Exception? Unhandled) ToErrorDto(this ProblemDetails problem, HttpContext? httpContext) { - Guard.NotNull(problem, nameof(problem)); + Guard.NotNull(problem); var error = CreateError(problem.Status ?? 500, problem.Title); @@ -55,7 +55,7 @@ namespace Squidex.Web public static (ErrorDto Error, Exception? Unhandled) ToErrorDto(this Exception exception, HttpContext? httpContext) { - Guard.NotNull(exception, nameof(exception)); + Guard.NotNull(exception); var result = CreateError(exception); diff --git a/backend/src/Squidex.Web/Deferred.cs b/backend/src/Squidex.Web/Deferred.cs index 53a9c3154..b185a9d4c 100644 --- a/backend/src/Squidex.Web/Deferred.cs +++ b/backend/src/Squidex.Web/Deferred.cs @@ -25,14 +25,14 @@ namespace Squidex.Web public static Deferred Response(Func factory) { - Guard.NotNull(factory, nameof(factory)); + Guard.NotNull(factory); return new Deferred(() => Task.FromResult(factory())); } public static Deferred AsyncResponse(Func> factory) { - Guard.NotNull(factory, nameof(factory)); + Guard.NotNull(factory); return new Deferred(async () => (await factory())!); } diff --git a/backend/src/Squidex.Web/ExposedValues.cs b/backend/src/Squidex.Web/ExposedValues.cs index f1d5b3408..c227144b8 100644 --- a/backend/src/Squidex.Web/ExposedValues.cs +++ b/backend/src/Squidex.Web/ExposedValues.cs @@ -20,8 +20,8 @@ namespace Squidex.Web public ExposedValues(ExposedConfiguration configured, IConfiguration configuration, Assembly? assembly = null) { - Guard.NotNull(configured, nameof(configured)); - Guard.NotNull(configuration, nameof(configuration)); + Guard.NotNull(configured); + Guard.NotNull(configuration); foreach (var kvp in configured) { diff --git a/backend/src/Squidex.Web/FileCallbackResult.cs b/backend/src/Squidex.Web/FileCallbackResult.cs index cd8248ca5..9dda3b64d 100644 --- a/backend/src/Squidex.Web/FileCallbackResult.cs +++ b/backend/src/Squidex.Web/FileCallbackResult.cs @@ -11,10 +11,12 @@ using Squidex.Assets; using Squidex.Infrastructure; using Squidex.Web.Pipeline; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Web { public delegate Task FileCallback(Stream body, BytesRange range, - CancellationToken ct); + CancellationToken ct); public sealed class FileCallbackResult : FileResult { @@ -29,7 +31,7 @@ namespace Squidex.Web public FileCallbackResult(string contentType, FileCallback callback) : base(contentType) { - Guard.NotNull(callback, nameof(callback)); + Guard.NotNull(callback); Callback = callback; } @@ -41,4 +43,4 @@ namespace Squidex.Web return executor.ExecuteAsync(context, this); } } -} \ No newline at end of file +} diff --git a/backend/src/Squidex.Web/GraphQL/DynamicExecutor.cs b/backend/src/Squidex.Web/GraphQL/DynamicExecutor.cs deleted file mode 100644 index c7c1549f0..000000000 --- a/backend/src/Squidex.Web/GraphQL/DynamicExecutor.cs +++ /dev/null @@ -1,27 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using GraphQL; -using Squidex.Domain.Apps.Entities.Contents.GraphQL; - -namespace Squidex.Web.GraphQL -{ - public sealed class DynamicExecutor : IDocumentExecuter - { - private readonly IGraphQLService graphQLService; - - public DynamicExecutor(IGraphQLService graphQLService) - { - this.graphQLService = graphQLService; - } - - public Task ExecuteAsync(ExecutionOptions options) - { - return graphQLService.ExecuteAsync(options); - } - } -} diff --git a/backend/src/Squidex.Web/GraphQL/GraphQLMiddleware.cs b/backend/src/Squidex.Web/GraphQL/GraphQLRunner.cs similarity index 55% rename from backend/src/Squidex.Web/GraphQL/GraphQLMiddleware.cs rename to backend/src/Squidex.Web/GraphQL/GraphQLRunner.cs index e00876697..9c27b6f64 100644 --- a/backend/src/Squidex.Web/GraphQL/GraphQLMiddleware.cs +++ b/backend/src/Squidex.Web/GraphQL/GraphQLRunner.cs @@ -10,13 +10,18 @@ using Microsoft.AspNetCore.Http; namespace Squidex.Web.GraphQL { - public sealed class GraphQLMiddleware : GraphQLHttpMiddleware + public sealed class GraphQLRunner { - private static readonly RequestDelegate Noop = _ => Task.CompletedTask; + private readonly GraphQLHttpMiddleware middleware; - public GraphQLMiddleware(IGraphQLRequestDeserializer deserializer) - : base(Noop, deserializer) + public GraphQLRunner(IGraphQLRequestDeserializer deserializer) { + middleware = new GraphQLHttpMiddleware(x => Task.CompletedTask, deserializer); + } + + public Task InvokeAsync(HttpContext context) + { + return middleware.InvokeAsync(context); } } } diff --git a/backend/src/Squidex.Web/Pipeline/CachingManager.cs b/backend/src/Squidex.Web/Pipeline/CachingManager.cs index bd17a759c..12b77a4ac 100644 --- a/backend/src/Squidex.Web/Pipeline/CachingManager.cs +++ b/backend/src/Squidex.Web/Pipeline/CachingManager.cs @@ -182,7 +182,7 @@ namespace Squidex.Web.Pipeline public void Start(HttpContext httpContext) { - Guard.NotNull(httpContext, nameof(httpContext)); + Guard.NotNull(httpContext); var maxKeysSize = GetKeysSize(httpContext); @@ -224,7 +224,7 @@ namespace Squidex.Web.Pipeline public void Finish(HttpContext httpContext) { - Guard.NotNull(httpContext, nameof(httpContext)); + Guard.NotNull(httpContext); var cacheContext = httpContext.Features.Get(); diff --git a/backend/src/Squidex.Web/Pipeline/SchemaResolver.cs b/backend/src/Squidex.Web/Pipeline/SchemaResolver.cs index ee1593c6e..9521ef487 100644 --- a/backend/src/Squidex.Web/Pipeline/SchemaResolver.cs +++ b/backend/src/Squidex.Web/Pipeline/SchemaResolver.cs @@ -22,7 +22,7 @@ namespace Squidex.Web.Pipeline public SchemaResolver(IAppProvider appProvider) { - Guard.NotNull(appProvider, nameof(appProvider)); + Guard.NotNull(appProvider); this.appProvider = appProvider; } diff --git a/backend/src/Squidex.Web/Resource.cs b/backend/src/Squidex.Web/Resource.cs index 85de4a51e..1d247bfe9 100644 --- a/backend/src/Squidex.Web/Resource.cs +++ b/backend/src/Squidex.Web/Resource.cs @@ -51,9 +51,9 @@ namespace Squidex.Web public void AddLink(string rel, string method, string href, string? metadata = null) { - Guard.NotNullOrEmpty(rel, nameof(rel)); - Guard.NotNullOrEmpty(href, nameof(href)); - Guard.NotNullOrEmpty(method, nameof(method)); + Guard.NotNullOrEmpty(rel); + Guard.NotNullOrEmpty(href); + Guard.NotNullOrEmpty(method); Links[rel] = new ResourceLink { Href = href, Method = method, Metadata = metadata }; } diff --git a/backend/src/Squidex.Web/Squidex.Web.csproj b/backend/src/Squidex.Web/Squidex.Web.csproj index 70a8a971f..ade9a860b 100644 --- a/backend/src/Squidex.Web/Squidex.Web.csproj +++ b/backend/src/Squidex.Web/Squidex.Web.csproj @@ -17,9 +17,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex/Areas/Api/Controllers/Apps/AppImageController.cs b/backend/src/Squidex/Areas/Api/Controllers/Apps/AppImageController.cs index 5881f08d4..5587f74ce 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Apps/AppImageController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Apps/AppImageController.cs @@ -88,7 +88,6 @@ namespace Squidex.Areas.Api.Controllers.Apps private async Task ResizeAsync(string resizedAsset, string mimeType, Stream target, CancellationToken ct) { -#pragma warning disable CA2016 // Forward the 'CancellationToken' parameter to methods #pragma warning disable MA0040 // Flow the cancellation token using var activity = Telemetry.Activities.StartActivity("Resize"); @@ -155,7 +154,6 @@ namespace Squidex.Areas.Api.Controllers.Apps await resizeStream.CopyToAsync(target, ct); } } -#pragma warning restore CA2016 // Forward the 'CancellationToken' parameter to methods #pragma warning restore MA0040 // Flow the cancellation token } } diff --git a/backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdateAssetScripts.cs b/backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdateAssetScriptsDto.cs similarity index 100% rename from backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdateAssetScripts.cs rename to backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdateAssetScriptsDto.cs diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs index bc7139114..758a86234 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetContentQueryDto.cs @@ -95,7 +95,7 @@ namespace Squidex.Areas.Api.Controllers.Assets.Models public ResizeOptions ToResizeOptions(IAssetEntity asset) { - Guard.NotNull(asset, nameof(asset)); + Guard.NotNull(asset); var result = SimpleMapper.Map(this, new ResizeOptions()); diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs index 9808eb127..ad677a608 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs @@ -24,12 +24,12 @@ namespace Squidex.Areas.Api.Controllers.Contents { private readonly IContentQueryService contentQuery; private readonly IContentWorkflow contentWorkflow; - private readonly GraphQLMiddleware graphQLMiddleware; + private readonly GraphQLRunner graphQLMiddleware; public ContentsController(ICommandBus commandBus, IContentQueryService contentQuery, IContentWorkflow contentWorkflow, - GraphQLMiddleware graphQLMiddleware) + GraphQLRunner graphQLMiddleware) : base(commandBus) { this.contentQuery = contentQuery; diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/ConnectController.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/AuthorizationController.cs similarity index 100% rename from backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/ConnectController.cs rename to backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/AuthorizationController.cs diff --git a/backend/src/Squidex/Config/Domain/QueryServices.cs b/backend/src/Squidex/Config/Domain/QueryServices.cs index 67b8392b6..ea5841b6a 100644 --- a/backend/src/Squidex/Config/Domain/QueryServices.cs +++ b/backend/src/Squidex/Config/Domain/QueryServices.cs @@ -1,4 +1,4 @@ -// ========================================================================== +// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) @@ -36,9 +36,6 @@ namespace Squidex.Config.Domain services.AddSingletonAs() .AsSelf(); - - services.AddSingletonAs() - .As(); } } -} \ No newline at end of file +} diff --git a/backend/src/Squidex/Config/Domain/SerializationServices.cs b/backend/src/Squidex/Config/Domain/SerializationServices.cs index 3d1117377..0ed68be46 100644 --- a/backend/src/Squidex/Config/Domain/SerializationServices.cs +++ b/backend/src/Squidex/Config/Domain/SerializationServices.cs @@ -7,9 +7,9 @@ using System.Security.Claims; using GraphQL; +using GraphQL.DI; using GraphQL.Execution; using GraphQL.NewtonsoftJson; -using GraphQL.Server; using Migrations; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -31,6 +31,7 @@ using Squidex.Infrastructure.Json.Objects; using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Queries.Json; using Squidex.Infrastructure.Reflection; +using ServiceLifetime = GraphQL.DI.ServiceLifetime; namespace Squidex.Config.Domain { @@ -126,12 +127,12 @@ namespace Squidex.Config.Domain public static IGraphQLBuilder AddSquidexWriter(this IGraphQLBuilder builder) { - builder.Services.AddSingleton(c => + builder.Register(c => { var serializer = new NewtonsoftJsonSerializer(ConfigureJson(TypeNameHandling.None)); return new DefaultDocumentWriter(serializer); - }); + }, ServiceLifetime.Singleton); return builder; } diff --git a/backend/src/Squidex/Config/Web/WebServices.cs b/backend/src/Squidex/Config/Web/WebServices.cs index 33a7be3ac..8bf26abb8 100644 --- a/backend/src/Squidex/Config/Web/WebServices.cs +++ b/backend/src/Squidex/Config/Web/WebServices.cs @@ -6,6 +6,8 @@ // ========================================================================== using GraphQL; +using GraphQL.DataLoader; +using GraphQL.DI; using GraphQL.Server; using GraphQL.Server.Transports.AspNetCore; using Microsoft.AspNetCore.Mvc; @@ -14,6 +16,7 @@ using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using Squidex.Config.Domain; using Squidex.Domain.Apps.Entities; +using Squidex.Domain.Apps.Entities.Contents.GraphQL; using Squidex.Infrastructure.Caching; using Squidex.Pipeline.Plugins; using Squidex.Web; @@ -84,24 +87,26 @@ namespace Squidex.Config.Web public static void AddSquidexGraphQL(this IServiceCollection services) { - services.AddGraphQL(options => - { - options.EnableMetrics = false; - }) - .AddDataLoader() - .AddSystemTextJson() - .AddSquidexWriter(); + GraphQL.MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services) + .AddServer(false, options => + { + options.EnableMetrics = false; + }) + .AddSchema() + .AddSquidexWriter() + .AddSystemTextJson() + .AddDataLoader(); services.AddSingletonAs() .AsSelf(); - services.AddSingletonAs() - .As(); - services.AddSingletonAs() .As(); - services.AddSingletonAs() + services.AddSingletonAs() + .As(); + + services.AddSingletonAs() .AsSelf(); } } diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj index 8187edd0e..323d7d3fa 100644 --- a/backend/src/Squidex/Squidex.csproj +++ b/backend/src/Squidex/Squidex.csproj @@ -34,52 +34,53 @@ - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + - - - - - + + + + + - + - + - + - + - + - + diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateFilters/FiltersTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateFilters/FiltersTests.cs index 64c0cc552..b7fb3aa1e 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateFilters/FiltersTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateFilters/FiltersTests.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Core.Operations.GenerateFilters var queryModel = ContentQueryModel.Build(schema, languagesConfig.ToResolver(), components); - Assert.NotNull(queryModel); + CheckFields(queryModel.Schema, schema); } [Fact] @@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Core.Operations.GenerateFilters void CheckField(IField field) { - if (!field.IsForApi()) + if (!field.IsForApi(true)) { Assert.DoesNotContain(field.Name, filterProperties); } 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 7cfa68e9d..ade5b240e 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 @@ -559,7 +559,9 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting replace(); "; +#pragma warning disable MA0042 // Do not use blocking calls in an async method sut.Execute(vars, script1, new ScriptOptions { AsContext = true }); +#pragma warning restore MA0042 // Do not use blocking calls in an async method var vars2 = new ScriptVars(vars) { diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ValidationTestExtensions.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ValidationTestExtensions.cs index 186b84e9e..426d49a04 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ValidationTestExtensions.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/ValidationTestExtensions.cs @@ -15,6 +15,8 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Validation; using Squidex.Log; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Domain.Apps.Core.Operations.ValidateContent { public delegate ValidationContext ValidationUpdater(ValidationContext context); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidator.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs similarity index 100% rename from backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidator.cs rename to backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/UniqueObjectValuesValidatorTests.cs 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 dcacc8257..d5d7436fd 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 @@ -13,9 +13,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppEventDeleter.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppEventDeleterTests.cs similarity index 100% rename from backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppEventDeleter.cs rename to backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppEventDeleterTests.cs diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLIntrospectionTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLIntrospectionTests.cs index 1b35b10bd..1adf9e01e 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLIntrospectionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLIntrospectionTests.cs @@ -13,6 +13,7 @@ using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types; using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Infrastructure; using Xunit; +using GraphQLSchema = GraphQL.Types.Schema; using Schema = Squidex.Domain.Apps.Core.Schemas.Schema; namespace Squidex.Domain.Apps.Entities.Contents.GraphQL @@ -119,7 +120,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL [Fact] public async Task Should_create_empty_schema() { - var model = await CreateSut().GetModelAsync(TestApp.Default); + var model = await CreateSut().GetSchemaAsync(TestApp.Default); Assert.NotNull(model); } @@ -132,7 +133,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL NamedId.Of(DomainId.NewGuid(), "content"), new Schema("content").Publish()); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var model = await CreateSut(schema).GetSchemaAsync(TestApp.Default); Assert.NotNull(model); } @@ -146,7 +147,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("content").Publish() .AddUI(1, "ui", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var model = await CreateSut(schema).GetSchemaAsync(TestApp.Default); Assert.NotNull(model); } @@ -160,7 +161,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("content").Publish() .AddComponent(1, "component", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var model = await CreateSut(schema).GetSchemaAsync(TestApp.Default); Assert.NotNull(model); } @@ -174,7 +175,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("content") .AddString(1, "myField", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var model = await CreateSut(schema).GetSchemaAsync(TestApp.Default); Assert.NotNull(model); } @@ -188,9 +189,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("content").Publish() .AddString(1, "myField", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - Assert.Contains(model.Schema.AllTypes, x => x.Name == "ContentEntity"); + Assert.Contains(graphQLSchema.AllTypes, x => x.Name == "ContentEntity"); } [Fact] @@ -202,9 +203,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("my-schema").Publish() .AddString(1, "content", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.Contains(type?.Fields, x => x.Name == "content"); } @@ -218,9 +219,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new Schema("my-schema").Publish() .AddString(1, "2-field", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.Contains(type?.Fields, x => x.Name == "gql_2Field"); } @@ -235,9 +236,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL .AddString(1, "my-field", Partitioning.Invariant) .AddString(2, "my_field", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.Contains(type?.Fields, x => x.Name == "myField"); Assert.Contains(type?.Fields, x => x.Name == "myField2"); @@ -254,9 +255,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new ComponentFieldProperties()) .AddString(2, "my-string", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.DoesNotContain(type?.Fields, x => x.Name == "myComponent"); } @@ -272,9 +273,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new ComponentsFieldProperties()) .AddString(2, "my-string", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.DoesNotContain(type?.Fields, x => x.Name == "myComponents"); } @@ -290,16 +291,16 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL new ReferencesFieldProperties { SchemaId = DomainId.NewGuid() }) .AddString(2, "my-string", Partitioning.Invariant)); - var model = await CreateSut(schema).GetModelAsync(TestApp.Default); + var graphQLSchema = await CreateSut(schema).GetSchemaAsync(TestApp.Default); - var type = FindDataType(model, "MySchema"); + var type = FindDataType(graphQLSchema, "MySchema"); Assert.DoesNotContain(type?.Fields, x => x.Name == "myReferences"); } - private static IObjectGraphType? FindDataType(GraphQLModel model, string schema) + private static IObjectGraphType? FindDataType(GraphQLSchema graphQLSchema, string schema) { - var type = (IObjectGraphType)model.Schema.AllTypes.Single(x => x.Name == schema); + var type = (IObjectGraphType)graphQLSchema.AllTypes.Single(x => x.Name == schema); return (IObjectGraphType?)type.GetField("flatData")?.ResolvedType?.Flatten(); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs index afc9ea344..f6794daa5 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs @@ -83,23 +83,23 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL return ExcecuteAsync(options, context); } - private Task ExcecuteAsync(ExecutionOptions options, Context context) + private async Task ExcecuteAsync(ExecutionOptions options, Context context) { var sut = CreateSut(TestSchemas.Default, TestSchemas.Ref1, TestSchemas.Ref2); options.UserContext = ActivatorUtilities.CreateInstance(sut.Services, context)!; - var listener = sut.Services.GetService(); - - if (listener != null) + foreach (var listener in sut.Services.GetRequiredService>()) { options.Listeners.Add(listener); } - return sut.ExecuteAsync(options); + await sut.ConfigureAsync(options); + + return await new DocumentExecuter().ExecuteAsync(options); } - protected CachingGraphQLService CreateSut(params ISchemaEntity[] schemas) + protected CachingGraphQLResolver CreateSut(params ISchemaEntity[] schemas) { var cache = new BackgroundCache(new MemoryCache(Options.Create(new MemoryCacheOptions()))); @@ -108,20 +108,19 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL A.CallTo(() => appProvider.GetSchemasAsync(TestApp.Default.Id, default)) .Returns(schemas.ToList()); - var dataLoaderContext = (IDataLoaderContextAccessor)new DataLoaderContextAccessor(); - var dataLoaderListener = new DataLoaderDocumentListener(dataLoaderContext); - var services = new ServiceCollection() .AddMemoryCache() .AddTransient() + .AddSingleton() + .AddSingleton() .AddSingleton(A.Fake()) .AddSingleton(appProvider) .AddSingleton(assetQuery) .AddSingleton(commandBus) .AddSingleton(contentQuery) - .AddSingleton(dataLoaderContext) - .AddSingleton(dataLoaderListener) .AddSingleton(userResolver) .AddSingleton() .AddSingleton() @@ -133,7 +132,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL var schemasHash = A.Fake(); - return new CachingGraphQLService(cache, schemasHash, services, Options.Create(new GraphQLOptions())); + return new CachingGraphQLResolver(cache, schemasHash, services, Options.Create(new GraphQLOptions())); } } } 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 ab73ef939..ebbef9c98 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 @@ -65,8 +65,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb Task.Run(async () => { - await Task.WhenAll( - SetupAsync(ContentRepository, mongoDatabase)); + await SetupAsync(ContentRepository, mongoDatabase); }).Wait(); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs index 14a3f1f7c..c8a76467f 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs @@ -6,79 +6,67 @@ // ========================================================================== using FakeItEasy; +using Squidex.Domain.Apps.Core; using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Entities.Contents.Queries.Steps; using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Infrastructure; -using Squidex.Infrastructure.Caching; +using Squidex.Infrastructure.Json; using Xunit; namespace Squidex.Domain.Apps.Entities.Contents.Queries { - public class EnrichForCachingTests + public class CalculateTokensTests { private readonly ISchemaEntity schema; - private readonly IRequestCache requestCache = A.Fake(); + private readonly IJsonSerializer jsonSerializer = A.Fake(); + private readonly IUrlGenerator urlGenerator = A.Fake(); private readonly Context requestContext; private readonly NamedId appId = NamedId.Of(DomainId.NewGuid(), "my-app"); private readonly NamedId schemaId = NamedId.Of(DomainId.NewGuid(), "my-schema"); private readonly ProvideSchema schemaProvider; - private readonly EnrichForCaching sut; + private readonly CalculateTokens sut; - public EnrichForCachingTests() + public CalculateTokensTests() { requestContext = new Context(Mocks.ApiUser(), Mocks.App(appId)); schema = Mocks.Schema(appId, schemaId); schemaProvider = x => Task.FromResult((schema, ResolvedComponents.Empty)); - sut = new EnrichForCaching(requestCache); + sut = new CalculateTokens(urlGenerator, jsonSerializer); } [Fact] - public async Task Should_add_cache_headers() + public async Task Should_not_compute_ui_tokens_for_frontend() { - var headers = new List(); + var source = CreateContent(); - A.CallTo(() => requestCache.AddHeader(A._)) - .Invokes(new Action(header => headers.Add(header))); + await sut.EnrichAsync(new Context(Mocks.FrontendUser(), Mocks.App(appId)), new[] { source }, schemaProvider, default); - await sut.EnrichAsync(requestContext, default); + Assert.Null(source.EditToken); - Assert.Equal(new List - { - "X-Flatten", - "X-Languages", - "X-NoCleanup", - "X-NoEnrichment", - "X-NoResolveLanguages", - "X-ResolveFlow", - "X-Resolve-Urls", - "X-Unpublished" - }, headers); + A.CallTo(() => urlGenerator.Root()) + .MustNotHaveHappened(); } [Fact] - public async Task Should_add_app_version_and_schema_as_dependency() + public async Task Should_compute_ui_tokens() { - var content = CreateContent(); + var source = CreateContent(); - await sut.EnrichAsync(requestContext, Enumerable.Repeat(content, 1), schemaProvider, default); + await sut.EnrichAsync(requestContext, new[] { source }, schemaProvider, default); - A.CallTo(() => requestCache.AddDependency(content.UniqueId, content.Version)) - .MustHaveHappened(); - - A.CallTo(() => requestCache.AddDependency(schema.UniqueId, schema.Version)) - .MustHaveHappened(); + Assert.NotNull(source.EditToken); - A.CallTo(() => requestCache.AddDependency(requestContext.App.UniqueId, requestContext.App.Version)) + A.CallTo(() => urlGenerator.Root()) .MustHaveHappened(); } private ContentEntity CreateContent() { - return new ContentEntity { AppId = appId, Id = DomainId.NewGuid(), SchemaId = schemaId, Version = 13 }; + return new ContentEntity { AppId = appId, SchemaId = schemaId }; } } } 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 c8a76467f..14a3f1f7c 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 @@ -6,67 +6,79 @@ // ========================================================================== using FakeItEasy; -using Squidex.Domain.Apps.Core; using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Entities.Contents.Queries.Steps; using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Infrastructure; -using Squidex.Infrastructure.Json; +using Squidex.Infrastructure.Caching; using Xunit; namespace Squidex.Domain.Apps.Entities.Contents.Queries { - public class CalculateTokensTests + public class EnrichForCachingTests { private readonly ISchemaEntity schema; - private readonly IJsonSerializer jsonSerializer = A.Fake(); - private readonly IUrlGenerator urlGenerator = A.Fake(); + private readonly IRequestCache requestCache = A.Fake(); private readonly Context requestContext; private readonly NamedId appId = NamedId.Of(DomainId.NewGuid(), "my-app"); private readonly NamedId schemaId = NamedId.Of(DomainId.NewGuid(), "my-schema"); private readonly ProvideSchema schemaProvider; - private readonly CalculateTokens sut; + private readonly EnrichForCaching sut; - public CalculateTokensTests() + public EnrichForCachingTests() { requestContext = new Context(Mocks.ApiUser(), Mocks.App(appId)); schema = Mocks.Schema(appId, schemaId); schemaProvider = x => Task.FromResult((schema, ResolvedComponents.Empty)); - sut = new CalculateTokens(urlGenerator, jsonSerializer); + sut = new EnrichForCaching(requestCache); } [Fact] - public async Task Should_not_compute_ui_tokens_for_frontend() + public async Task Should_add_cache_headers() { - var source = CreateContent(); + var headers = new List(); - await sut.EnrichAsync(new Context(Mocks.FrontendUser(), Mocks.App(appId)), new[] { source }, schemaProvider, default); + A.CallTo(() => requestCache.AddHeader(A._)) + .Invokes(new Action(header => headers.Add(header))); - Assert.Null(source.EditToken); + await sut.EnrichAsync(requestContext, default); - A.CallTo(() => urlGenerator.Root()) - .MustNotHaveHappened(); + Assert.Equal(new List + { + "X-Flatten", + "X-Languages", + "X-NoCleanup", + "X-NoEnrichment", + "X-NoResolveLanguages", + "X-ResolveFlow", + "X-Resolve-Urls", + "X-Unpublished" + }, headers); } [Fact] - public async Task Should_compute_ui_tokens() + public async Task Should_add_app_version_and_schema_as_dependency() { - var source = CreateContent(); + var content = CreateContent(); - await sut.EnrichAsync(requestContext, new[] { source }, schemaProvider, default); + await sut.EnrichAsync(requestContext, Enumerable.Repeat(content, 1), schemaProvider, default); - Assert.NotNull(source.EditToken); + A.CallTo(() => requestCache.AddDependency(content.UniqueId, content.Version)) + .MustHaveHappened(); + + A.CallTo(() => requestCache.AddDependency(schema.UniqueId, schema.Version)) + .MustHaveHappened(); - A.CallTo(() => urlGenerator.Root()) + A.CallTo(() => requestCache.AddDependency(requestContext.App.UniqueId, requestContext.App.Version)) .MustHaveHappened(); } private ContentEntity CreateContent() { - return new ContentEntity { AppId = appId, SchemaId = schemaId }; + return new ContentEntity { AppId = appId, Id = DomainId.NewGuid(), SchemaId = schemaId, Version = 13 }; } } } 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 b94b44399..0acffa654 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 @@ -20,19 +20,19 @@ - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + 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 bef775836..77209db91 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 @@ -14,9 +14,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoEventStoreFixture.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoEventStoreFixture.cs index 49c92520e..b3601be1e 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoEventStoreFixture.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/MongoEventStoreFixture.cs @@ -11,6 +11,8 @@ using Newtonsoft.Json; using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.TestHelpers; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.EventSourcing { public abstract class MongoEventStoreFixture : IDisposable diff --git a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoQueryTests.cs b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoQueryTests.cs index 53a2f3861..ee8199725 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoQueryTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoQueryTests.cs @@ -311,7 +311,7 @@ namespace Squidex.Infrastructure.MongoDb .MustHaveHappened(); } - private void AssertQuery(string expected, FilterNode filter, object? arg = null) + private static void AssertQuery(string expected, FilterNode filter, object? arg = null) { AssertQuery(new ClrQuery { Filter = filter }, expected, arg); } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj index 21e007233..572f42b79 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj +++ b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj @@ -14,17 +14,17 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers diff --git a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainObject.cs b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainObject.cs index 491571803..5867641a0 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainObject.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainObject.cs @@ -11,6 +11,8 @@ using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.States; using Squidex.Log; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.TestHelpers { public sealed class MyDomainObject : DomainObject @@ -32,7 +34,7 @@ namespace Squidex.Infrastructure.TestHelpers protected override bool CanRecreate(IEvent @event) { - return RecreateEvent ? @event is ValueChanged : false; + return RecreateEvent && @event is ValueChanged; } protected override bool CanRecreate() diff --git a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainState.cs b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainState.cs index 4f870ef72..b269b384b 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainState.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/TestHelpers/MyDomainState.cs @@ -8,6 +8,8 @@ using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; +#pragma warning disable MA0048 // File name must match type name + namespace Squidex.Infrastructure.TestHelpers { public sealed record MyDomainState : IDomainState diff --git a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj index 9cd43e8e2..78c9e66a1 100644 --- a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj +++ b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj @@ -12,8 +12,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive