From 59e8a178f85b500fafbda17c0a99b4ad0e31fe70 Mon Sep 17 00:00:00 2001 From: ArneD Date: Thu, 14 Nov 2024 10:57:58 +0100 Subject: [PATCH] refactor: sonar suggestions BREAKING CHANGE: EventTag is now sealed --- .../EventHandlingModule.cs | 8 ++++---- .../Documentation/RegistryEventsMarkdownBuilder.cs | 4 +--- .../EventTag.cs | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Be.Vlaanderen.Basisregisters.EventHandling.Autofac/EventHandlingModule.cs b/src/Be.Vlaanderen.Basisregisters.EventHandling.Autofac/EventHandlingModule.cs index 68831c6..371e25b 100755 --- a/src/Be.Vlaanderen.Basisregisters.EventHandling.Autofac/EventHandlingModule.cs +++ b/src/Be.Vlaanderen.Basisregisters.EventHandling.Autofac/EventHandlingModule.cs @@ -18,17 +18,17 @@ public EventHandlingModule(Assembly eventsAssembly, JsonSerializerSettings jsonS _eventMapping = new EventMapping(EventMapping.DiscoverEventNamesInAssembly(eventsAssembly)); } - protected override void Load(ContainerBuilder containerBuilder) + protected override void Load(ContainerBuilder builder) { - containerBuilder + builder .RegisterInstance(_eventMapping) .As(); - containerBuilder + builder .RegisterInstance(_eventDeserializer) .As(); - containerBuilder + builder .RegisterInstance(_eventSerializer) .As(); } diff --git a/src/Be.Vlaanderen.Basisregisters.EventHandling/Documentation/RegistryEventsMarkdownBuilder.cs b/src/Be.Vlaanderen.Basisregisters.EventHandling/Documentation/RegistryEventsMarkdownBuilder.cs index b46cf70..c2702ad 100644 --- a/src/Be.Vlaanderen.Basisregisters.EventHandling/Documentation/RegistryEventsMarkdownBuilder.cs +++ b/src/Be.Vlaanderen.Basisregisters.EventHandling/Documentation/RegistryEventsMarkdownBuilder.cs @@ -60,11 +60,9 @@ private static Func HasEventTags(IReadOnlyList requestedTa throw new ArgumentNullException(nameof(requestedTags)); return requestedTags.Count == 0 - ? (Func) AllowAllEvents + ? _ => true : HasAnyRequestedEventTag; - static bool AllowAllEvents(Type eventType) => true; - bool HasAnyRequestedEventTag(Type eventType) { var eventTags = eventType diff --git a/src/Be.Vlaanderen.Basisregisters.EventHandling/EventTag.cs b/src/Be.Vlaanderen.Basisregisters.EventHandling/EventTag.cs index d1a11da..ee55a5a 100644 --- a/src/Be.Vlaanderen.Basisregisters.EventHandling/EventTag.cs +++ b/src/Be.Vlaanderen.Basisregisters.EventHandling/EventTag.cs @@ -2,9 +2,9 @@ namespace Be.Vlaanderen.Basisregisters.EventHandling { using System; - public class EventTag + public sealed class EventTag { - public class For + public static class For { public const string Sync = "sync"; public const string Crab = "crab"; @@ -35,7 +35,7 @@ public static EventTag Create(string tagType) public override bool Equals(object? obj) => obj is EventTag tag && Equals(tag); - protected bool Equals(EventTag other) + private bool Equals(EventTag other) => _tagType == other._tagType; public override int GetHashCode()