Skip to content

Commit d118f30

Browse files
committed
Simplify type lookup
1 parent c851608 commit d118f30

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/DefaultBuilder/test/Microsoft.AspNetCore.TrimmingTests/X509Utilities.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ public static class X509Utilities
1414
public static bool HasCertificateType =>
1515
GetType("System.Security.Cryptography", "System.Security.Cryptography.X509Certificates.X509Certificate") is not null;
1616

17-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
17+
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2057:UnrecognizedReflectionPattern",
1818
Justification = "Returning null when the type is unreferenced is desirable")]
1919
private static Type? GetType(string assemblyName, string typeName) {
20-
var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name == assemblyName);
21-
return assembly?.GetType(typeName);
20+
return Type.GetType($"{typeName}, {assemblyName}");
2221
}
2322
}

0 commit comments

Comments
 (0)