diff --git a/build/common.props b/build/common.props
index 129b404c8a..77ec346892 100644
--- a/build/common.props
+++ b/build/common.props
@@ -16,6 +16,7 @@
false
false
+ true
True
$(MSBuildThisFileDirectory)CodingStyle.ruleset
true
@@ -57,7 +58,7 @@
$(Major).$(Minor).$(Revision).$(BuildNumber)$(PrereleaseLabel)
-
+
all
runtime; build; native; contentfiles; analyzers
@@ -67,8 +68,5 @@
all
-
- all
-
diff --git a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj
index f7d65aca25..4b37f5c950 100644
--- a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj
+++ b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj
@@ -14,11 +14,11 @@
+
-
diff --git a/src/BenchmarkDotNet/Analysers/AnalyserBase.cs b/src/BenchmarkDotNet/Analysers/AnalyserBase.cs
index ee9943dd37..dc6049f163 100644
--- a/src/BenchmarkDotNet/Analysers/AnalyserBase.cs
+++ b/src/BenchmarkDotNet/Analysers/AnalyserBase.cs
@@ -21,11 +21,11 @@ public IEnumerable Analyse(Summary summary)
[PublicAPI] protected virtual IEnumerable AnalyseSummary(Summary summary) => Enumerable.Empty();
[PublicAPI] protected virtual IEnumerable AnalyseReport(BenchmarkReport report, Summary summary) => Enumerable.Empty();
- protected Conclusion CreateHint(string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ protected Conclusion CreateHint(string message, BenchmarkReport? report = null, bool mergeable = true)
=> Conclusion.CreateHint(Id, message, report, mergeable);
- protected Conclusion CreateWarning(string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ protected Conclusion CreateWarning(string message, BenchmarkReport? report = null, bool mergeable = true)
=> Conclusion.CreateWarning(Id, message, report, mergeable);
- protected Conclusion CreateError(string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ protected Conclusion CreateError(string message, BenchmarkReport? report = null, bool mergeable = true)
=> Conclusion.CreateError(Id, message, report, mergeable);
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Analysers/Conclusion.cs b/src/BenchmarkDotNet/Analysers/Conclusion.cs
index d5179134b5..2ea3248316 100644
--- a/src/BenchmarkDotNet/Analysers/Conclusion.cs
+++ b/src/BenchmarkDotNet/Analysers/Conclusion.cs
@@ -7,23 +7,20 @@ namespace BenchmarkDotNet.Analysers
// TODO: Find a better name
public sealed class Conclusion : IEquatable
{
- [NotNull]
public string AnalyserId { get; }
public ConclusionKind Kind { get; }
public bool Mergeable { get; }
- [NotNull]
public string Message { get; }
- [CanBeNull]
- public BenchmarkReport Report { get; }
+ public BenchmarkReport? Report { get; }
- private Conclusion([NotNull] string analyserId,
+ private Conclusion(string analyserId,
ConclusionKind kind,
- [NotNull] string message,
- [CanBeNull] BenchmarkReport report,
+ string message,
+ BenchmarkReport? report,
bool mergeable)
{
AnalyserId = analyserId;
@@ -33,13 +30,13 @@ private Conclusion([NotNull] string analyserId,
Mergeable = mergeable;
}
- public static Conclusion CreateHint(string analyserId, string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ public static Conclusion CreateHint(string analyserId, string message, BenchmarkReport? report = null, bool mergeable = true)
=> new Conclusion(analyserId, ConclusionKind.Hint, message, report, mergeable);
- public static Conclusion CreateWarning(string analyserId, string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ public static Conclusion CreateWarning(string analyserId, string message, BenchmarkReport? report = null, bool mergeable = true)
=> new Conclusion(analyserId, ConclusionKind.Warning, message, report, mergeable);
- public static Conclusion CreateError(string analyserId, string message, [CanBeNull] BenchmarkReport report = null, bool mergeable = true)
+ public static Conclusion CreateError(string analyserId, string message, BenchmarkReport? report = null, bool mergeable = true)
=> new Conclusion(analyserId, ConclusionKind.Error, message, report, mergeable);
public bool Equals(Conclusion other)
diff --git a/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs b/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs
index 137174a6a1..a7278a156b 100644
--- a/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs
+++ b/src/BenchmarkDotNet/Analysers/MultimodalDistributionAnalyzer.cs
@@ -30,8 +30,7 @@ protected override IEnumerable AnalyseReport(BenchmarkReport report,
yield return Create("can have several modes", mValue, report, summary.GetCultureInfo());
}
- [NotNull]
- private Conclusion Create([NotNull] string kind, double mValue, [CanBeNull] BenchmarkReport report, CultureInfo cultureInfo)
+ private Conclusion Create(string kind, double mValue, BenchmarkReport? report, CultureInfo cultureInfo)
=> CreateWarning($"It seems that the distribution {kind} (mValue = {mValue.ToString("0.##", cultureInfo)})", report);
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs b/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs
index f4f5abea7d..6da2088e86 100644
--- a/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs
+++ b/src/BenchmarkDotNet/Analysers/OutliersAnalyser.cs
@@ -55,7 +55,7 @@ protected override IEnumerable AnalyseReport(BenchmarkReport report,
/// All upper outliers
/// CultureInfo
/// The message
- [PublicAPI, NotNull, Pure]
+ [PublicAPI, Pure]
public static string GetMessage(double[] actualOutliers, double[] allOutliers, double[] lowerOutliers, double[] upperOutliers, CultureInfo cultureInfo)
{
if (allOutliers.Length == 0)
@@ -80,8 +80,7 @@ string Format(int n, string verb)
return Format(actualOutliers.Length, "removed") + ", " + Format(allOutliers.Length, "detected") + rangeMessage;
}
- [CanBeNull]
- private static string GetRangeMessage([NotNull] double[] values, CultureInfo cultureInfo)
+ private static string? GetRangeMessage(double[] values, CultureInfo cultureInfo)
{
string Format(double value) => TimeInterval.FromNanoseconds(value).ToString(cultureInfo, "N2");
diff --git a/src/BenchmarkDotNet/BenchmarkDotNet.csproj b/src/BenchmarkDotNet/BenchmarkDotNet.csproj
index 190d3a9ba4..3838c4af94 100644
--- a/src/BenchmarkDotNet/BenchmarkDotNet.csproj
+++ b/src/BenchmarkDotNet/BenchmarkDotNet.csproj
@@ -4,6 +4,7 @@
BenchmarkDotNet
netstandard2.0;net6.0
true
+ annotations
$(NoWarn);1701;1702;1705;1591;3005;NU1702;CS3001;CS3003
BenchmarkDotNet
BenchmarkDotNet
@@ -22,16 +23,18 @@
-
-
-
-
-
+
+
+
+
+
+
+
@@ -48,7 +51,7 @@
-
+
diff --git a/src/BenchmarkDotNet/Characteristics/CharacteristicObject.cs b/src/BenchmarkDotNet/Characteristics/CharacteristicObject.cs
index 08ba87d988..b01f39e0fe 100644
--- a/src/BenchmarkDotNet/Characteristics/CharacteristicObject.cs
+++ b/src/BenchmarkDotNet/Characteristics/CharacteristicObject.cs
@@ -5,8 +5,6 @@
using System.Reflection;
using JetBrains.Annotations;
-using NotNullAttribute = JetBrains.Annotations.NotNullAttribute;
-
namespace BenchmarkDotNet.Characteristics
{
// TODO: better naming.
@@ -343,8 +341,8 @@ protected CharacteristicObject ApplyCore(CharacteristicObject other) =>
GetCharacteristicsToApply(other));
private CharacteristicObject ApplyCore(
- [CanBeNull] CharacteristicObject other,
- [NotNull] IEnumerable characteristicsToApply)
+ CharacteristicObject? other,
+ IEnumerable characteristicsToApply)
{
AssertNotFrozen();
diff --git a/src/BenchmarkDotNet/Columns/BaselineAllocationRatioColumn.cs b/src/BenchmarkDotNet/Columns/BaselineAllocationRatioColumn.cs
index c649b8c87f..cebccb09a2 100644
--- a/src/BenchmarkDotNet/Columns/BaselineAllocationRatioColumn.cs
+++ b/src/BenchmarkDotNet/Columns/BaselineAllocationRatioColumn.cs
@@ -63,8 +63,8 @@ private static bool IsNonBaselinesPrecise(Summary summary, IReadOnlyDictionary current,
- [CanBeNull] IReadOnlyDictionary baseline)
+ IReadOnlyDictionary? current,
+ IReadOnlyDictionary? baseline)
{
double? currentBytes = GetAllocatedBytes(current);
double? baselineBytes = GetAllocatedBytes(baseline);
@@ -78,7 +78,7 @@ private static bool IsNonBaselinesPrecise(Summary summary, IReadOnlyDictionary metrics)
+ private static double? GetAllocatedBytes(IReadOnlyDictionary? metrics)
{
var metric = metrics?.Values.FirstOrDefault(m => m.Descriptor is AllocatedMemoryMetricDescriptor);
return metric?.Value;
diff --git a/src/BenchmarkDotNet/Columns/BaselineRatioColumn.cs b/src/BenchmarkDotNet/Columns/BaselineRatioColumn.cs
index 4808a42821..450c1c22a3 100644
--- a/src/BenchmarkDotNet/Columns/BaselineRatioColumn.cs
+++ b/src/BenchmarkDotNet/Columns/BaselineRatioColumn.cs
@@ -118,8 +118,7 @@ private static bool IsNonBaselinesPrecise(Summary summary, Statistics baselineSt
return nonBaselines.Any(x => GetRatioStatistics(summary[x].ResultStatistics, baselineStat)?.Mean < 0.01);
}
- [CanBeNull]
- private static Statistics GetRatioStatistics([CanBeNull] Statistics current, [CanBeNull] Statistics baseline)
+ private static Statistics? GetRatioStatistics(Statistics? current, Statistics? baseline)
{
if (current == null || current.N < 1)
return null;
diff --git a/src/BenchmarkDotNet/Columns/SizeValue.cs b/src/BenchmarkDotNet/Columns/SizeValue.cs
index 46feaf9af1..9478989eb1 100644
--- a/src/BenchmarkDotNet/Columns/SizeValue.cs
+++ b/src/BenchmarkDotNet/Columns/SizeValue.cs
@@ -28,21 +28,21 @@ public SizeValue(long bytes, SizeUnit unit) : this(bytes * unit.ByteAmount) { }
[Pure] public static SizeValue operator *(SizeValue value, long k) => new SizeValue(value.Bytes * k);
[Pure] public static SizeValue operator *(long k, SizeValue value) => new SizeValue(value.Bytes * k);
- [Pure, NotNull]
+ [Pure]
public string ToString(
- [CanBeNull] CultureInfo cultureInfo,
- [CanBeNull] string format = "0.##",
- [CanBeNull] UnitPresentation unitPresentation = null)
+ CultureInfo? cultureInfo,
+ string? format = "0.##",
+ UnitPresentation? unitPresentation = null)
{
return ToString(null, cultureInfo, format, unitPresentation);
}
- [Pure, NotNull]
+ [Pure]
public string ToString(
- [CanBeNull] SizeUnit sizeUnit,
- [CanBeNull] CultureInfo cultureInfo,
- [CanBeNull] string format = "0.##",
- [CanBeNull] UnitPresentation unitPresentation = null)
+ SizeUnit? sizeUnit,
+ CultureInfo? cultureInfo,
+ string? format = "0.##",
+ UnitPresentation? unitPresentation = null)
{
sizeUnit = sizeUnit ?? SizeUnit.GetBestSizeUnit(Bytes);
cultureInfo = cultureInfo ?? DefaultCultureInfo.Instance;
diff --git a/src/BenchmarkDotNet/Configs/IConfig.cs b/src/BenchmarkDotNet/Configs/IConfig.cs
index f3847a6f4e..beb30a33e6 100644
--- a/src/BenchmarkDotNet/Configs/IConfig.cs
+++ b/src/BenchmarkDotNet/Configs/IConfig.cs
@@ -29,7 +29,7 @@ public interface IConfig
IEnumerable GetLogicalGroupRules();
IEnumerable GetColumnHidingRules();
- [CanBeNull] IOrderer Orderer { get; }
+ IOrderer? Orderer { get; }
SummaryStyle SummaryStyle { get; }
@@ -40,8 +40,7 @@ public interface IConfig
///
string ArtifactsPath { get; }
- [CanBeNull]
- CultureInfo CultureInfo { get; }
+ CultureInfo? CultureInfo { get; }
///
/// a set of custom flags that can enable/disable various settings
diff --git a/src/BenchmarkDotNet/Configs/ImmutableConfig.cs b/src/BenchmarkDotNet/Configs/ImmutableConfig.cs
index 185aa03f0e..d4a1cfd47a 100644
--- a/src/BenchmarkDotNet/Configs/ImmutableConfig.cs
+++ b/src/BenchmarkDotNet/Configs/ImmutableConfig.cs
@@ -80,7 +80,7 @@ internal ImmutableConfig(
public string ArtifactsPath { get; }
public CultureInfo CultureInfo { get; }
public ConfigOptions Options { get; }
- [NotNull] public IOrderer Orderer { get; }
+ public IOrderer Orderer { get; }
public SummaryStyle SummaryStyle { get; }
public TimeSpan BuildTimeout { get; }
diff --git a/src/BenchmarkDotNet/ConsoleArguments/CorrectionsSuggester.cs b/src/BenchmarkDotNet/ConsoleArguments/CorrectionsSuggester.cs
index e77d373f8d..dbc471c969 100644
--- a/src/BenchmarkDotNet/ConsoleArguments/CorrectionsSuggester.cs
+++ b/src/BenchmarkDotNet/ConsoleArguments/CorrectionsSuggester.cs
@@ -32,7 +32,7 @@ public CorrectionsSuggester(IReadOnlyList types)
}
}
- public string[] SuggestFor([NotNull] string userInput)
+ public string[] SuggestFor(string userInput)
{
if (userInput == null)
throw new ArgumentNullException(nameof(userInput));
diff --git a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs
index 86c7c5bdbd..cc9f535027 100644
--- a/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs
+++ b/src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs
@@ -133,7 +133,7 @@ public IEnumerable Validate(ValidationParameters validationPara
private static bool ShouldUseMonoDisassembler(BenchmarkCase benchmarkCase)
=> benchmarkCase.Job.Environment.Runtime is MonoRuntime || RuntimeInformation.IsMono;
- // when we add macOS support, RuntimeInformation.IsMacOSX() needs to be added here
+ // when we add macOS support, RuntimeInformation.IsMacOS() needs to be added here
private static bool ShouldUseClrMdDisassembler(BenchmarkCase benchmarkCase)
=> !ShouldUseMonoDisassembler(benchmarkCase) && (RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux());
diff --git a/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs b/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs
index 75868a9ca3..30fc072722 100644
--- a/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs
+++ b/src/BenchmarkDotNet/Disassemblers/MonoDisassembler.cs
@@ -50,7 +50,7 @@ private static string GetLlvmFlag(Job job) =>
internal static class OutputParser
{
- internal static DisassemblyResult Parse([ItemCanBeNull] IReadOnlyList input, string methodName, string commandLine)
+ internal static DisassemblyResult Parse(IReadOnlyList input, string methodName, string commandLine)
{
var instructions = new List();
@@ -101,7 +101,7 @@ internal static DisassemblyResult Parse([ItemCanBeNull] IReadOnlyList in
};
}
- private static DisassemblyResult CreateErrorResult([ItemCanBeNull] IReadOnlyList input,
+ private static DisassemblyResult CreateErrorResult(IReadOnlyList input,
string methodName, string commandLine, string message)
{
return new DisassemblyResult
diff --git a/src/BenchmarkDotNet/Engines/EnginePilotStage.cs b/src/BenchmarkDotNet/Engines/EnginePilotStage.cs
index 1bf3e34d54..8f43f0121f 100644
--- a/src/BenchmarkDotNet/Engines/EnginePilotStage.cs
+++ b/src/BenchmarkDotNet/Engines/EnginePilotStage.cs
@@ -14,10 +14,9 @@ internal class EnginePilotStage : EngineStage
public readonly struct PilotStageResult
{
public long PerfectInvocationCount { get; }
- [NotNull]
public IReadOnlyList Measurements { get; }
- public PilotStageResult(long perfectInvocationCount, [NotNull] List measurements)
+ public PilotStageResult(long perfectInvocationCount, List measurements)
{
PerfectInvocationCount = perfectInvocationCount;
Measurements = measurements;
diff --git a/src/BenchmarkDotNet/Engines/IEngine.cs b/src/BenchmarkDotNet/Engines/IEngine.cs
index c502a97e16..e35b870d8b 100644
--- a/src/BenchmarkDotNet/Engines/IEngine.cs
+++ b/src/BenchmarkDotNet/Engines/IEngine.cs
@@ -3,36 +3,28 @@
using BenchmarkDotNet.Characteristics;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
-using JetBrains.Annotations;
-using NotNullAttribute = JetBrains.Annotations.NotNullAttribute;
namespace BenchmarkDotNet.Engines
{
[SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")]
public interface IEngine : IDisposable
{
- [NotNull]
IHost Host { get; }
void WriteLine();
void WriteLine(string line);
- [NotNull]
Job TargetJob { get; }
long OperationsPerInvoke { get; }
- [CanBeNull]
- Action GlobalSetupAction { get; }
+ Action? GlobalSetupAction { get; }
- [CanBeNull]
- Action GlobalCleanupAction { get; }
+ Action? GlobalCleanupAction { get; }
- [NotNull]
Action WorkloadAction { get; }
- [NotNull]
Action OverheadAction { get; }
IResolver Resolver { get; }
diff --git a/src/BenchmarkDotNet/Engines/RunResults.cs b/src/BenchmarkDotNet/Engines/RunResults.cs
index ff49488707..36e014d1ec 100644
--- a/src/BenchmarkDotNet/Engines/RunResults.cs
+++ b/src/BenchmarkDotNet/Engines/RunResults.cs
@@ -14,16 +14,16 @@ public struct RunResults
{
private readonly OutlierMode outlierMode;
- [NotNull, PublicAPI]
+ [PublicAPI]
public IReadOnlyList EngineMeasurements { get; }
- [CanBeNull, PublicAPI]
- public IReadOnlyList Overhead
+ [PublicAPI]
+ public IReadOnlyList? Overhead
=> EngineMeasurements
.Where(m => m.Is(IterationMode.Overhead, IterationStage.Actual))
.ToArray();
- [NotNull, PublicAPI]
+ [PublicAPI]
public IReadOnlyList Workload
=> EngineMeasurements
.Where(m => m.Is(IterationMode.Workload, IterationStage.Actual))
@@ -35,7 +35,7 @@ public IReadOnlyList Workload
public double ExceptionFrequency { get; }
- public RunResults([NotNull] IReadOnlyList engineMeasurements,
+ public RunResults(IReadOnlyList engineMeasurements,
OutlierMode outlierMode,
GcStats gcStats,
ThreadingStats threadingStats,
diff --git a/src/BenchmarkDotNet/Engines/StoppingCriteria/IStoppingCriteria.cs b/src/BenchmarkDotNet/Engines/StoppingCriteria/IStoppingCriteria.cs
index 6030739ebe..86459e6548 100644
--- a/src/BenchmarkDotNet/Engines/StoppingCriteria/IStoppingCriteria.cs
+++ b/src/BenchmarkDotNet/Engines/StoppingCriteria/IStoppingCriteria.cs
@@ -12,12 +12,11 @@ public interface IStoppingCriteria
///
/// Checks do we have enough iterations
///
- StoppingResult Evaluate([NotNull] IReadOnlyList measurements);
+ StoppingResult Evaluate(IReadOnlyList measurements);
///
/// Title which can be used in logs and diagnostics methods
///
- [NotNull]
string Title { get; }
///
@@ -30,7 +29,6 @@ public interface IStoppingCriteria
///
/// An array of user-friendly warnings which notify about incorrect parameters.
///
- [NotNull]
IReadOnlyList Warnings { get; }
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingCriteriaBase.cs b/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingCriteriaBase.cs
index fd50c2d1e0..b79591b15d 100644
--- a/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingCriteriaBase.cs
+++ b/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingCriteriaBase.cs
@@ -25,12 +25,10 @@ protected StoppingCriteriaBase()
public abstract StoppingResult Evaluate(IReadOnlyList measurements);
- [NotNull]
protected abstract string GetTitle();
protected abstract int GetMaxIterationCount();
- [NotNull]
protected abstract IEnumerable GetWarnings();
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingResult.cs b/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingResult.cs
index a0c2a55b01..d37b3c00b7 100644
--- a/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingResult.cs
+++ b/src/BenchmarkDotNet/Engines/StoppingCriteria/StoppingResult.cs
@@ -6,16 +6,15 @@ public struct StoppingResult
{
public readonly bool IsFinished;
- [CanBeNull]
- public readonly string Message;
+ public readonly string? Message;
- private StoppingResult(bool isFinished, [CanBeNull] string message)
+ private StoppingResult(bool isFinished, string? message)
{
IsFinished = isFinished;
Message = message;
}
public static readonly StoppingResult NotFinished = new StoppingResult(false, null);
- public static StoppingResult CreateFinished([NotNull] string message) => new StoppingResult(true, message);
+ public static StoppingResult CreateFinished(string message) => new StoppingResult(true, message);
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Environments/OsBrandStringHelper.cs b/src/BenchmarkDotNet/Environments/OsBrandStringHelper.cs
index f529109531..aa2ab52f32 100644
--- a/src/BenchmarkDotNet/Environments/OsBrandStringHelper.cs
+++ b/src/BenchmarkDotNet/Environments/OsBrandStringHelper.cs
@@ -4,7 +4,6 @@
using System.Linq;
using JetBrains.Annotations;
using BenchmarkDotNet.Extensions;
-using NotNullAttribute = JetBrains.Annotations.NotNullAttribute;
namespace BenchmarkDotNet.Environments
{
@@ -108,16 +107,16 @@ public class OsBrandStringHelper
private class Windows1XVersion
{
- [CanBeNull] private string CodeVersion { get; }
- [CanBeNull] private string CodeName { get; }
- [CanBeNull] private string MarketingName { get; }
+ private string? CodeVersion { get; }
+ private string? CodeName { get; }
+ private string? MarketingName { get; }
private int BuildNumber { get; }
- [NotNull] private string MarketingNumber => BuildNumber >= 22000 ? "11" : "10";
- [CanBeNull] private string ShortifiedCodeName => CodeName?.Replace(" ", "");
- [CanBeNull] private string ShortifiedMarketingName => MarketingName?.Replace(" ", "");
+ private string MarketingNumber => BuildNumber >= 22000 ? "11" : "10";
+ private string? ShortifiedCodeName => CodeName?.Replace(" ", "");
+ private string? ShortifiedMarketingName => MarketingName?.Replace(" ", "");
- private Windows1XVersion([CanBeNull] string codeVersion, [CanBeNull] string codeName, [CanBeNull] string marketingName, int buildNumber)
+ private Windows1XVersion(string? codeVersion, string? codeName, string? marketingName, int buildNumber)
{
CodeVersion = codeVersion;
CodeName = codeName;
@@ -125,7 +124,7 @@ private Windows1XVersion([CanBeNull] string codeVersion, [CanBeNull] string code
BuildNumber = buildNumber;
}
- private string ToFullVersion([CanBeNull] int? ubr = null)
+ private string ToFullVersion(int? ubr = null)
=> ubr == null ? $"10.0.{BuildNumber}" : $"10.0.{BuildNumber}.{ubr}";
private static string Collapse(params string[] values) => string.Join("/", values.Where(v => !string.IsNullOrEmpty(v)));
@@ -133,7 +132,7 @@ private string ToFullVersion([CanBeNull] int? ubr = null)
// The line with OsBrandString is one of the longest lines in the summary.
// When people past in on GitHub, it can be a reason of an ugly horizontal scrollbar.
// To avoid this, we are trying to minimize this line and use the minimum possible number of characters.
- public string ToPrettifiedString([CanBeNull] int? ubr)
+ public string ToPrettifiedString(int? ubr)
=> CodeVersion == ShortifiedCodeName
? $"{MarketingNumber} ({Collapse(ToFullVersion(ubr), CodeVersion, ShortifiedMarketingName)})"
: $"{MarketingNumber} ({Collapse(ToFullVersion(ubr), CodeVersion, ShortifiedMarketingName, ShortifiedCodeName)})";
@@ -161,8 +160,7 @@ public string ToPrettifiedString([CanBeNull] int? ubr)
new Windows1XVersion("21H2", "21H2", null, 22000),
};
- [CanBeNull]
- public static Windows1XVersion Resolve([NotNull] string osVersionString)
+ public static Windows1XVersion? Resolve(string osVersionString)
{
var windows1XVersion = WellKnownVersions.FirstOrDefault(v => osVersionString == $"10.0.{v.BuildNumber}");
if (windows1XVersion != null)
@@ -183,16 +181,14 @@ public static Windows1XVersion Resolve([NotNull] string osVersionString)
/// Original operation system version
/// UBR (Update Build Revision), the revision number of Windows version (if available)
/// Prettified operation system title
- [NotNull]
- public static string Prettify([NotNull] string osName, [NotNull] string osVersion, [CanBeNull] int? windowsUbr = null)
+ public static string Prettify(string osName, string osVersion, int? windowsUbr = null)
{
if (osName == "Windows")
return PrettifyWindows(osVersion, windowsUbr);
return $"{osName} {osVersion}";
}
- [NotNull]
- private static string PrettifyWindows([NotNull] string osVersion, [CanBeNull] int? windowsUbr)
+ private static string PrettifyWindows(string osVersion, int? windowsUbr)
{
var windows1XVersion = Windows1XVersion.Resolve(osVersion);
if (windows1XVersion != null)
@@ -209,9 +205,9 @@ private static string PrettifyWindows([NotNull] string osVersion, [CanBeNull] in
private class MacOSXVersion
{
private int DarwinVersion { get; }
- [NotNull]private string CodeName { get; }
+ private string CodeName { get; }
- private MacOSXVersion(int darwinVersion, [NotNull] string codeName)
+ private MacOSXVersion(int darwinVersion, string codeName)
{
DarwinVersion = darwinVersion;
CodeName = codeName;
@@ -237,8 +233,7 @@ private MacOSXVersion(int darwinVersion, [NotNull] string codeName)
new MacOSXVersion(21, "Monterey")
};
- [CanBeNull]
- public static string ResolveCodeName([NotNull] string kernelVersion)
+ public static string? ResolveCodeName(string kernelVersion)
{
if (string.IsNullOrWhiteSpace(kernelVersion))
return null;
@@ -257,8 +252,7 @@ public static string ResolveCodeName([NotNull] string kernelVersion)
}
}
- [NotNull]
- public static string PrettifyMacOSX([NotNull] string systemVersion, [NotNull] string kernelVersion)
+ public static string PrettifyMacOSX(string systemVersion, string kernelVersion)
{
string codeName = MacOSXVersion.ResolveCodeName(kernelVersion);
if (codeName != null)
diff --git a/src/BenchmarkDotNet/Environments/ProcessorBrandStringHelper.cs b/src/BenchmarkDotNet/Environments/ProcessorBrandStringHelper.cs
index a8d2a679bb..8e3688a25b 100644
--- a/src/BenchmarkDotNet/Environments/ProcessorBrandStringHelper.cs
+++ b/src/BenchmarkDotNet/Environments/ProcessorBrandStringHelper.cs
@@ -5,9 +5,7 @@
using System.Text.RegularExpressions;
using BenchmarkDotNet.Helpers;
using BenchmarkDotNet.Portability.Cpu;
-using JetBrains.Annotations;
using Perfolizer.Horology;
-using NotNullAttribute = JetBrains.Annotations.NotNullAttribute;
namespace BenchmarkDotNet.Environments
{
@@ -19,7 +17,6 @@ public static class ProcessorBrandStringHelper
/// The CPU information
/// Whether to include determined max frequency information
/// Prettified version
- [NotNull]
public static string Prettify(CpuInfo cpuInfo, bool includeMaxFrequency = false)
{
if (cpuInfo == null || string.IsNullOrEmpty(cpuInfo.ProcessorName))
@@ -68,8 +65,7 @@ private static string GetBrandStyledActualFrequency(Frequency? frequency)
/// Parse a processor name and tries to return a microarchitecture name.
/// Works only for well-known microarchitectures.
///
- [CanBeNull]
- private static string ParseMicroarchitecture([NotNull] string processorName)
+ private static string? ParseMicroarchitecture(string processorName)
{
if (processorName.StartsWith("Intel Core"))
{
@@ -121,9 +117,8 @@ private static string ParseMicroarchitecture([NotNull] string processorName)
});
// see http://www.intel.com/content/www/us/en/processors/processor-numbers.html
- [CanBeNull]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
- internal static string ParseIntelCoreMicroarchitecture([NotNull] string modelNumber)
+ internal static string? ParseIntelCoreMicroarchitecture(string modelNumber)
{
if (KnownMicroarchitectures.Value.ContainsKey(modelNumber))
return KnownMicroarchitectures.Value[modelNumber];
diff --git a/src/BenchmarkDotNet/Exporters/Csv/CsvHelper.cs b/src/BenchmarkDotNet/Exporters/Csv/CsvHelper.cs
index 69fbb275fa..7e81583426 100644
--- a/src/BenchmarkDotNet/Exporters/Csv/CsvHelper.cs
+++ b/src/BenchmarkDotNet/Exporters/Csv/CsvHelper.cs
@@ -10,8 +10,7 @@ public static class CsvHelper
private const string TwoQuotes = "\"\"";
private static readonly char[] ForbiddenSymbols = { '\n', '\r', '"', ',' };
- [NotNull]
- public static string Escape([CanBeNull] string value, string currentListSeparator)
+ public static string Escape(string? value, string currentListSeparator)
{
if (value == null)
return string.Empty;
diff --git a/src/BenchmarkDotNet/Extensions/CommonExtensions.cs b/src/BenchmarkDotNet/Extensions/CommonExtensions.cs
index 72a423c016..a753787c53 100644
--- a/src/BenchmarkDotNet/Extensions/CommonExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/CommonExtensions.cs
@@ -42,7 +42,7 @@ public static void AddRange(this HashSet hashSet, IEnumerable collectio
hashSet.Add(item);
}
-#if NETSTANDARD
+#if NETSTANDARD2_0
public static TValue GetValueOrDefault(this IDictionary dictionary, TKey key)
=> dictionary.TryGetValue(key, out var value) ? value : default;
#endif
diff --git a/src/BenchmarkDotNet/Extensions/CultureInfoExtensions.cs b/src/BenchmarkDotNet/Extensions/CultureInfoExtensions.cs
index eac9893a1d..fb1e5df368 100644
--- a/src/BenchmarkDotNet/Extensions/CultureInfoExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/CultureInfoExtensions.cs
@@ -6,8 +6,7 @@ namespace BenchmarkDotNet.Extensions
{
internal static class CultureInfoExtensions
{
- [NotNull]
- public static string GetActualListSeparator([CanBeNull] this CultureInfo cultureInfo)
+ public static string GetActualListSeparator(this CultureInfo? cultureInfo)
{
cultureInfo = cultureInfo ?? DefaultCultureInfo.Instance;
string listSeparator = cultureInfo.TextInfo.ListSeparator;
diff --git a/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs b/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
index 5c0ae5e82f..0f5f2e5c5f 100644
--- a/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
@@ -53,9 +53,9 @@ private static IntPtr FixAffinity(IntPtr processorAffinity)
}
public static bool TrySetPriority(
- [NotNull] this Process process,
+ this Process process,
ProcessPriorityClass priority,
- [NotNull] ILogger logger)
+ ILogger logger)
{
if (process == null)
throw new ArgumentNullException(nameof(process));
@@ -77,9 +77,9 @@ public static bool TrySetPriority(
}
public static bool TrySetAffinity(
- [NotNull] this Process process,
+ this Process process,
IntPtr processorAffinity,
- [NotNull] ILogger logger)
+ ILogger logger)
{
if (process == null)
throw new ArgumentNullException(nameof(process));
@@ -103,7 +103,7 @@ public static bool TrySetAffinity(
return false;
}
- public static IntPtr? TryGetAffinity([NotNull] this Process process)
+ public static IntPtr? TryGetAffinity(this Process process)
{
if (process == null)
throw new ArgumentNullException(nameof(process));
diff --git a/src/BenchmarkDotNet/Helpers/AsciiHelper.cs b/src/BenchmarkDotNet/Helpers/AsciiHelper.cs
index 7c19c7eeef..c01d6c4e18 100644
--- a/src/BenchmarkDotNet/Helpers/AsciiHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/AsciiHelper.cs
@@ -9,7 +9,7 @@ internal static class AsciiHelper
///
private const string Mu = "\u03BC";
- public static string ToAscii([CanBeNull] this string s)
+ public static string ToAscii(this string? s)
{
// We should replace all non-ASCII symbols that used in BenchmarkDotNet by ASCII-compatible analogues
return s?.Replace(Mu, "u");
diff --git a/src/BenchmarkDotNet/Helpers/ExternalToolsHelper.cs b/src/BenchmarkDotNet/Helpers/ExternalToolsHelper.cs
index 57adabd6ba..3802608047 100644
--- a/src/BenchmarkDotNet/Helpers/ExternalToolsHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/ExternalToolsHelper.cs
@@ -11,7 +11,7 @@ public static class ExternalToolsHelper
/// MacOSX only.
///
public static readonly Lazy> MacSystemProfilerData =
- LazyParse(RuntimeInformation.IsMacOSX, "system_profiler", "SPSoftwareDataType", s => SectionsHelper.ParseSection(s, ':'));
+ LazyParse(RuntimeInformation.IsMacOS, "system_profiler", "SPSoftwareDataType", s => SectionsHelper.ParseSection(s, ':'));
private static Lazy LazyParse(Func isAvailable, string fileName, string arguments, Func parseFunc)
{
diff --git a/src/BenchmarkDotNet/Helpers/ProcessHelper.cs b/src/BenchmarkDotNet/Helpers/ProcessHelper.cs
index 69e20b7f52..918abdb840 100644
--- a/src/BenchmarkDotNet/Helpers/ProcessHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/ProcessHelper.cs
@@ -13,8 +13,7 @@ internal static class ProcessHelper
/// Run external process and return the console output.
/// In the case of any exception, null will be returned.
///
- [CanBeNull]
- internal static string RunAndReadOutput(string fileName, string arguments = "", ILogger logger = null)
+ internal static string? RunAndReadOutput(string fileName, string arguments = "", ILogger logger = null)
{
var processStartInfo = new ProcessStartInfo
{
diff --git a/src/BenchmarkDotNet/Helpers/SectionsHelper.cs b/src/BenchmarkDotNet/Helpers/SectionsHelper.cs
index 10cb5b04c7..cb87e90bcf 100644
--- a/src/BenchmarkDotNet/Helpers/SectionsHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/SectionsHelper.cs
@@ -8,8 +8,7 @@ namespace BenchmarkDotNet.Helpers
{
internal static class SectionsHelper
{
- [NotNull]
- public static Dictionary ParseSection([CanBeNull] string content, char separator)
+ public static Dictionary ParseSection(string? content, char separator)
{
var values = new Dictionary();
var list = content?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
@@ -24,8 +23,7 @@ public static Dictionary ParseSection([CanBeNull] string content
return values;
}
- [NotNull]
- public static List> ParseSections([CanBeNull] string content, char separator)
+ public static List> ParseSections(string? content, char separator)
{
// wmic doubles the carriage return character due to a bug.
// Therefore, the * quantifier should be used to workaround it.
diff --git a/src/BenchmarkDotNet/Jobs/EnvironmentVariable.cs b/src/BenchmarkDotNet/Jobs/EnvironmentVariable.cs
index 96ecaf9b1a..97c1ec4226 100644
--- a/src/BenchmarkDotNet/Jobs/EnvironmentVariable.cs
+++ b/src/BenchmarkDotNet/Jobs/EnvironmentVariable.cs
@@ -5,16 +5,14 @@ namespace BenchmarkDotNet.Jobs
{
public class EnvironmentVariable : IEquatable
{
- public EnvironmentVariable([NotNull] string key, [NotNull] string value)
+ public EnvironmentVariable(string key, string value)
{
Key = key ?? throw new ArgumentNullException(nameof(key));
Value = value ?? throw new ArgumentNullException(nameof(value));
}
- [NotNull]
public string Key { get; }
- [NotNull]
public string Value { get; }
// CharacteristicPresenters call ToString(), this is why we need this override
diff --git a/src/BenchmarkDotNet/Jobs/JobExtensions.cs b/src/BenchmarkDotNet/Jobs/JobExtensions.cs
index ca731ad723..8cbf7445d7 100644
--- a/src/BenchmarkDotNet/Jobs/JobExtensions.cs
+++ b/src/BenchmarkDotNet/Jobs/JobExtensions.cs
@@ -315,7 +315,7 @@ public static Job WithEnvironmentVariable(this Job job, EnvironmentVariable envi
/// The key of the new environment variable
/// The value of the new environment variable
/// The new job with additional environment variable
- public static Job WithEnvironmentVariable(this Job job, [NotNull] string key, [NotNull] string value)
+ public static Job WithEnvironmentVariable(this Job job, string key, string value)
=> job.WithEnvironmentVariable(new EnvironmentVariable(key, value));
///
diff --git a/src/BenchmarkDotNet/Mathematics/PercentileValues.cs b/src/BenchmarkDotNet/Mathematics/PercentileValues.cs
index 214628c37e..34abe47430 100644
--- a/src/BenchmarkDotNet/Mathematics/PercentileValues.cs
+++ b/src/BenchmarkDotNet/Mathematics/PercentileValues.cs
@@ -86,7 +86,7 @@ public string ToString(Func formatter)
return builder.ToString();
}
- public string ToString([CanBeNull] CultureInfo cultureInfo, string format = "0.##")
+ public string ToString(CultureInfo? cultureInfo, string format = "0.##")
{
return ToString(x => x.ToString(format, cultureInfo));
}
diff --git a/src/BenchmarkDotNet/Mathematics/RankHelper.cs b/src/BenchmarkDotNet/Mathematics/RankHelper.cs
index 957a5df3dd..08bb60b7a4 100644
--- a/src/BenchmarkDotNet/Mathematics/RankHelper.cs
+++ b/src/BenchmarkDotNet/Mathematics/RankHelper.cs
@@ -8,7 +8,7 @@ namespace BenchmarkDotNet.Mathematics
{
internal static class RankHelper
{
- public static int[] GetRanks([ItemNotNull] params Statistics[] stats)
+ public static int[] GetRanks(params Statistics[] stats)
{
var values = stats.
Select((s, index) => new { Stats = s, Index = index }).
diff --git a/src/BenchmarkDotNet/Mathematics/Statistics.cs b/src/BenchmarkDotNet/Mathematics/Statistics.cs
index cff67ce8f5..35743d009c 100644
--- a/src/BenchmarkDotNet/Mathematics/Statistics.cs
+++ b/src/BenchmarkDotNet/Mathematics/Statistics.cs
@@ -103,7 +103,7 @@ public bool IsActualOutlier(double value, OutlierMode outlierMode)
}
}
- [PublicAPI, NotNull]
+ [PublicAPI]
public double[] GetActualOutliers(OutlierMode outlierMode)
{
switch (outlierMode)
@@ -152,7 +152,7 @@ public override string ToString()
///
/// Mean for [X/Y].
///
- public static double DivMean([CanBeNull] Statistics x, [CanBeNull] Statistics y)
+ public static double DivMean(Statistics? x, Statistics? y)
{
if (x == null || y == null)
return double.NaN;
@@ -162,8 +162,7 @@ public static double DivMean([CanBeNull] Statistics x, [CanBeNull] Statistics y)
return MulMean(x, yInvert);
}
- [NotNull]
- public static Statistics Divide([NotNull] Statistics x, [NotNull] Statistics y)
+ public static Statistics Divide(Statistics x, Statistics y)
{
if (x.N < 1)
throw new ArgumentOutOfRangeException(nameof(x), "Argument doesn't contain any values");
diff --git a/src/BenchmarkDotNet/Order/IOrderer.cs b/src/BenchmarkDotNet/Order/IOrderer.cs
index c0684c4954..dece54e519 100644
--- a/src/BenchmarkDotNet/Order/IOrderer.cs
+++ b/src/BenchmarkDotNet/Order/IOrderer.cs
@@ -10,19 +10,19 @@ namespace BenchmarkDotNet.Order
{
public interface IOrderer
{
- [PublicAPI, NotNull]
+ [PublicAPI]
IEnumerable GetExecutionOrder(ImmutableArray benchmarksCase, IEnumerable order = null);
- [PublicAPI, NotNull]
- IEnumerable GetSummaryOrder(ImmutableArray benchmarksCases, [NotNull] Summary summary);
+ [PublicAPI]
+ IEnumerable GetSummaryOrder(ImmutableArray benchmarksCases, Summary summary);
- [PublicAPI, CanBeNull]
- string GetHighlightGroupKey([NotNull] BenchmarkCase benchmarkCase);
+ [PublicAPI]
+ string? GetHighlightGroupKey(BenchmarkCase benchmarkCase);
- [PublicAPI, CanBeNull]
- string GetLogicalGroupKey(ImmutableArray allBenchmarksCases, [NotNull] BenchmarkCase benchmarkCase);
+ [PublicAPI]
+ string? GetLogicalGroupKey(ImmutableArray allBenchmarksCases, BenchmarkCase benchmarkCase);
- [PublicAPI, NotNull]
+ [PublicAPI]
IEnumerable> GetLogicalGroupOrder(IEnumerable> logicalGroups,
IEnumerable order = null);
diff --git a/src/BenchmarkDotNet/Portability/Cpu/MosCpuInfoProvider.cs b/src/BenchmarkDotNet/Portability/Cpu/MosCpuInfoProvider.cs
index 7c47762855..59b0524014 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/MosCpuInfoProvider.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/MosCpuInfoProvider.cs
@@ -14,7 +14,6 @@ internal static class MosCpuInfoProvider
#endif
internal static readonly Lazy MosCpuInfo = new Lazy(Load);
- [NotNull]
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
diff --git a/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoParser.cs b/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoParser.cs
index cdd68a1282..9de9e26b35 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoParser.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoParser.cs
@@ -9,8 +9,7 @@ namespace BenchmarkDotNet.Portability.Cpu
{
internal static class ProcCpuInfoParser
{
- [NotNull]
- internal static CpuInfo ParseOutput([CanBeNull] string content)
+ internal static CpuInfo ParseOutput(string? content)
{
var logicalCores = SectionsHelper.ParseSections(content, ':');
var processorModelNames = new HashSet();
diff --git a/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoProvider.cs b/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoProvider.cs
index 36707e4766..6e4ab2d6e9 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoProvider.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/ProcCpuInfoProvider.cs
@@ -14,8 +14,7 @@ internal static class ProcCpuInfoProvider
{
internal static readonly Lazy ProcCpuInfo = new Lazy(Load);
- [CanBeNull]
- private static CpuInfo Load()
+ private static CpuInfo? Load()
{
if (RuntimeInformation.IsLinux())
{
diff --git a/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoParser.cs b/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoParser.cs
index facd1ebb5a..7e61bbd3ec 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoParser.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoParser.cs
@@ -1,17 +1,14 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using BenchmarkDotNet.Helpers;
-using JetBrains.Annotations;
using BenchmarkDotNet.Extensions;
-using NotNullAttribute = JetBrains.Annotations.NotNullAttribute;
namespace BenchmarkDotNet.Portability.Cpu
{
internal static class SysctlCpuInfoParser
{
- [NotNull]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
- internal static CpuInfo ParseOutput([CanBeNull] string content)
+ internal static CpuInfo ParseOutput(string? content)
{
var sysctl = SectionsHelper.ParseSection(content, ':');
string processorName = sysctl.GetValueOrDefault("machdep.cpu.brand_string");
@@ -24,8 +21,7 @@ internal static CpuInfo ParseOutput([CanBeNull] string content)
return new CpuInfo(processorName, physicalProcessorCount, physicalCoreCount, logicalCoreCount, nominalFrequency, minFrequency, maxFrequency);
}
- [CanBeNull]
- private static int? GetPositiveIntValue([NotNull] Dictionary sysctl, [NotNull] string keyName)
+ private static int? GetPositiveIntValue(Dictionary sysctl, string keyName)
{
if (sysctl.TryGetValue(keyName, out string value) &&
int.TryParse(value, out int result) &&
@@ -34,8 +30,7 @@ internal static CpuInfo ParseOutput([CanBeNull] string content)
return null;
}
- [CanBeNull]
- private static long? GetPositiveLongValue([NotNull] Dictionary sysctl, [NotNull] string keyName)
+ private static long? GetPositiveLongValue(Dictionary sysctl, string keyName)
{
if (sysctl.TryGetValue(keyName, out string value) &&
long.TryParse(value, out long result) &&
diff --git a/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoProvider.cs b/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoProvider.cs
index d5aad7136f..ba32b22f9b 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoProvider.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/SysctlCpuInfoProvider.cs
@@ -12,10 +12,9 @@ internal static class SysctlCpuInfoProvider
{
internal static readonly Lazy SysctlCpuInfo = new Lazy(Load);
- [CanBeNull]
- private static CpuInfo Load()
+ private static CpuInfo? Load()
{
- if (RuntimeInformation.IsMacOSX())
+ if (RuntimeInformation.IsMacOS())
{
string content = ProcessHelper.RunAndReadOutput("sysctl", "-a");
return SysctlCpuInfoParser.ParseOutput(content);
diff --git a/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoParser.cs b/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoParser.cs
index 31cd935a66..9c85764860 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoParser.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoParser.cs
@@ -7,8 +7,7 @@ namespace BenchmarkDotNet.Portability.Cpu
{
internal static class WmicCpuInfoParser
{
- [NotNull]
- internal static CpuInfo ParseOutput([CanBeNull] string content)
+ internal static CpuInfo ParseOutput(string? content)
{
var processors = SectionsHelper.ParseSections(content, '=');
diff --git a/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoProvider.cs b/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoProvider.cs
index 3f86188ed1..2cd380c396 100644
--- a/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoProvider.cs
+++ b/src/BenchmarkDotNet/Portability/Cpu/WmicCpuInfoProvider.cs
@@ -12,8 +12,7 @@ internal static class WmicCpuInfoProvider
{
internal static readonly Lazy WmicCpuInfo = new Lazy(Load);
- [CanBeNull]
- private static CpuInfo Load()
+ private static CpuInfo? Load()
{
if (RuntimeInformation.IsWindows())
{
diff --git a/src/BenchmarkDotNet/Portability/RuntimeInformation.cs b/src/BenchmarkDotNet/Portability/RuntimeInformation.cs
index bef9a295c2..009e34049c 100644
--- a/src/BenchmarkDotNet/Portability/RuntimeInformation.cs
+++ b/src/BenchmarkDotNet/Portability/RuntimeInformation.cs
@@ -46,8 +46,17 @@ public static bool IsNativeAOT
&& string.IsNullOrEmpty(typeof(object).Assembly.Location) // it's merged to a single .exe and .Location returns null
&& !IsWasm; // Wasm also returns "" for assembly locations
- public static bool IsWasm => IsOSPlatform(OSPlatform.Create("BROWSER"));
+#if NET6_0_OR_GREATER
+ [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")]
+#endif
+ public static bool IsWasm =>
+#if NET6_0_OR_GREATER
+ OperatingSystem.IsBrowser();
+#else
+ IsOSPlatform(OSPlatform.Create("BROWSER"));
+#endif
+#if NETSTANDARD2_0
public static bool IsAot { get; } = IsAotMethod(); // This allocates, so we only want to call it once statically.
private static bool IsAotMethod()
@@ -65,6 +74,9 @@ private static bool IsAotMethod()
return false;
}
+#else
+ public static bool IsAot => !System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled;
+#endif
public static bool IsRunningInContainer => string.Equals(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), "true");
@@ -87,20 +99,46 @@ internal static bool IsWindows() =>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatformGuard("linux")]
#endif
- internal static bool IsLinux() => IsOSPlatform(OSPlatform.Linux);
+ internal static bool IsLinux() =>
+#if NET6_0_OR_GREATER
+ OperatingSystem.IsLinux();
+#else
+ IsOSPlatform(OSPlatform.Linux);
+#endif
#if NET6_0_OR_GREATER
- [System.Runtime.Versioning.SupportedOSPlatformGuard("osx")]
+ [System.Runtime.Versioning.SupportedOSPlatformGuard("macos")]
+#endif
+ internal static bool IsMacOS() =>
+#if NET6_0_OR_GREATER
+ OperatingSystem.IsMacOS();
+#else
+ IsOSPlatform(OSPlatform.OSX);
#endif
- internal static bool IsMacOSX() => IsOSPlatform(OSPlatform.OSX);
- internal static bool IsAndroid() => Type.GetType("Java.Lang.Object, Mono.Android") != null;
+#if NET6_0_OR_GREATER
+ [System.Runtime.Versioning.SupportedOSPlatformGuard("android")]
+#endif
+ internal static bool IsAndroid() =>
+#if NET6_0_OR_GREATER
+ OperatingSystem.IsAndroid();
+#else
+ Type.GetType("Java.Lang.Object, Mono.Android") != null;
+#endif
- internal static bool IsiOS() => Type.GetType("Foundation.NSObject, Xamarin.iOS") != null;
+#if NET6_0_OR_GREATER
+ [System.Runtime.Versioning.SupportedOSPlatformGuard("ios")]
+#endif
+ internal static bool IsIOS() =>
+#if NET6_0_OR_GREATER
+ OperatingSystem.IsIOS();
+#else
+ Type.GetType("Foundation.NSObject, Xamarin.iOS") != null;
+#endif
public static string GetOsVersion()
{
- if (IsMacOSX())
+ if (IsMacOS())
{
string systemVersion = ExternalToolsHelper.MacSystemProfilerData.Value.GetValueOrDefault("System Version") ?? "";
string kernelVersion = ExternalToolsHelper.MacSystemProfilerData.Value.GetValueOrDefault("Kernel Version") ?? "";
@@ -123,7 +161,6 @@ public static string GetOsVersion()
/// Returns null if the value is not available
///
///
- [CanBeNull]
private static int? GetWindowsUbr()
{
if (IsWindows())
@@ -155,7 +192,7 @@ internal static CpuInfo GetCpuInfo()
return WmicCpuInfoProvider.WmicCpuInfo.Value;
if (IsLinux())
return ProcCpuInfoProvider.ProcCpuInfo.Value;
- if (IsMacOSX())
+ if (IsMacOS())
return SysctlCpuInfoProvider.SysctlCpuInfo.Value;
return null;
diff --git a/src/BenchmarkDotNet/Reports/BenchmarkReport.cs b/src/BenchmarkDotNet/Reports/BenchmarkReport.cs
index 4938216fce..b63c5221be 100644
--- a/src/BenchmarkDotNet/Reports/BenchmarkReport.cs
+++ b/src/BenchmarkDotNet/Reports/BenchmarkReport.cs
@@ -20,11 +20,9 @@ public sealed class BenchmarkReport
[PublicAPI] public BuildResult BuildResult { get; }
[PublicAPI] public IReadOnlyDictionary Metrics { get; }
- [NotNull]
public IReadOnlyList ExecuteResults { get; }
- [CanBeNull]
- public Statistics ResultStatistics => resultStatistics ?? (resultStatistics = GetResultRuns().Any()
+ public Statistics? ResultStatistics => resultStatistics ?? (resultStatistics = GetResultRuns().Any()
? new Statistics(GetResultRuns().Select(r => r.GetAverageTime().Nanoseconds))
: null);
diff --git a/src/BenchmarkDotNet/Reports/BenchmarkReportExtensions.cs b/src/BenchmarkDotNet/Reports/BenchmarkReportExtensions.cs
index 4f163dc66e..a046d2ed57 100644
--- a/src/BenchmarkDotNet/Reports/BenchmarkReportExtensions.cs
+++ b/src/BenchmarkDotNet/Reports/BenchmarkReportExtensions.cs
@@ -10,17 +10,13 @@ public static class BenchmarkReportExtensions
private const string DisplayedGcInfoPrefix = "// " + BenchmarkEnvironmentInfo.GcInfoPrefix;
private const string DisplayedHardwareIntrinsicsPrefix = "// " + BenchmarkEnvironmentInfo.HardwareIntrinsicsPrefix;
- [CanBeNull]
- public static string GetRuntimeInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedRuntimeInfoPrefix);
+ public static string? GetRuntimeInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedRuntimeInfoPrefix);
- [CanBeNull]
- public static string GetGcInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedGcInfoPrefix);
+ public static string? GetGcInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedGcInfoPrefix);
- [CanBeNull]
- public static string GetHardwareIntrinsicsInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedHardwareIntrinsicsPrefix);
+ public static string? GetHardwareIntrinsicsInfo(this BenchmarkReport report) => report.GetInfoFromOutput(DisplayedHardwareIntrinsicsPrefix);
- [CanBeNull]
- private static string GetInfoFromOutput(this BenchmarkReport report, string prefix)
+ private static string? GetInfoFromOutput(this BenchmarkReport report, string prefix)
{
return (
from executeResults in report.ExecuteResults
diff --git a/src/BenchmarkDotNet/Reports/DisplayPrecisionManager.cs b/src/BenchmarkDotNet/Reports/DisplayPrecisionManager.cs
index fc524299a1..8798904985 100644
--- a/src/BenchmarkDotNet/Reports/DisplayPrecisionManager.cs
+++ b/src/BenchmarkDotNet/Reports/DisplayPrecisionManager.cs
@@ -21,7 +21,7 @@ internal class DisplayPrecisionManager
///
/// Returns the best amount of decimal digits for the given column.
///
- public int GetPrecision(SummaryStyle summaryStyle, [NotNull] IStatisticColumn column, [CanBeNull] IStatisticColumn parentColumn = null)
+ public int GetPrecision(SummaryStyle summaryStyle, IStatisticColumn column, IStatisticColumn? parentColumn = null)
{
if (!precision.ContainsKey(column.Id))
{
@@ -34,7 +34,7 @@ public int GetPrecision(SummaryStyle summaryStyle, [NotNull] IStatisticColumn co
return precision[column.Id];
}
- internal static int CalcPrecision([NotNull] IList values)
+ internal static int CalcPrecision(IList values)
{
if (values.IsEmpty())
return MinPrecision;
@@ -51,7 +51,7 @@ internal static int CalcPrecision([NotNull] IList values)
return MathHelper.Clamp((int) Math.Truncate(-Math.Log10(minValue)) + 3, MinPrecision, MaxPrecision);
}
- internal static int CalcPrecision([NotNull] IList values, int parentPrecision)
+ internal static int CalcPrecision(IList values, int parentPrecision)
{
return MathHelper.Clamp(CalcPrecision(values), parentPrecision, parentPrecision + 1);
}
diff --git a/src/BenchmarkDotNet/Reports/Summary.cs b/src/BenchmarkDotNet/Reports/Summary.cs
index 08a1efecc9..782a2e6af9 100644
--- a/src/BenchmarkDotNet/Reports/Summary.cs
+++ b/src/BenchmarkDotNet/Reports/Summary.cs
@@ -128,20 +128,17 @@ internal static string BuildAllRuntimes(HostEnvironmentInfo hostEnvironmentInfo,
internal SummaryTable GetTable(SummaryStyle style) => new SummaryTable(this, style);
- [CanBeNull]
- public string GetLogicalGroupKey(BenchmarkCase benchmarkCase)
+ public string? GetLogicalGroupKey(BenchmarkCase benchmarkCase)
=> Orderer.GetLogicalGroupKey(BenchmarksCases, benchmarkCase);
public bool IsBaseline(BenchmarkCase benchmarkCase)
=> BaseliningStrategy.IsBaseline(benchmarkCase);
- [CanBeNull]
- public BenchmarkCase GetBaseline(string logicalGroupKey)
+ public BenchmarkCase? GetBaseline(string logicalGroupKey)
=> BenchmarksCases
.Where(b => GetLogicalGroupKey(b) == logicalGroupKey)
.FirstOrDefault(IsBaseline);
- [NotNull]
public IEnumerable GetNonBaselines(string logicalGroupKey)
=> BenchmarksCases
.Where(b => GetLogicalGroupKey(b) == logicalGroupKey)
diff --git a/src/BenchmarkDotNet/Reports/SummaryExtensions.cs b/src/BenchmarkDotNet/Reports/SummaryExtensions.cs
index 365d045d9c..b69760e57a 100644
--- a/src/BenchmarkDotNet/Reports/SummaryExtensions.cs
+++ b/src/BenchmarkDotNet/Reports/SummaryExtensions.cs
@@ -29,7 +29,7 @@ public static IEnumerable GetLogicalGroupForBenchmark(this Summar
return summary.BenchmarksCases.Where(b => summary.GetLogicalGroupKey(b) == logicalGroupKey);
}
- [NotNull, Pure]
- public static CultureInfo GetCultureInfo([CanBeNull] this Summary summary) => summary?.Style?.CultureInfo ?? DefaultCultureInfo.Instance;
+ [Pure]
+ public static CultureInfo GetCultureInfo(this Summary? summary) => summary?.Style?.CultureInfo ?? DefaultCultureInfo.Instance;
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Reports/SummaryStyle.cs b/src/BenchmarkDotNet/Reports/SummaryStyle.cs
index 0143838a2d..9ba8e0da6c 100644
--- a/src/BenchmarkDotNet/Reports/SummaryStyle.cs
+++ b/src/BenchmarkDotNet/Reports/SummaryStyle.cs
@@ -21,12 +21,11 @@ public class SummaryStyle : IEquatable
public SizeUnit SizeUnit { get; }
internal SizeUnit CodeSizeUnit { get; }
public TimeUnit TimeUnit { get; }
- [NotNull]
public CultureInfo CultureInfo { get; }
public RatioStyle RatioStyle { get; }
- public SummaryStyle([CanBeNull] CultureInfo cultureInfo, bool printUnitsInHeader, SizeUnit sizeUnit, TimeUnit timeUnit, bool printUnitsInContent = true,
+ public SummaryStyle(CultureInfo? cultureInfo, bool printUnitsInHeader, SizeUnit sizeUnit, TimeUnit timeUnit, bool printUnitsInContent = true,
bool printZeroValuesInContent = false, int maxParameterColumnWidth = DefaultMaxParameterColumnWidth, RatioStyle ratioStyle = RatioStyle.Value)
{
if (maxParameterColumnWidth < DefaultMaxParameterColumnWidth)
diff --git a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
index 66a1f3d7da..5bf2e5ed03 100644
--- a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
+++ b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
@@ -654,7 +654,7 @@ private static void Cleanup(HashSet artifactsToCleanup)
private static void UpdateTitle(int totalBenchmarkCount, int benchmarksToRunCount)
{
- if (!Console.IsOutputRedirected && (RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux() || RuntimeInformation.IsMacOSX()))
+ if (!Console.IsOutputRedirected && (RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux() || RuntimeInformation.IsMacOS()))
{
Console.Title = $"{benchmarksToRunCount}/{totalBenchmarkCount} Remaining";
}
@@ -669,7 +669,7 @@ private static void LogProgress(ILogger logger, in StartedClock runsChronometer,
$" Estimated finish {estimatedEnd:yyyy-MM-dd H:mm} ({(int)fromNow.TotalHours}h {fromNow.Minutes}m from now) **";
logger.WriteLineHeader(message);
- if (!Console.IsOutputRedirected && (RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux() || RuntimeInformation.IsMacOSX()))
+ if (!Console.IsOutputRedirected && (RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux() || RuntimeInformation.IsMacOS()))
{
Console.Title = $"{benchmarksToRunCount}/{totalBenchmarkCount} Remaining - {(int)fromNow.TotalHours}h {fromNow.Minutes}m to finish";
}
diff --git a/src/BenchmarkDotNet/Running/Descriptor.cs b/src/BenchmarkDotNet/Running/Descriptor.cs
index b66e63872b..a7fd0cd7ac 100644
--- a/src/BenchmarkDotNet/Running/Descriptor.cs
+++ b/src/BenchmarkDotNet/Running/Descriptor.cs
@@ -59,7 +59,7 @@ public Descriptor(
public override string ToString() => DisplayInfo;
- private static string FormatDescription([CanBeNull] string description)
+ private static string FormatDescription(string? description)
{
var specialSymbols = new[] { ' ', '\'', '[', ']' };
return description != null && specialSymbols.Any(description.Contains)
diff --git a/src/BenchmarkDotNet/Running/UserInteraction.cs b/src/BenchmarkDotNet/Running/UserInteraction.cs
index b7a10426ae..de07c530a9 100644
--- a/src/BenchmarkDotNet/Running/UserInteraction.cs
+++ b/src/BenchmarkDotNet/Running/UserInteraction.cs
@@ -22,8 +22,7 @@ public void PrintNoBenchmarksError(ILogger logger)
logger.WriteError("No benchmarks to choose from. Make sure you provided public non-sealed non-static types with public [Benchmark] methods.");
}
- [NotNull]
- public IReadOnlyList AskUser([NotNull] IReadOnlyList allTypes, ILogger logger)
+ public IReadOnlyList AskUser(IReadOnlyList allTypes, ILogger logger)
{
var selectedTypes = new List();
string benchmarkCaptionExample = allTypes.First().GetDisplayName();
@@ -53,7 +52,7 @@ public IReadOnlyList AskUser([NotNull] IReadOnlyList allTypes, ILogg
return selectedTypes;
}
- public void PrintWrongFilterInfo(IReadOnlyList allTypes, ILogger logger, [NotNull] string[] userFilters)
+ public void PrintWrongFilterInfo(IReadOnlyList allTypes, ILogger logger, string[] userFilters)
{
var correctionSuggester = new CorrectionsSuggester(allTypes);
@@ -109,7 +108,7 @@ private static IEnumerable GetMatching(IReadOnlyList allTypes, strin
static bool IsInteger(string str) => int.TryParse(str, out _);
}
- private static void PrintAvailable([NotNull] IReadOnlyList allTypes, ILogger logger)
+ private static void PrintAvailable(IReadOnlyList allTypes, ILogger logger)
{
logger.WriteLineHelp($"Available Benchmark{(allTypes.Count > 1 ? "s" : "")}:");
diff --git a/src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs b/src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs
index 344978f829..dc48965f1e 100644
--- a/src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs
+++ b/src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs
@@ -127,7 +127,7 @@ internal static string GetPortableRuntimeIdentifier()
// Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
// returns win10-x64, we want the simpler form win-x64
// the values taken from https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#macos-rids
- string osPart = RuntimeInformation.IsWindows() ? "win" : (RuntimeInformation.IsMacOSX() ? "osx" : "linux");
+ string osPart = RuntimeInformation.IsWindows() ? "win" : (RuntimeInformation.IsMacOS() ? "osx" : "linux");
string architecture =
#if NETSTANDARD
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/ConsumableTypeInfo.cs b/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/ConsumableTypeInfo.cs
index 060c977014..0fde3ac1ee 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/ConsumableTypeInfo.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/ConsumableTypeInfo.cs
@@ -71,23 +71,17 @@ public ConsumableTypeInfo(Type methodReturnType)
throw new InvalidOperationException("Bug: (OverheadResultType == null");
}
- [NotNull]
public Type OriginMethodReturnType { get; }
- [NotNull]
public Type WorkloadMethodReturnType { get; }
- [NotNull]
public Type OverheadMethodReturnType { get; }
- [CanBeNull]
- public MethodInfo GetAwaiterMethod { get; }
- [CanBeNull]
- public MethodInfo GetResultMethod { get; }
+ public MethodInfo? GetAwaiterMethod { get; }
+ public MethodInfo? GetResultMethod { get; }
public bool IsVoid { get; }
public bool IsByRef { get; }
public bool IsConsumable { get; }
- [CanBeNull]
- public FieldInfo WorkloadConsumableField { get; }
+ public FieldInfo? WorkloadConsumableField { get; }
public bool IsAwaitable => GetAwaiterMethod != null && GetResultMethod != null;
}
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/Emitters/RunnableEmitter.cs b/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/Emitters/RunnableEmitter.cs
index 91e97cc71e..7f9d47c62f 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/Emitters/RunnableEmitter.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess.Emit.Implementation/Emitters/RunnableEmitter.cs
@@ -277,7 +277,7 @@ private static void EmitNoArgsMethodCallPopReturn(
private MethodBuilder runMethod;
// ReSharper restore NotAccessedField.Local
- private RunnableEmitter([NotNull] BuildPartition buildPartition, [NotNull] ModuleBuilder moduleBuilder)
+ private RunnableEmitter(BuildPartition buildPartition, ModuleBuilder moduleBuilder)
{
if (buildPartition == null)
throw new ArgumentNullException(nameof(buildPartition));
@@ -288,7 +288,6 @@ private RunnableEmitter([NotNull] BuildPartition buildPartition, [NotNull] Modul
this.moduleBuilder = moduleBuilder;
}
- [NotNull]
private Descriptor Descriptor => benchmark.BenchmarkCase.Descriptor;
// ReSharper disable once UnusedMethodReturnValue.Local
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory.cs b/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory.cs
index ef351975a1..6b0f2468d8 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory.cs
@@ -19,9 +19,9 @@ public static partial class BenchmarkActionFactory
/// Either or should be not null.
///
private static BenchmarkAction CreateCore(
- [NotNull] object instance,
- [CanBeNull] MethodInfo targetMethod,
- [CanBeNull] MethodInfo fallbackIdleSignature,
+ object instance,
+ MethodInfo? targetMethod,
+ MethodInfo? fallbackIdleSignature,
int unrollFactor)
{
PrepareInstanceAndResultType(instance, targetMethod, fallbackIdleSignature, out var resultInstance, out var resultType);
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory_Base.cs b/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory_Base.cs
index e000135441..ee4ca65362 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory_Base.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess.NoEmit/BenchmarkActionFactory_Base.cs
@@ -2,8 +2,6 @@
using System.Linq;
using System.Reflection;
-using JetBrains.Annotations;
-
namespace BenchmarkDotNet.Toolchains.InProcess.NoEmit
{
/*
@@ -29,7 +27,7 @@ public static partial class BenchmarkActionFactory
/// Base class that provides reusable API for final implementations.
internal abstract class BenchmarkActionBase : BenchmarkAction
{
- protected static TDelegate CreateWorkload([CanBeNull] object targetInstance, MethodInfo workloadMethod)
+ protected static TDelegate CreateWorkload(object? targetInstance, MethodInfo workloadMethod)
{
if (workloadMethod.IsStatic)
return (TDelegate)(object)workloadMethod.CreateDelegate(typeof(TDelegate));
@@ -38,10 +36,10 @@ protected static TDelegate CreateWorkload([CanBeNull] object targetIn
}
protected static TDelegate CreateWorkloadOrOverhead(
- [CanBeNull] object targetInstance,
- [CanBeNull] MethodInfo workloadMethod,
- [NotNull] TDelegate overheadStaticCallback,
- [NotNull] TDelegate overheadInstanceCallback)
+ object? targetInstance,
+ MethodInfo? workloadMethod,
+ TDelegate overheadStaticCallback,
+ TDelegate overheadInstanceCallback) where TDelegate : notnull
{
if (workloadMethod == null)
return targetInstance == null ? overheadStaticCallback : overheadInstanceCallback;
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory.cs b/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory.cs
index 0774339ad2..8def323161 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory.cs
@@ -20,9 +20,9 @@ public static partial class BenchmarkActionFactory
/// Either or should be not null.
///
private static BenchmarkAction CreateCore(
- [NotNull] object instance,
- [CanBeNull] MethodInfo targetMethod,
- [CanBeNull] MethodInfo fallbackIdleSignature,
+ object instance,
+ MethodInfo? targetMethod,
+ MethodInfo? fallbackIdleSignature,
BenchmarkActionCodegen codegenMode,
int unrollFactor)
{
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory_Base.cs b/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory_Base.cs
index e3c0f1f4be..ba1fe75060 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory_Base.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess/BenchmarkActionFactory_Base.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
-using JetBrains.Annotations;
namespace BenchmarkDotNet.Toolchains.InProcess
{
@@ -31,7 +30,7 @@ public static partial class BenchmarkActionFactory
/// Base class that provides reusable API for final implementations.
internal abstract class BenchmarkActionBase : BenchmarkAction
{
- protected static TDelegate CreateWorkload([CanBeNull] object targetInstance, MethodInfo workloadMethod)
+ protected static TDelegate CreateWorkload(object? targetInstance, MethodInfo workloadMethod)
{
if (workloadMethod.IsStatic)
return (TDelegate)(object)workloadMethod.CreateDelegate(typeof(TDelegate));
@@ -40,8 +39,8 @@ protected static TDelegate CreateWorkload([CanBeNull] object targetIn
}
protected static TDelegate CreateWorkloadOrOverhead(
- [CanBeNull] object targetInstance, [CanBeNull] MethodInfo workloadMethod,
- [NotNull] TDelegate overheadStaticCallback, [NotNull] TDelegate overheadInstanceCallback)
+ object? targetInstance, MethodInfo? workloadMethod,
+ TDelegate overheadStaticCallback, TDelegate overheadInstanceCallback) where TDelegate : notnull
{
if (workloadMethod == null)
return targetInstance == null ? overheadStaticCallback : overheadInstanceCallback;
diff --git a/src/BenchmarkDotNet/Toolchains/InProcess/InProcessHost.cs b/src/BenchmarkDotNet/Toolchains/InProcess/InProcessHost.cs
index 726d69b2bd..90043dded6 100644
--- a/src/BenchmarkDotNet/Toolchains/InProcess/InProcessHost.cs
+++ b/src/BenchmarkDotNet/Toolchains/InProcess/InProcessHost.cs
@@ -17,14 +17,11 @@ namespace BenchmarkDotNet.Toolchains.InProcess
///
public sealed class InProcessHost : IHost
{
- [NotNull]
private readonly ILogger logger;
- [CanBeNull]
- private readonly IDiagnoser diagnoser;
+ private readonly IDiagnoser? diagnoser;
- [CanBeNull]
- private readonly DiagnoserActionParameters diagnoserActionParameters;
+ private readonly DiagnoserActionParameters? diagnoserActionParameters;
/// Creates a new instance of .
/// Current benchmark.
diff --git a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
index c2af278c76..b05cceb833 100644
--- a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
+++ b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
@@ -44,7 +44,7 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor descrip
case MonoRuntime mono:
if (RuntimeInformation.IsAndroid())
return InProcessEmitToolchain.Instance;
- if (RuntimeInformation.IsiOS())
+ if (RuntimeInformation.IsIOS())
return InProcessNoEmitToolchain.Instance;
if (!string.IsNullOrEmpty(mono.AotArgs))
return MonoAotToolchain.Instance;
diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
old mode 100755
new mode 100644
index 3b5c821c8f..504c7efe78
--- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
@@ -43,6 +43,7 @@
+
diff --git a/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs b/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs
index 5893df2740..b495489d78 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs
@@ -19,7 +19,7 @@ public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled()
{
if (!RuntimeInformation.Is64BitPlatform()) // NativeAOT does not support 32bit yet
return;
- if (RuntimeInformation.IsMacOSX())
+ if (RuntimeInformation.IsMacOS())
return; // currently not supported
// we use NativeAOT on purpose because it takes a LOT of time to build it
diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
index 6b7574eb24..2ffe1b3387 100755
--- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
@@ -67,7 +67,7 @@ public void MemoryDiagnoserIsAccurate(IToolchain toolchain)
[FactDotNetCoreOnly("We don't want to test NativeAOT twice (for .NET Framework 4.6.2 and .NET 7.0)")]
public void MemoryDiagnoserSupportsNativeAOT()
{
- if (RuntimeInformation.IsMacOSX())
+ if (RuntimeInformation.IsMacOS())
return; // currently not supported
if (ContinuousIntegration.IsAppVeyorOnWindows())
return; // timeouts
diff --git a/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs b/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs
index 15fe8a7a6a..aa0c7de67f 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs
@@ -23,7 +23,7 @@ public void LatestNativeAotVersionIsSupported()
return;
if (ContinuousIntegration.IsAppVeyorOnWindows())
return; // timeouts
- if (RuntimeInformation.IsMacOSX())
+ if (RuntimeInformation.IsMacOS())
return; // currently not supported
var toolchain = NativeAotToolchain.CreateBuilder().UseNuGet().IlcInstructionSet(IsAvx2Supported() ? "avx2" : "").ToToolchain();
diff --git a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
index 3fbb968383..094e40b03c 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
@@ -32,7 +32,7 @@ public static IEnumerable
-
@@ -24,6 +23,7 @@
+
diff --git a/tests/BenchmarkDotNet.Tests/Reports/RatioStyleTests.cs b/tests/BenchmarkDotNet.Tests/Reports/RatioStyleTests.cs
index 2fe3ad2e5a..96c9519a14 100644
--- a/tests/BenchmarkDotNet.Tests/Reports/RatioStyleTests.cs
+++ b/tests/BenchmarkDotNet.Tests/Reports/RatioStyleTests.cs
@@ -57,7 +57,7 @@ public TestData(RatioStyle ratioStyle, int[] meanValues, int noise, string[] exp
[Theory]
[MemberData(nameof(DataNames))]
// First value is baseline, others are benchmark measurements
- public void RatioPrecisionTestWithBaseline([NotNull] string testDataKey)
+ public void RatioPrecisionTestWithBaseline(string testDataKey)
{
var testData = Data[testDataKey];
var summary = CreateSummary(testData.MeanValues, testData.RatioStyle, testData.Noise);