mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-18 07:00:04 +02:00
Add additional try-catch to TypeLoader logic (#1352)
This commit is contained in:
@@ -119,13 +119,21 @@ internal static class TypeLoader
|
|||||||
|
|
||||||
private static bool TryGetImplementationTypeByInterfaceAndOptionalFullName<T>(Assembly assembly, string? implementationTypeFullName, [NotNullWhen(true)] out Type? type)
|
private static bool TryGetImplementationTypeByInterfaceAndOptionalFullName<T>(Assembly assembly, string? implementationTypeFullName, [NotNullWhen(true)] out Type? type)
|
||||||
{
|
{
|
||||||
type = assembly
|
try
|
||||||
.GetTypes()
|
{
|
||||||
.FirstOrDefault(t =>
|
type = assembly
|
||||||
typeof(T).IsAssignableFrom(t) && !t.GetTypeInfo().IsInterface &&
|
.GetTypes()
|
||||||
(implementationTypeFullName == null || string.Equals(t.FullName, implementationTypeFullName, StringComparison.OrdinalIgnoreCase))
|
.FirstOrDefault(t =>
|
||||||
);
|
typeof(T).IsAssignableFrom(t) && !t.GetTypeInfo().IsInterface &&
|
||||||
|
(implementationTypeFullName == null || string.Equals(t.FullName, implementationTypeFullName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
);
|
||||||
|
|
||||||
return type != null;
|
return type != null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
type = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user