Skip to content

Commit 516bd68

Browse files
alinasmirnovaAndreyAkinshin
authored andcommitted
Enabled nullability for BenchmarkDotNet.Diagnostics.dotTrace.csproj
1 parent 8986e05 commit 516bd68

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

src/BenchmarkDotNet.Diagnostics.dotTrace/BenchmarkDotNet.Diagnostics.dotTrace.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<AssemblyTitle>BenchmarkDotNet.Diagnostics.dotTrace</AssemblyTitle>
77
<AssemblyName>BenchmarkDotNet.Diagnostics.dotTrace</AssemblyName>
88
<PackageId>BenchmarkDotNet.Diagnostics.dotTrace</PackageId>
9+
<Nullable>enable</Nullable>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
1919
{
2020
public class DotTraceDiagnoser : IProfiler
2121
{
22-
private readonly Uri nugetUrl;
23-
private readonly string toolsDownloadFolder;
22+
private readonly Uri? nugetUrl;
23+
private readonly string? toolsDownloadFolder;
2424

25-
public DotTraceDiagnoser(Uri nugetUrl = null, string toolsDownloadFolder = null)
25+
public DotTraceDiagnoser(Uri? nugetUrl = null, string? toolsDownloadFolder = null)
2626
{
2727
this.nugetUrl = nugetUrl;
2828
this.toolsDownloadFolder = toolsDownloadFolder;

src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoserAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public DotTraceDiagnoserAttribute()
1313
Config = ManualConfig.CreateEmpty().AddDiagnoser(new DotTraceDiagnoser());
1414
}
1515

16-
public DotTraceDiagnoserAttribute(Uri nugetUrl = null, string toolsDownloadFolder = null)
16+
public DotTraceDiagnoserAttribute(Uri? nugetUrl = null, string? toolsDownloadFolder = null)
1717
{
1818
Config = ManualConfig.CreateEmpty().AddDiagnoser(new DotTraceDiagnoser(nugetUrl, toolsDownloadFolder));
1919
}

src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceToolBase.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
1111
internal abstract class DotTraceToolBase
1212
{
1313
private readonly ILogger logger;
14-
private readonly Uri nugetUrl;
14+
private readonly Uri? nugetUrl;
1515
private readonly NuGetApi nugetApi;
16-
private readonly string downloadTo;
16+
private readonly string? downloadTo;
1717

18-
protected DotTraceToolBase(ILogger logger, Uri nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string downloadTo = null)
18+
protected DotTraceToolBase(ILogger logger, Uri? nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string? downloadTo = null)
1919
{
2020
this.logger = logger;
2121
this.nugetUrl = nugetUrl;
@@ -48,9 +48,9 @@ public void Init(DiagnoserActionParameters parameters)
4848
public string Start(DiagnoserActionParameters parameters)
4949
{
5050
string snapshotFile = ArtifactFileNameHelper.GetFilePath(parameters, "snapshots", DateTime.Now, "dtp", ".0000".Length);
51-
string snapshotDirectory = Path.GetDirectoryName(snapshotFile);
51+
string? snapshotDirectory = Path.GetDirectoryName(snapshotFile);
5252
logger.WriteLineInfo($"Target snapshot file: {snapshotFile}");
53-
if (!Directory.Exists(snapshotDirectory))
53+
if (!Directory.Exists(snapshotDirectory) && snapshotDirectory != null)
5454
{
5555
try
5656
{
@@ -126,7 +126,7 @@ protected string GetRunnerPath()
126126
if (consoleRunnerPackageField == null)
127127
throw new InvalidOperationException("Field 'ConsoleRunnerPackage' not found.");
128128

129-
object consoleRunnerPackage = consoleRunnerPackageField.GetValue(null);
129+
object? consoleRunnerPackage = consoleRunnerPackageField.GetValue(null);
130130
if (consoleRunnerPackage == null)
131131
throw new InvalidOperationException("Unable to get value of 'ConsoleRunnerPackage'.");
132132

@@ -135,7 +135,7 @@ protected string GetRunnerPath()
135135
if (getRunnerPathMethod == null)
136136
throw new InvalidOperationException("Method 'GetRunnerPath' not found.");
137137

138-
string runnerPath = getRunnerPathMethod.Invoke(consoleRunnerPackage, null) as string;
138+
string? runnerPath = getRunnerPathMethod.Invoke(consoleRunnerPackage, null) as string;
139139
if (runnerPath == null)
140140
throw new InvalidOperationException("Unable to invoke 'GetRunnerPath'.");
141141

src/BenchmarkDotNet.Diagnostics.dotTrace/ExternalDotTraceTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class ExternalDotTraceTool : DotTraceToolBase
1212
{
1313
private static readonly TimeSpan AttachTimeout = TimeSpan.FromMinutes(5);
1414

15-
public ExternalDotTraceTool(ILogger logger, Uri nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string downloadTo = null) :
15+
public ExternalDotTraceTool(ILogger logger, Uri? nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string? downloadTo = null) :
1616
base(logger, nugetUrl, nugetApi, downloadTo) { }
1717

1818
protected override bool AttachOnly => true;
@@ -44,7 +44,7 @@ protected override void Attach(DiagnoserActionParameters parameters, string snap
4444
{
4545
process.OutputDataReceived += (_, args) =>
4646
{
47-
string content = args.Data;
47+
string? content = args.Data;
4848
if (content != null)
4949
{
5050
logger.WriteLineInfo("[dotTrace] " + content);
@@ -54,7 +54,7 @@ protected override void Attach(DiagnoserActionParameters parameters, string snap
5454
};
5555
process.ErrorDataReceived += (_, args) =>
5656
{
57-
string content = args.Data;
57+
string? content = args.Data;
5858
if (content != null)
5959
logger.WriteLineError("[dotTrace] " + args.Data);
6060
};

src/BenchmarkDotNet.Diagnostics.dotTrace/InProcessDotTraceTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
77
{
88
internal class InProcessDotTraceTool : DotTraceToolBase
99
{
10-
public InProcessDotTraceTool(ILogger logger, Uri nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string downloadTo = null) :
10+
public InProcessDotTraceTool(ILogger logger, Uri? nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string? downloadTo = null) :
1111
base(logger, nugetUrl, nugetApi, downloadTo) { }
1212

1313
protected override bool AttachOnly => false;

src/BenchmarkDotNet.Diagnostics.dotTrace/Progress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public Progress(ILogger logger, string title)
1818
}
1919

2020
private int lastProgress;
21-
private Stopwatch stopwatch;
21+
private Stopwatch? stopwatch;
2222

2323
public void Report(double value)
2424
{

0 commit comments

Comments
 (0)