Skip to content

Commit 2e1774d

Browse files
timcassellAndreyAkinshin
authored andcommitted
Catch the NotSupportedException thrown in NativeAOT for GetReferencedAssemblies.
1 parent b725ac5 commit 2e1774d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/BenchmarkDotNet/Validators/JitOptimizationsValidator.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ public IEnumerable<ValidationError> Validate(ValidationParameters validationPara
1919
{
2020
foreach (var group in validationParameters.Benchmarks.GroupBy(benchmark => benchmark.Descriptor.Type.GetTypeInfo().Assembly))
2121
{
22-
foreach (var referencedAssemblyName in group.Key.GetReferencedAssemblies())
22+
// GetReferencedAssemblies() is not supported in NativeAOT currently.
23+
AssemblyName[] referencedAssemblies;
24+
try
25+
{
26+
referencedAssemblies = group.Key.GetReferencedAssemblies();
27+
}
28+
catch (NotSupportedException)
29+
{
30+
referencedAssemblies = Array.Empty<AssemblyName>();
31+
}
32+
foreach (var referencedAssemblyName in referencedAssemblies)
2333
{
2434
var referencedAssembly = Assembly.Load(referencedAssemblyName);
2535

0 commit comments

Comments
 (0)