Skip to content

Commit 7dc0981

Browse files
Handle exceptions in GetDebuggableAttribute
1 parent c352b36 commit 7dc0981

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/BenchmarkDotNet/Extensions/AssemblyExtensions.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics;
1+
using System;
2+
using System.Diagnostics;
23
using System.Linq;
34
using System.Reflection;
45

@@ -15,9 +16,16 @@ internal static class AssemblyExtensions
1516
internal static bool IsTrue(this bool? valueOrNothing) => valueOrNothing.HasValue && valueOrNothing.Value;
1617

1718
private static DebuggableAttribute? GetDebuggableAttribute(Assembly? assembly)
18-
=> assembly?.GetCustomAttributes()
19-
.OfType<DebuggableAttribute>()
20-
.SingleOrDefault();
19+
{
20+
try
21+
{
22+
return assembly?.GetCustomAttributes().OfType<DebuggableAttribute>().SingleOrDefault();
23+
}
24+
catch (Exception)
25+
{
26+
return null;
27+
}
28+
}
2129

2230
private static bool? IsJitOptimizerDisabled(this DebuggableAttribute? attribute) => attribute?.IsJITOptimizerDisabled;
2331

0 commit comments

Comments
 (0)