Skip to content

Commit b473dd0

Browse files
committed
Fix #2740: Add nullability to HostEnvironmentInfo CpuInfo
1 parent 2b6d7c7 commit b473dd0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/BenchmarkDotNet/Analysers/ZeroMeasurementAnalyser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private ZeroMeasurementAnalyser() { }
1919

2020
protected override IEnumerable<Conclusion> AnalyseReport(BenchmarkReport report, Summary summary)
2121
{
22-
var currentFrequency = summary.HostEnvironmentInfo.Cpu.Value.MaxFrequency();
22+
var currentFrequency = summary.HostEnvironmentInfo.Cpu.Value?.MaxFrequency();
2323
if (!currentFrequency.HasValue || currentFrequency <= 0)
2424
currentFrequency = FallbackCpuResolutionValue.ToFrequency();
2525

src/BenchmarkDotNet/Environments/HostEnvironmentInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class HostEnvironmentInfo : BenchmarkEnvironmentInfo
3838
/// <summary>
3939
/// is expensive to call (1s)
4040
/// </summary>
41-
public Lazy<CpuInfo> Cpu { get; protected set; }
41+
public Lazy<CpuInfo?> Cpu { get; protected set; }
4242

4343
public Lazy<OsInfo> Os { get; protected set; }
4444

@@ -78,7 +78,7 @@ protected HostEnvironmentInfo()
7878
AntivirusProducts = new Lazy<ICollection<Antivirus>>(RuntimeInformation.GetAntivirusProducts);
7979
VirtualMachineHypervisor = new Lazy<VirtualMachineHypervisor>(RuntimeInformation.GetVirtualMachineHypervisor);
8080
Os = new Lazy<OsInfo>(OsDetector.GetOs);
81-
Cpu = new Lazy<CpuInfo>(CpuDetector.CrossPlatform.Detect);
81+
Cpu = new Lazy<CpuInfo?>(CpuDetector.CrossPlatform.Detect);
8282
}
8383

8484
public new static HostEnvironmentInfo GetCurrent() => current ??= new HostEnvironmentInfo();

0 commit comments

Comments
 (0)