Skip to content

Commit

Permalink
No longer do ToLowerInvariant
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Aug 24, 2023
1 parent 770d70a commit 13f53e4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 13f53e4

Please sign in to comment.