From 13f53e406f4bdfd9fd6b322f214fc6f121d864d4 Mon Sep 17 00:00:00 2001 From: Daniel Marbach Date: Thu, 24 Aug 2023 22:25:23 +0200 Subject: [PATCH] No longer do ToLowerInvariant --- .../Hosting/Helpers/AssemblyScanner.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs index e5ab118189..658eae9651 100644 --- a/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs +++ b/src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs @@ -320,21 +320,20 @@ bool IsExcluded(string assemblyNameOrFileName) } static bool IsMatch(string expression1, string expression2) - => DistillLowerAssemblyName(expression1) == DistillLowerAssemblyName(expression2); + => string.Equals(RemoveFileExtensionIfNecessary(expression1),RemoveFileExtensionIfNecessary(expression2), StringComparison.OrdinalIgnoreCase); bool IsAllowedType(Type type) => type is { IsValueType: false } && Attribute.GetCustomAttribute(type, typeof(CompilerGeneratedAttribute), false) != null && !TypesToSkip.Contains(type); - static string DistillLowerAssemblyName(string assemblyOrFileName) + static string RemoveFileExtensionIfNecessary(string assemblyOrFileName) { - var lowerAssemblyName = assemblyOrFileName.ToLowerInvariant(); - if (lowerAssemblyName.EndsWith(".dll") || lowerAssemblyName.EndsWith(".exe")) + if (assemblyOrFileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || assemblyOrFileName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { - lowerAssemblyName = lowerAssemblyName.Substring(0, lowerAssemblyName.Length - 4); + return assemblyOrFileName[..^4]; } - return lowerAssemblyName; + return assemblyOrFileName; } void AddTypesToResult(Assembly assembly, AssemblyScannerResults results)