From 7f7b6a617e82f23d54b9bb1825ebf625444e231e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 18:41:19 +0000 Subject: [PATCH 1/2] refactor: use trygetvalue for dictionary lookup This PR refactors dictionary access in the handler to use TryGetValue, reducing redundant lookups and improving readability and performance. - Consider using `.TryGetValue` to access elements in `Dictionary` The code originally checked for key existence with `ContainsKey` and then used the indexer to retrieve the value. This resulted in two lookups and less concise logic. By switching to `TryGetValue`, we combine the existence check and retrieval in a single operation, storing the result in a local variable and simplifying the conditional flow. > This Autofix was generated by AI. Please review the change before merging. --- .../Common/DomainEventTypesToSilentlyHandle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs index 487fac4..3d1b87d 100644 --- a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs +++ b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs @@ -42,9 +42,9 @@ public DomainEventTypesToSilentlyHandle(Dictionary handlerEven public Boolean HandleSilently(String handlerName, DomainEvent domainEvent) { - if (this.HandlerEventTypesToSilentlyHandle.ContainsKey(handlerName)) + if (this.HandlerEventTypesToSilentlyHandle.TryGetValue(handlerName, out var eventTypes)) { - if (this.HandlerEventTypesToSilentlyHandle[handlerName].Contains(domainEvent.GetType().FullName)) + if (eventTypes.Contains(domainEvent.GetType().FullName)) { return true; } From fa05e74872b375206df186527d5df419585f13d6 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 18:53:15 +0000 Subject: [PATCH 2/2] refactor: merge if conditions This PR refactors the conditional logic in the event handler by merging two nested `if` statements into a single combined check. The redundant inner block and braces have been removed, simplifying the code path and improving readability. - `if` conditions can be merged: The code originally checked for a handler key and then separately checked if the event type was present in the collection. These two nested `if` statements have been merged into one compound condition using a logical AND. As a result, the redundant block and braces are eliminated and the method now immediately returns true when both conditions are met. > This Autofix was generated by AI. Please review the change before merging. --- .../Common/DomainEventTypesToSilentlyHandle.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs index 3d1b87d..c05d1c6 100644 --- a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs +++ b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs @@ -42,12 +42,10 @@ public DomainEventTypesToSilentlyHandle(Dictionary handlerEven public Boolean HandleSilently(String handlerName, DomainEvent domainEvent) { - if (this.HandlerEventTypesToSilentlyHandle.TryGetValue(handlerName, out var eventTypes)) + if (this.HandlerEventTypesToSilentlyHandle.TryGetValue(handlerName, out var eventTypes) + && eventTypes.Contains(domainEvent.GetType().FullName)) { - if (eventTypes.Contains(domainEvent.GetType().FullName)) - { - return true; - } + return true; } return false;