Skip to content

Commit

Permalink
Fix nullability issues in AssemblyExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed May 31, 2023
1 parent 43815de commit 7c4241c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/BenchmarkDotNet/Extensions/AssemblyExtensions.cs
Expand Up @@ -6,21 +6,21 @@ namespace BenchmarkDotNet.Extensions
{
internal static class AssemblyExtensions
{
internal static bool? IsJitOptimizationDisabled(this Assembly assembly)
=> GetDebuggableAttribute(assembly).IsJitOptimizerDisabled();
internal static bool? IsJitOptimizationDisabled(this Assembly? assembly)
=> GetDebuggableAttribute(assembly)?.IsJitOptimizerDisabled();

internal static bool? IsDebug(this Assembly assembly)
=> GetDebuggableAttribute(assembly).IsJitTrackingEnabled();
internal static bool? IsDebug(this Assembly? assembly)
=> GetDebuggableAttribute(assembly)?.IsJitTrackingEnabled();

internal static bool IsTrue(this bool? valueOrNothing) => valueOrNothing.HasValue && valueOrNothing.Value;

private static DebuggableAttribute GetDebuggableAttribute(Assembly assembly)
private static DebuggableAttribute? GetDebuggableAttribute(Assembly? assembly)
=> assembly?.GetCustomAttributes()
.OfType<DebuggableAttribute>()
.SingleOrDefault();

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

private static bool? IsJitTrackingEnabled(this DebuggableAttribute attribute) => attribute?.IsJITTrackingEnabled;
private static bool? IsJitTrackingEnabled(this DebuggableAttribute? attribute) => attribute?.IsJITTrackingEnabled;
}
}

0 comments on commit 7c4241c

Please sign in to comment.