diff --git a/backend/src/Migrations/Migrations/PopulateGrainIndexes.cs b/backend/src/Migrations/Migrations/PopulateGrainIndexes.cs index 13fffb0c7..ef64223cc 100644 --- a/backend/src/Migrations/Migrations/PopulateGrainIndexes.cs +++ b/backend/src/Migrations/Migrations/PopulateGrainIndexes.cs @@ -55,24 +55,24 @@ namespace Migrations.Migrations bool HasApp(NamedId appId, bool consistent, out Guid id) { - return appsByName.TryGetValue(appId.Name, out id) && (!consistent || id == appId.Id); + return appsByName!.TryGetValue(appId.Name, out id) && (!consistent || id == appId.Id); } HashSet Index(string contributorId) { - return appsByUser.GetOrAddNew(contributorId); + return appsByUser!.GetOrAddNew(contributorId); } void RemoveApp(NamedId appId, bool consistent) { if (HasApp(appId, consistent, out var id)) { - foreach (var apps in appsByUser.Values) + foreach (var apps in appsByUser!.Values) { apps.Remove(id); } - appsByName.Remove(appId.Name); + appsByName!.Remove(appId.Name); } } @@ -125,7 +125,7 @@ namespace Migrations.Migrations HashSet Index(RuleEvent @event) { - return rulesByApp.GetOrAddNew(@event.AppId.Id); + return rulesByApp!.GetOrAddNew(@event.AppId.Id); } await eventStore.QueryAsync(storedEvent => @@ -157,7 +157,7 @@ namespace Migrations.Migrations Dictionary Index(SchemaEvent @event) { - return schemasByApp.GetOrAddNew(@event.AppId.Id); + return schemasByApp!.GetOrAddNew(@event.AppId.Id); } await eventStore.QueryAsync(storedEvent => diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/IdContentData.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/IdContentData.cs index 6afddd6b0..7a800ecb6 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/IdContentData.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/IdContentData.cs @@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Core.Contents return this; } - public bool Equals(IdContentData other) + public bool Equals([AllowNull] IdContentData other) { return base.Equals(other); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs index 68b536f5c..84ed62235 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Contents/NamedContentData.cs @@ -6,6 +6,7 @@ // ========================================================================== using System; +using System.Diagnostics.CodeAnalysis; using Squidex.Infrastructure; namespace Squidex.Domain.Apps.Core.Contents @@ -63,7 +64,7 @@ namespace Squidex.Domain.Apps.Core.Contents return clone; } - public bool Equals(NamedContentData other) + public bool Equals([AllowNull] NamedContentData other) { return base.Equals(other); } diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs index 3bb246b27..ce02d6d6a 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs @@ -201,7 +201,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains private async Task ClearAsync() { - var logContext = (actionId: Guid.NewGuid().ToString(), consumer: eventConsumer.Name); + var logContext = (actionId: Guid.NewGuid().ToString(), consumer: eventConsumer!.Name); log.LogDebug(logContext, (ctx, w) => w .WriteProperty("action", "EventConsumerReset") @@ -224,7 +224,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains var eventId = @event.Headers.EventId().ToString(); var eventType = @event.Payload.GetType().Name; - var logContext = (eventId, eventType, consumer: eventConsumer.Name); + var logContext = (eventId, eventType, consumer: eventConsumer!.Name); log.LogDebug(logContext, (ctx, w) => w .WriteProperty("action", "HandleEvent") diff --git a/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs b/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs index 04198efda..a7372d291 100644 --- a/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs +++ b/backend/src/Squidex.Infrastructure/Json/Objects/JsonObject.cs @@ -113,7 +113,7 @@ namespace Squidex.Infrastructure.Json.Objects return Equals(obj as JsonObject); } - public bool Equals(IJsonValue other) + public bool Equals([AllowNull] IJsonValue other) { return Equals(other as JsonObject); } diff --git a/backend/src/Squidex.Infrastructure/Net/IPAddressComparer.cs b/backend/src/Squidex.Infrastructure/Net/IPAddressComparer.cs index be236eaf9..0a5f8f939 100644 --- a/backend/src/Squidex.Infrastructure/Net/IPAddressComparer.cs +++ b/backend/src/Squidex.Infrastructure/Net/IPAddressComparer.cs @@ -6,6 +6,7 @@ // ========================================================================== using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Net; namespace Squidex.Infrastructure.Net @@ -18,8 +19,13 @@ namespace Squidex.Infrastructure.Net { } - public int Compare(IPAddress x, IPAddress y) + public int Compare([AllowNull] IPAddress x, [AllowNull] IPAddress y) { + if (x == null || y == null) + { + return 0; + } + var lbytes = x.GetAddressBytes(); var rbytes = y.GetAddressBytes(); diff --git a/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs b/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs index 2a05e3d04..b55354beb 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs @@ -116,7 +116,7 @@ namespace Squidex.Infrastructure.Orleans.Indexes { state.Value.Names.TryGetValue(name, out var id); - return Task.FromResult(id); + return Task.FromResult(id!); } public Task> GetIdsAsync() diff --git a/backend/src/Squidex.Infrastructure/Reflection/Equality/DeepEqualityComparer.cs b/backend/src/Squidex.Infrastructure/Reflection/Equality/DeepEqualityComparer.cs index 3bb04aef1..4a7ceda20 100644 --- a/backend/src/Squidex.Infrastructure/Reflection/Equality/DeepEqualityComparer.cs +++ b/backend/src/Squidex.Infrastructure/Reflection/Equality/DeepEqualityComparer.cs @@ -6,6 +6,7 @@ // ========================================================================== using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace Squidex.Infrastructure.Reflection.Equality { @@ -19,7 +20,7 @@ namespace Squidex.Infrastructure.Reflection.Equality this.comparer = comparer ?? SimpleEquals.Build(typeof(T)); } - public bool Equals(T x, T y) + public bool Equals([AllowNull] T x, [AllowNull] T y) { return comparer.IsEquals(x, y); } diff --git a/backend/src/Squidex.Infrastructure/Security/Permission.cs b/backend/src/Squidex.Infrastructure/Security/Permission.cs index 7576c457b..5355a3891 100644 --- a/backend/src/Squidex.Infrastructure/Security/Permission.cs +++ b/backend/src/Squidex.Infrastructure/Security/Permission.cs @@ -6,6 +6,7 @@ // ========================================================================== using System; +using System.Diagnostics.CodeAnalysis; namespace Squidex.Infrastructure.Security { @@ -112,7 +113,7 @@ namespace Squidex.Infrastructure.Security return id; } - public int CompareTo(Permission other) + public int CompareTo([AllowNull] Permission other) { return other == null ? -1 : string.Compare(id, other.id, StringComparison.Ordinal); }