Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enabled nullability for BenchmarkDotNet.Diagnostics.dotTrace.csproj
  • Loading branch information
alinasmirnova committed Sep 1, 2023
commit 6b7c17966de495f6a8d29ce553a01aabc7f24d41
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<AssemblyTitle>BenchmarkDotNet.Diagnostics.dotTrace</AssemblyTitle>
<AssemblyName>BenchmarkDotNet.Diagnostics.dotTrace</AssemblyName>
<PackageId>BenchmarkDotNet.Diagnostics.dotTrace</PackageId>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
{
public class DotTraceDiagnoser : IProfiler
{
private readonly Uri nugetUrl;
private readonly string toolsDownloadFolder;
private readonly Uri? nugetUrl;
private readonly string? toolsDownloadFolder;

public DotTraceDiagnoser(Uri nugetUrl = null, string toolsDownloadFolder = null)
public DotTraceDiagnoser(Uri? nugetUrl = null, string? toolsDownloadFolder = null)
{
this.nugetUrl = nugetUrl;
this.toolsDownloadFolder = toolsDownloadFolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public DotTraceDiagnoserAttribute()
Config = ManualConfig.CreateEmpty().AddDiagnoser(new DotTraceDiagnoser());
}

public DotTraceDiagnoserAttribute(Uri nugetUrl = null, string toolsDownloadFolder = null)
public DotTraceDiagnoserAttribute(Uri? nugetUrl = null, string? toolsDownloadFolder = null)
{
Config = ManualConfig.CreateEmpty().AddDiagnoser(new DotTraceDiagnoser(nugetUrl, toolsDownloadFolder));
}
Expand Down
14 changes: 7 additions & 7 deletions src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceToolBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
internal abstract class DotTraceToolBase
{
private readonly ILogger logger;
private readonly Uri nugetUrl;
private readonly Uri? nugetUrl;
private readonly NuGetApi nugetApi;
private readonly string downloadTo;
private readonly string? downloadTo;

protected DotTraceToolBase(ILogger logger, Uri nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string downloadTo = null)
protected DotTraceToolBase(ILogger logger, Uri? nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string? downloadTo = null)
{
this.logger = logger;
this.nugetUrl = nugetUrl;
Expand Down Expand Up @@ -48,9 +48,9 @@ public void Init(DiagnoserActionParameters parameters)
public string Start(DiagnoserActionParameters parameters)
{
string snapshotFile = ArtifactFileNameHelper.GetFilePath(parameters, "snapshots", DateTime.Now, "dtp", ".0000".Length);
string snapshotDirectory = Path.GetDirectoryName(snapshotFile);
string? snapshotDirectory = Path.GetDirectoryName(snapshotFile);
logger.WriteLineInfo($"Target snapshot file: {snapshotFile}");
if (!Directory.Exists(snapshotDirectory))
if (!Directory.Exists(snapshotDirectory) && snapshotDirectory != null)
{
try
{
Expand Down Expand Up @@ -126,7 +126,7 @@ protected string GetRunnerPath()
if (consoleRunnerPackageField == null)
throw new InvalidOperationException("Field 'ConsoleRunnerPackage' not found.");

object consoleRunnerPackage = consoleRunnerPackageField.GetValue(null);
object? consoleRunnerPackage = consoleRunnerPackageField.GetValue(null);
if (consoleRunnerPackage == null)
throw new InvalidOperationException("Unable to get value of 'ConsoleRunnerPackage'.");

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class ExternalDotTraceTool : DotTraceToolBase
{
private static readonly TimeSpan AttachTimeout = TimeSpan.FromMinutes(5);

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

protected override bool AttachOnly => true;
Expand Down Expand Up @@ -44,7 +44,7 @@ protected override void Attach(DiagnoserActionParameters parameters, string snap
{
process.OutputDataReceived += (_, args) =>
{
string content = args.Data;
string? content = args.Data;
if (content != null)
{
logger.WriteLineInfo("[dotTrace] " + content);
Expand All @@ -54,7 +54,7 @@ protected override void Attach(DiagnoserActionParameters parameters, string snap
};
process.ErrorDataReceived += (_, args) =>
{
string content = args.Data;
string? content = args.Data;
if (content != null)
logger.WriteLineError("[dotTrace] " + args.Data);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BenchmarkDotNet.Diagnostics.dotTrace
{
internal class InProcessDotTraceTool : DotTraceToolBase
{
public InProcessDotTraceTool(ILogger logger, Uri nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string downloadTo = null) :
public InProcessDotTraceTool(ILogger logger, Uri? nugetUrl = null, NuGetApi nugetApi = NuGetApi.V3, string? downloadTo = null) :
base(logger, nugetUrl, nugetApi, downloadTo) { }

protected override bool AttachOnly => false;
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet.Diagnostics.dotTrace/Progress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Progress(ILogger logger, string title)
}

private int lastProgress;
private Stopwatch stopwatch;
private Stopwatch? stopwatch;

public void Report(double value)
{
Expand Down