From ea97d102eced26a5fa4c0ffd0eda27349b809c87 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 20:08:02 +0000 Subject: [PATCH] refactor: remove redundant identity Select calls This PR refactors LINQ usage by removing unnecessary identity projections with `Select()`, resulting in simpler and more performant code. - Passing an identity function to `Select()` is redundant: In two spots, the code used `CurrentSubscriptions.Select(r => r)` and `eventHandlerConfiguration.Keys.Select(k => k)`, which returned the same elements without transformation. This change replaces the first with a direct `ToList()` call on the original collection and the second by using the `Keys` enumerable directly. > This Autofix was generated by AI. Please review the change before merging. --- Shared.EventStore/EventHandling/DomainEventHandlerResolver.cs | 2 +- Shared.EventStore/SubscriptionWorker/SubscriptionWorker.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Shared.EventStore/EventHandling/DomainEventHandlerResolver.cs b/Shared.EventStore/EventHandling/DomainEventHandlerResolver.cs index 8604a21..e5a81be 100644 --- a/Shared.EventStore/EventHandling/DomainEventHandlerResolver.cs +++ b/Shared.EventStore/EventHandling/DomainEventHandlerResolver.cs @@ -33,7 +33,7 @@ public DomainEventHandlerResolver(Dictionary eventHandlerConfi this.DomainEventHandlers = new Dictionary(); - IEnumerable distinctHandlers = eventHandlerConfiguration.Keys.Select(k => k); + IEnumerable distinctHandlers = eventHandlerConfiguration.Keys; foreach (String handlerTypeString in distinctHandlers) { diff --git a/Shared.EventStore/SubscriptionWorker/SubscriptionWorker.cs b/Shared.EventStore/SubscriptionWorker/SubscriptionWorker.cs index 9a76ea4..4102662 100644 --- a/Shared.EventStore/SubscriptionWorker/SubscriptionWorker.cs +++ b/Shared.EventStore/SubscriptionWorker/SubscriptionWorker.cs @@ -146,7 +146,7 @@ public async Task StopAsync(CancellationToken cancellationToken) this.IsRunning = false; - var temp = this.CurrentSubscriptions.Select(r => r).ToList(); + var temp = this.CurrentSubscriptions.ToList(); for (Int32 i = 0; i < temp.Count; i++) {