Skip to content

Commit

Permalink
Fixed nullability warnings in methods signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
alinasmirnova authored and AndreyAkinshin committed Oct 3, 2023
1 parent 516bd68 commit 5428ebd
Show file tree
Hide file tree
Showing 43 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions samples/BenchmarkDotNet.Samples/IntroOrderManual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private class Config : ManualConfig
private class FastestToSlowestOrderer : IOrderer
{
public IEnumerable<BenchmarkCase> GetExecutionOrder(ImmutableArray<BenchmarkCase> benchmarksCase,
IEnumerable<BenchmarkLogicalGroupRule> order = null) =>
IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>
from benchmark in benchmarksCase
orderby benchmark.Parameters["X"] descending,
benchmark.Descriptor.WorkloadMethodDisplayInfo
Expand All @@ -39,7 +39,7 @@ public string GetLogicalGroupKey(ImmutableArray<BenchmarkCase> allBenchmarksCase
benchmarkCase.Job.DisplayInfo + "_" + benchmarkCase.Parameters.DisplayInfo;

public IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,
IEnumerable<BenchmarkLogicalGroupRule> order = null) =>
IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>
logicalGroups.OrderBy(it => it.Key);

public bool SeparateLogicalGroups => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public InliningDiagnoserAttribute(bool logFailuresOnly = true, bool filterByName
Config = ManualConfig.CreateEmpty().AddDiagnoser(new InliningDiagnoser(logFailuresOnly, filterByNamespace));
}

public InliningDiagnoserAttribute(bool logFailuresOnly = true, string[] allowedNamespaces = null)
public InliningDiagnoserAttribute(bool logFailuresOnly = true, string[]? allowedNamespaces = null)
{
Config = ManualConfig.CreateEmpty().AddDiagnoser(new InliningDiagnoser(logFailuresOnly, allowedNamespaces));
}
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet.Diagnostics.Windows/EtwDiagnoser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void Clear()

private void OnProcessExit(object sender, EventArgs e) => Session?.Dispose();

private static string GetSessionName(string prefix, BenchmarkCase benchmarkCase, ParameterInstances parameters = null)
private static string GetSessionName(string prefix, BenchmarkCase benchmarkCase, ParameterInstances? parameters = null)
{
if (parameters != null && parameters.Items.Count > 0)
return $"{prefix}-{benchmarkCase.FolderInfo}-{parameters.FolderInfo}";
Expand Down
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet.Diagnostics.Windows/EtwProfilerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public EtwProfilerConfig(
float cpuSampleIntervalInMilliseconds = 1.0f,
KernelTraceEventParser.Keywords kernelKeywords = KernelTraceEventParser.Keywords.ImageLoad | KernelTraceEventParser.Keywords.Profile,
KernelTraceEventParser.Keywords kernelStackKeywords = KernelTraceEventParser.Keywords.Profile,
IReadOnlyDictionary<HardwareCounter, Func<ProfileSourceInfo, int>> intervalSelectors = null,
IReadOnlyCollection<(Guid providerGuid, TraceEventLevel providerLevel, ulong keywords, TraceEventProviderOptions options)> providers = null,
IReadOnlyDictionary<HardwareCounter, Func<ProfileSourceInfo, int>>? intervalSelectors = null,
IReadOnlyCollection<(Guid providerGuid, TraceEventLevel providerLevel, ulong keywords, TraceEventProviderOptions options)>? providers = null,
bool createHeapSession = false)
{
CreateHeapSession = createHeapSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public InliningDiagnoser(bool logFailuresOnly = true, bool filterByNamespace = t
/// </summary>
/// <param name="logFailuresOnly">only the methods that failed to get inlined. True by default.</param>
/// <param name="allowedNamespaces">list of namespaces from which inlining message should be print.</param>
public InliningDiagnoser(bool logFailuresOnly = true, string[] allowedNamespaces = null)
public InliningDiagnoser(bool logFailuresOnly = true, string[]? allowedNamespaces = null)
{
this.logFailuresOnly = logFailuresOnly;
this.allowedNamespaces = allowedNamespaces;
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Code/EnumParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private EnumParam(object value, Type type)
public string ToSourceCode() =>
$"({type.GetCorrectCSharpTypeName()})({ToInvariantCultureString()})";

internal static IParam FromObject(object value, Type type = null)
internal static IParam FromObject(object value, Type? type = null)
{
type = type ?? value.GetType();
if (!type.IsEnum)
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Columns/StatisticColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private enum Priority
private readonly IStatisticColumn parentColumn;

private StatisticColumn(string columnName, string legend, Func<Statistics, double> calc, Priority priority, UnitType type = UnitType.Time,
IStatisticColumn parentColumn = null)
IStatisticColumn? parentColumn = null)
{
this.calc = calc;
this.priority = priority;
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static class ConfigParser
{ "fullxml", new[] { XmlExporter.Full } }
};

public static (bool isSuccess, IConfig config, CommandLineOptions options) Parse(string[] args, ILogger logger, IConfig globalConfig = null)
public static (bool isSuccess, IConfig config, CommandLineOptions options) Parse(string[] args, ILogger logger, IConfig? globalConfig = null)
{
(bool isSuccess, IConfig config, CommandLineOptions options) result = default;

Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Diagnosers/EventPipeProfiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EventPipeProfiler() :this(profile: EventPipeProfile.CpuSampling, performE
/// <param name="profile">A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly.</param>
/// <param name="providers">A list of EventPipe providers to be enabled.</param>
/// <param name="performExtraBenchmarksRun">if set to true, benchmarks will be executed one more time with the profiler attached. If set to false, there will be no extra run but the results will contain overhead. True by default.</param>
public EventPipeProfiler(EventPipeProfile profile = EventPipeProfile.CpuSampling, IReadOnlyCollection<EventPipeProvider> providers = null, bool performExtraBenchmarksRun = true)
public EventPipeProfiler(EventPipeProfile profile = EventPipeProfile.CpuSampling, IReadOnlyCollection<EventPipeProvider>? providers = null, bool performExtraBenchmarksRun = true)
{
this.performExtraBenchmarksRun = performExtraBenchmarksRun;
eventPipeProviders = MapToProviders(profile, providers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class DisassemblyDiagnoserConfig
public DisassemblyDiagnoserConfig(
int maxDepth = 1,
DisassemblySyntax syntax = DisassemblySyntax.Masm,
string[] filters = null,
FormatterOptions formatterOptions = null,
string[]? filters = null,
FormatterOptions? formatterOptions = null,
bool printSource = false,
bool printInstructionAddresses = false,
bool exportGithubMarkdown = true,
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Environments/Runtimes/ClrRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ClrRuntime : Runtime, IEquatable<ClrRuntime>

public string Version { get; }

private ClrRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName, string version = null)
private ClrRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName, string? version = null)
: base(runtimeMoniker, msBuildMoniker, displayName)
{
Version = version;
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Environments/Runtimes/WasmRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class WasmRuntime : Runtime, IEquatable<WasmRuntime>
/// <param name="aot">Specifies whether AOT or Interpreter (default) project should be generated.</param>
/// <param name="wasmDataDir">Specifies a wasm data directory surfaced as $(WasmDataDir) for the project</param>
/// <param name="moniker">Runtime moniker</param>
public WasmRuntime(string msBuildMoniker = "net5.0", string displayName = "Wasm", string javaScriptEngine = "v8", string javaScriptEngineArguments = "--expose_wasm", bool aot = false, string wasmDataDir = null, RuntimeMoniker moniker = RuntimeMoniker.Wasm) : base(moniker, msBuildMoniker, displayName)
public WasmRuntime(string msBuildMoniker = "net5.0", string displayName = "Wasm", string javaScriptEngine = "v8", string javaScriptEngineArguments = "--expose_wasm", bool aot = false, string? wasmDataDir = null, RuntimeMoniker moniker = RuntimeMoniker.Wasm) : base(moniker, msBuildMoniker, displayName)
{
if (!string.IsNullOrEmpty(javaScriptEngine) && javaScriptEngine != "v8" && !File.Exists(javaScriptEngine))
throw new FileNotFoundException($"Provided {nameof(javaScriptEngine)} file: \"{javaScriptEngine}\" doest NOT exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CsvMeasurementsExporter : ExporterBase
private static readonly Lazy<MeasurementColumn[]> Columns = new Lazy<MeasurementColumn[]>(BuildColumns);

private readonly CsvSeparator separator;
public CsvMeasurementsExporter(CsvSeparator separator, SummaryStyle style = null)
public CsvMeasurementsExporter(CsvSeparator separator, SummaryStyle? style = null)
{
this.separator = separator;
Style = style ?? SummaryStyle.Default;
Expand Down
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Helpers/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ProcessHelper
/// Run external process and return the console output.
/// In the case of any exception, null will be returned.
/// </summary>
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
{
Expand Down Expand Up @@ -42,7 +42,7 @@ internal static class ProcessHelper
}

internal static (int exitCode, ImmutableArray<string> output) RunAndReadOutputLineByLine(string fileName, string arguments = "", string workingDirectory = "",
Dictionary<string, string> environmentVariables = null, bool includeErrors = false, ILogger logger = null)
Dictionary<string, string>? environmentVariables = null, bool includeErrors = false, ILogger? logger = null)
{
var processStartInfo = new ProcessStartInfo
{
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Jobs/JobExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public static Job WithEnvironmentVariable(this Job job, string key, string value
/// <param name="source">(optional)Indicate the URI of the NuGet package source to use during the restore operation.</param>
/// <param name="prerelease">(optional)Allows prerelease packages to be installed.</param>
/// <returns></returns>
public static Job WithNuGet(this Job job, string packageName, string packageVersion = null, Uri source = null, bool prerelease = false) =>
public static Job WithNuGet(this Job job, string packageName, string? packageVersion = null, Uri? source = null, bool prerelease = false) =>
job.WithCore(j => j.Infrastructure.NuGetReferences =
new NuGetReferenceList(j.Infrastructure.NuGetReferences ?? Array.Empty<NuGetReference>())
{
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Jobs/NugetReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BenchmarkDotNet.Jobs
{
public class NuGetReference : IEquatable<NuGetReference>
{
public NuGetReference(string packageName, string packageVersion, Uri source = null, bool prerelease = false)
public NuGetReference(string packageName, string packageVersion, Uri? source = null, bool prerelease = false)
{
if (string.IsNullOrWhiteSpace(packageName))
throw new ArgumentException("message", nameof(packageName));
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Loggers/AsyncProcessOutputReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class AsyncProcessOutputReader : IDisposable

private long status;

internal AsyncProcessOutputReader(Process process, bool logOutput = false, ILogger logger = null, bool readStandardError = true)
internal AsyncProcessOutputReader(Process process, bool logOutput = false, ILogger? logger = null, bool readStandardError = true)
{
if (!process.StartInfo.RedirectStandardOutput)
throw new NotSupportedException("set RedirectStandardOutput to true first");
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Loggers/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private static readonly bool ConsoleSupportsColors
private readonly Dictionary<LogKind, ConsoleColor> colorScheme;

[PublicAPI]
public ConsoleLogger(bool unicodeSupport = false, Dictionary<LogKind, ConsoleColor> colorScheme = null)
public ConsoleLogger(bool unicodeSupport = false, Dictionary<LogKind, ConsoleColor>? colorScheme = null)
{
this.unicodeSupport = unicodeSupport;
this.colorScheme = colorScheme ?? CreateColorfulScheme();
Expand Down
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Order/DefaultOrderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public DefaultOrderer(
[PublicAPI]
public virtual IEnumerable<BenchmarkCase> GetExecutionOrder(
ImmutableArray<BenchmarkCase> benchmarkCases,
IEnumerable<BenchmarkLogicalGroupRule> order = null)
IEnumerable<BenchmarkLogicalGroupRule>? order = null)
{
var benchmarkComparer = new BenchmarkComparer(categoryComparer, paramsComparer, jobComparer, targetComparer, order);
var list = benchmarkCases.ToList();
Expand Down Expand Up @@ -137,7 +137,7 @@ public string GetLogicalGroupKey(ImmutableArray<BenchmarkCase> allBenchmarksCase

public virtual IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(
IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,
IEnumerable<BenchmarkLogicalGroupRule> order = null)
IEnumerable<BenchmarkLogicalGroupRule>? order = null)
{
var benchmarkComparer = new BenchmarkComparer(categoryComparer, paramsComparer, jobComparer, targetComparer, order);
var logicalGroupComparer = new LogicalGroupComparer(benchmarkComparer);
Expand Down
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Order/IOrderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BenchmarkDotNet.Order
public interface IOrderer
{
[PublicAPI]
IEnumerable<BenchmarkCase> GetExecutionOrder(ImmutableArray<BenchmarkCase> benchmarksCase, IEnumerable<BenchmarkLogicalGroupRule> order = null);
IEnumerable<BenchmarkCase> GetExecutionOrder(ImmutableArray<BenchmarkCase> benchmarksCase, IEnumerable<BenchmarkLogicalGroupRule>? order = null);

[PublicAPI]
IEnumerable<BenchmarkCase> GetSummaryOrder(ImmutableArray<BenchmarkCase> benchmarksCases, Summary summary);
Expand All @@ -24,7 +24,7 @@ public interface IOrderer

[PublicAPI]
IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,
IEnumerable<BenchmarkLogicalGroupRule> order = null);
IEnumerable<BenchmarkLogicalGroupRule>? order = null);

[PublicAPI]
bool SeparateLogicalGroups { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Reports/Summary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Summary(
CultureInfo cultureInfo,
ImmutableArray<ValidationError> validationErrors,
ImmutableArray<IColumnHidingRule> columnHidingRules,
SummaryStyle summaryStyle = null)
SummaryStyle? summaryStyle = null)
{
Title = title;
ResultsDirectoryPath = resultsDirectoryPath;
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Reports/SummaryTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class SummaryTable
public SummaryStyle EffectiveSummaryStyle { get; }
public bool SeparateLogicalGroups { get; }

internal SummaryTable(Summary summary, SummaryStyle style = null)
internal SummaryTable(Summary summary, SummaryStyle? style = null)
{
Summary = summary;

Expand Down
14 changes: 7 additions & 7 deletions src/BenchmarkDotNet/Running/Descriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public class Descriptor : IEquatable<Descriptor>
public Descriptor(
Type type,
MethodInfo workloadMethod,
MethodInfo globalSetupMethod = null,
MethodInfo globalCleanupMethod = null,
MethodInfo iterationSetupMethod = null,
MethodInfo iterationCleanupMethod = null,
string description = null,
string additionalLogic = null,
MethodInfo? globalSetupMethod = null,
MethodInfo? globalCleanupMethod = null,
MethodInfo? iterationSetupMethod = null,
MethodInfo? iterationCleanupMethod = null,
string? description = null,
string? additionalLogic = null,
bool baseline = false,
string[] categories = null,
string[]? categories = null,
int operationsPerInvoke = 1,
int methodIndex = 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Toolchains/CoreRun/CoreRunPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BenchmarkDotNet.Toolchains.CoreRun
{
public class CoreRunPublisher : IBuilder
{
public CoreRunPublisher(FileInfo coreRun, FileInfo customDotNetCliPath = null)
public CoreRunPublisher(FileInfo coreRun, FileInfo? customDotNetCliPath = null)
{
CoreRun = coreRun;
DotNetCliPublisher = new DotNetCliPublisher(customDotNetCliPath?.FullName);
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Toolchains/CoreRun/CoreRunToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CoreRunToolchain : IToolchain
/// <param name="restorePath">the directory to restore packages to</param>
public CoreRunToolchain(FileInfo coreRun, bool createCopy = true,
string targetFrameworkMoniker = "netcoreapp2.1",
FileInfo customDotNetCliPath = null, DirectoryInfo restorePath = null,
FileInfo? customDotNetCliPath = null, DirectoryInfo? restorePath = null,
string displayName = "CoreRun")
{
if (coreRun == null) throw new ArgumentNullException(nameof(coreRun));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CsProjClassicNetToolchain : Toolchain

internal string CustomDotNetCliPath { get; }

private CsProjClassicNetToolchain(string targetFrameworkMoniker, string name, string packagesPath = null, string customDotNetCliPath = null)
private CsProjClassicNetToolchain(string targetFrameworkMoniker, string name, string? packagesPath = null, string? customDotNetCliPath = null)
: base(name,
new CsProjGenerator(targetFrameworkMoniker, customDotNetCliPath, packagesPath, runtimeFrameworkVersion: null, isNetCore: false),
new DotNetCliBuilder(targetFrameworkMoniker, customDotNetCliPath),
Expand All @@ -34,7 +34,7 @@ private CsProjClassicNetToolchain(string targetFrameworkMoniker, string name, st
CustomDotNetCliPath = customDotNetCliPath;
}

public static IToolchain From(string targetFrameworkMoniker, string packagesPath = null, string customDotNetCliPath = null)
public static IToolchain From(string targetFrameworkMoniker, string? packagesPath = null, string? customDotNetCliPath = null)
=> new CsProjClassicNetToolchain(targetFrameworkMoniker, targetFrameworkMoniker, packagesPath, customDotNetCliPath);

public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCase, IResolver resolver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DotNetCliBuilder : IBuilder
private bool RetryFailedBuildWithNoDeps { get; }

[PublicAPI]
public DotNetCliBuilder(string targetFrameworkMoniker, string customDotNetCliPath = null, bool logOutput = false, bool retryFailedBuildWithNoDeps = true)
public DotNetCliBuilder(string targetFrameworkMoniker, string? customDotNetCliPath = null, bool logOutput = false, bool retryFailedBuildWithNoDeps = true)
{
TargetFrameworkMoniker = targetFrameworkMoniker;
CustomDotNetCliPath = customDotNetCliPath;
Expand Down
Loading

0 comments on commit 5428ebd

Please sign in to comment.