From ea83585548ddbf076bfde1443cd141781efd8d7a Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:03:58 +0000 Subject: [PATCH 1/2] refactor: simplify linq query This PR refactors a LINQ query to improve readability and performance by using the overload of Count that accepts a predicate directly. Instead of filtering with `.Where()` and then calling `.Count()`, the predicate is now passed to `.Count()`, reducing intermediate allocations. - Consider simplifying LINQ query by dropping explicit `.Where()` call: The original code used `loggedEntries.Where(...).Count()`, which creates an unnecessary iterator. The patch replaces it with `loggedEntries.Count(l => l.Contains("No Value"))`, achieving the same result more concisely and efficiently. > This Autofix was generated by AI. Please review the change before merging. --- Shared.Tests/ConfigurationRootExtensionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared.Tests/ConfigurationRootExtensionsTests.cs b/Shared.Tests/ConfigurationRootExtensionsTests.cs index b418220..7e055f7 100644 --- a/Shared.Tests/ConfigurationRootExtensionsTests.cs +++ b/Shared.Tests/ConfigurationRootExtensionsTests.cs @@ -44,7 +44,7 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() String[] loggedEntries = this.FilterLogEntries(testLogger); Int32 expectedCount = TestHelpers.DefaultAppSettings.Count; // 5 headers loggedEntries.Length.ShouldBe(expectedCount, String.Join(Environment.NewLine, loggedEntries.ToArray())); - loggedEntries.Where(l => l.Contains("No Value")).Count().ShouldBe(1); + loggedEntries.Count(l => l.Contains("No Value")).ShouldBe(1); } private string[] FilterLogEntries(TestLogger testLogger) { From 36f8465a728862729a615815be83421f37ab043c Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:04:48 +0000 Subject: [PATCH 2/2] style: format code with dotnet-format This commit fixes the style issues introduced in ea83585 according to the output from dotnet-format. Details: https://github.com/TransactionProcessing/Shared/pull/384 --- Shared.Tests/ConfigurationRootExtensionsTests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Shared.Tests/ConfigurationRootExtensionsTests.cs b/Shared.Tests/ConfigurationRootExtensionsTests.cs index 7e055f7..d6093a3 100644 --- a/Shared.Tests/ConfigurationRootExtensionsTests.cs +++ b/Shared.Tests/ConfigurationRootExtensionsTests.cs @@ -20,8 +20,8 @@ public partial class SharedTests { #region Properties - - + + #endregion #region Methods @@ -47,7 +47,8 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() loggedEntries.Count(l => l.Contains("No Value")).ShouldBe(1); } - private string[] FilterLogEntries(TestLogger testLogger) { + private string[] FilterLogEntries(TestLogger testLogger) + { return testLogger.GetLogEntries().Where(l => !l.Contains("PSLockDownPolicy") && !String.IsNullOrEmpty(l)) .Where(l => !l.Contains("Configuration Section")) .Where(l => !l.Contains("CF_USER_TEXT_ENCODING")).ToArray();