Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion dnup.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"src\\Installer\\dnup\\dnup.csproj",
"src\\Installer\\Microsoft.Dotnet.Installation\\Microsoft.Dotnet.Installation.csproj",
"test\\dnup.Tests\\dnup.Tests.csproj",
"src\\Resolvers\\Microsoft.DotNet.NativeWrapper\\Microsoft.DotNet.NativeWrapper.csproj
]
}
}
}
8 changes: 4 additions & 4 deletions src/Cli/dotnet/Telemetry/EnvironmentDetectionRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public BooleanEnvironmentRule(params string[] variables)

public override bool IsMatch()
{
return _variables.Any(variable =>
return _variables.Any(variable =>
bool.TryParse(Environment.GetEnvironmentVariable(variable), out bool value) && value);
}
}
Expand Down Expand Up @@ -96,8 +96,8 @@ public EnvironmentDetectionRuleWithResult(T result, params string[] variables)
/// <returns>The result value if the rule matches; otherwise, null.</returns>
public T? GetResult()
{
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
? _result
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
? _result
: null;
}
}
}
31 changes: 31 additions & 0 deletions src/Installer/Microsoft.Dotnet.Installation/DownloadProgress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;

namespace Microsoft.Dotnet.Installation
{
/// <summary>
/// Represents download progress information.
/// </summary>
public readonly struct DownloadProgress
{
/// <summary>
/// Gets the number of bytes downloaded.
/// </summary>
public long BytesDownloaded { get; }

/// <summary>
/// Gets the total number of bytes to download, if known.
/// </summary>
public long? TotalBytes { get; }

/// <summary>
/// Gets the percentage of download completed, if total size is known.
/// </summary>
public double? PercentComplete => TotalBytes.HasValue ? (double)BytesDownloaded / TotalBytes.Value * 100 : null;

public DownloadProgress(long bytesDownloaded, long? totalBytes)
{
BytesDownloaded = bytesDownloaded;
TotalBytes = totalBytes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ public void Commit(IEnumerable<ReleaseVersion> existingSdkVersions)
{
// When no-progress is enabled, install without progress display
Console.WriteLine($"Installing .NET SDK {_resolvedVersion}...");

// Extract archive directly to target directory with special handling for muxer
var extractResult = ExtractArchiveDirectlyToTarget(_archivePath, _request.InstallRoot.Path!, existingSdkVersions, null);
if (extractResult != null)
if (extractResult is not null)
{
throw new InvalidOperationException($"Failed to install SDK: {extractResult}");
}

Console.WriteLine($"Installation of .NET SDK {_resolvedVersion} complete.");
}
else
Expand All @@ -135,7 +135,7 @@ public void Commit(IEnumerable<ReleaseVersion> existingSdkVersions)

// Extract archive directly to target directory with special handling for muxer
var extractResult = ExtractArchiveDirectlyToTarget(_archivePath, _request.InstallRoot.Path!, existingSdkVersions, installTask);
if (extractResult != null)
if (extractResult is not null)
{
throw new InvalidOperationException($"Failed to install SDK: {extractResult}");
}
Expand Down Expand Up @@ -204,7 +204,7 @@ private MuxerHandlingConfig ConfigureMuxerHandling(IEnumerable<ReleaseVersion> e
long totalFiles = CountTarEntries(decompressedPath);

// Set progress maximum
if (installTask != null)
if (installTask is not null)
{
installTask.MaxValue = totalFiles > 0 ? totalFiles : 1;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ private long CountTarEntries(string tarPath)
long totalFiles = 0;
using var tarStream = File.OpenRead(tarPath);
var tarReader = new TarReader(tarStream);
while (tarReader.GetNextEntry() != null)
while (tarReader.GetNextEntry() is not null)
{
totalFiles++;
}
Expand All @@ -271,7 +271,7 @@ private void ExtractTarContents(string tarPath, string targetDir, MuxerHandlingC
var tarReader = new TarReader(tarStream);
TarEntry? entry;

while ((entry = tarReader.GetNextEntry()) != null)
while ((entry = tarReader.GetNextEntry()) is not null)
{
if (entry.EntryType == TarEntryType.RegularFile)
{
Expand Down
Loading