Skip to content

Commit d7d128d

Browse files
committed
refactor: rename BlacklistTypesInAssembly to BlacklistTypes for consistency and clarity; streamline type blacklisting logic
1 parent 8f03615 commit d7d128d

4 files changed

Lines changed: 10 additions & 25 deletions

File tree

ReflectorNet.Tests/src/ReflectorTests/IsTypeBlacklistedTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ public void BlacklistTypes_ByStringNames_AllInvalid_ReturnsFalse()
13191319
var reflector = new Reflector();
13201320

13211321
// Act - All invalid type names
1322-
var result = reflector.Converters.BlacklistTypesInAssembly(
1322+
var result = reflector.Converters.BlacklistTypes(
13231323
"This.Does.Not.Exist",
13241324
"Neither.Does.This");
13251325

@@ -1334,10 +1334,10 @@ public void BlacklistTypes_ByStringNames_AlreadyBlacklisted_ReturnsFalse()
13341334
{
13351335
// Arrange
13361336
var reflector = new Reflector();
1337-
reflector.Converters.BlacklistTypesInAssembly("System.String", "System.Int32");
1337+
reflector.Converters.BlacklistTypes("System.String", "System.Int32");
13381338

13391339
// Act - Try to add the same types again
1340-
var result = reflector.Converters.BlacklistTypesInAssembly("System.String", "System.Int32");
1340+
var result = reflector.Converters.BlacklistTypes("System.String", "System.Int32");
13411341

13421342
// Assert
13431343
Assert.False(result, "BlacklistTypes should return false when all types already blacklisted");

ReflectorNet/src/Reflector/Reflector.Registry.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,8 @@ public bool BlacklistTypesInAssembly(string assemblyNamePrefix, params string[]
217217
foreach (var typeFullName in typeFullNames)
218218
{
219219
var type = TypeUtils.GetType(assembly, typeFullName);
220-
if (type != null)
221-
{
222-
if (_blacklistedTypes.TryAdd(type, 0))
223-
changed = true;
224-
}
220+
if (type != null && _blacklistedTypes.TryAdd(type, 0))
221+
changed = true;
225222
}
226223
}
227224
if (changed)

ReflectorNet/src/Utils/TypeUtils.GetType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public static partial class TypeUtils
7777
/// </param>
7878
/// <param name="typeName">The name of the type to retrieve.</param>
7979
/// <returns>The <see cref="Type"/> corresponding to the specified name and assembly name prefix, or <see langword="null"/> if the type cannot be found.</returns>
80+
/// <remarks>
81+
/// Note: For generic types, only the generic type definition is required to be in an assembly whose name matches the
82+
/// specified prefix. Generic type arguments are resolved from all currently loaded assemblies, not only from assemblies
83+
/// whose names start with the provided prefix.
84+
/// </remarks>
8085
public static Type? GetType(string? assemblyName, string? typeName)
8186
{
8287
if (string.IsNullOrWhiteSpace(typeName))

ReflectorNet/src/Utils/TypeUtils.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)