Skip to content

Commit

Permalink
Merge pull request #7041 from dotnet/v-wuzhai/Fixes#6952
Browse files Browse the repository at this point in the history
Update NuGet.Configuration, NuGet.Credentials and NuGet.Protocol
  • Loading branch information
v-wuzhai authored Sep 25, 2023
2 parents d0152e5 + 865b2fe commit afffc77
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions eng/dependabot/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageReference Update="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Update="NuGet.Configuration" Version="6.6.1" />
<PackageReference Update="NuGet.Credentials" Version="6.6.1" />
<PackageReference Update="NuGet.Protocol" Version="6.6.1" />
<PackageReference Update="NuGet.Configuration" Version="6.7.0" />
<PackageReference Update="NuGet.Credentials" Version="6.7.0" />
<PackageReference Update="NuGet.Protocol" Version="6.7.0" />

<!--Analyzers-->
<PackageReference Update="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal NuGetFloatRangeSpecification(FloatRange version)

public bool CheckIfVersionIsValid(string versionToCheck)
{
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion nuGetVersion2))
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion? nuGetVersion2))
{
return _version.Satisfies(nuGetVersion2);
}
Expand All @@ -28,9 +28,9 @@ public bool CheckIfVersionIsValid(string versionToCheck)

internal static bool TryParse(string value, out NuGetFloatRangeSpecification? version)
{
if (FloatRange.TryParse(value, out FloatRange versionRange))
if (FloatRange.TryParse(value, out FloatRange? versionRange))
{
version = new NuGetFloatRangeSpecification(versionRange);
version = new NuGetFloatRangeSpecification(versionRange!);
return true;
}
version = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal NuGetVersionRangeSpecification(VersionRange versionRange)

public bool CheckIfVersionIsValid(string versionToCheck)
{
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion nuGetVersion2))
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion? nuGetVersion2))
{
return _versionRange.Satisfies(nuGetVersion2);
}
Expand All @@ -28,9 +28,9 @@ public bool CheckIfVersionIsValid(string versionToCheck)

internal static bool TryParse(string value, out NuGetVersionRangeSpecification? version)
{
if (VersionRange.TryParse(value, out VersionRange versionRange))
if (VersionRange.TryParse(value, out VersionRange? versionRange))
{
version = new NuGetVersionRangeSpecification(versionRange);
version = new NuGetVersionRangeSpecification(versionRange!);
return true;
}
version = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal NuGetVersionSpecification(NuGetVersion version)

public bool CheckIfVersionIsValid(string versionToCheck)
{
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion nuGetVersion2))
if (NuGetVersion.TryParse(versionToCheck, out NuGetVersion? nuGetVersion2))
{
return _version == nuGetVersion2;
}
Expand All @@ -28,9 +28,9 @@ public bool CheckIfVersionIsValid(string versionToCheck)

internal static bool TryParse(string value, out NuGetVersionSpecification? version)
{
if (NuGetVersion.TryParse(value, out NuGetVersion nuGetVersion))
if (NuGetVersion.TryParse(value, out NuGetVersion? nuGetVersion))
{
version = new NuGetVersionSpecification(nuGetVersion);
version = new NuGetVersionSpecification(nuGetVersion!);
return true;
}
version = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static bool IsSupportedVersionString(string? versionString)
||
NuGetVersion.TryParse(versionString, out _)
||
FloatRange.TryParse(versionString, out _);
FloatRange.TryParse(versionString!, out _);
}

public static bool IsUnrestricted(this FloatRange floatRange)
Expand All @@ -37,7 +37,7 @@ public static bool TryParseFloatRangeEx(string? versionString, out FloatRange fl
{
floatRange =
string.IsNullOrEmpty(versionString) ?
UnspecifiedVersion : FloatRange.Parse(versionString);
UnspecifiedVersion : FloatRange.Parse(versionString!);

return floatRange.FloatBehavior != NuGetVersionFloatBehavior.None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ await GetLatestVersionInternalAsync(
}
else
{
NuGetVersion packageVersion = new NuGetVersion(version);
NuGetVersion packageVersion = new NuGetVersion(version!);
(source, packageMetadata) = await GetPackageMetadataAsync(identifier, packageVersion, packagesSources, cancellationToken).ConfigureAwait(false);
}

Expand All @@ -94,7 +94,7 @@ await GetLatestVersionInternalAsync(
throw new VulnerablePackageException(
string.Format(LocalizableStrings.NuGetApiPackageManager_DownloadError_VulnerablePackage, source),
packageMetadata.Identity.Id,
foundPackageVersion,
foundPackageVersion!,
packageMetadata.Vulnerabilities);
}

Expand Down Expand Up @@ -204,9 +204,9 @@ await GetLatestVersionInternalAsync(

//if preview version is installed, check for the latest preview version, otherwise for latest stable
bool previewVersionInstalled = false;
if (NuGetVersion.TryParse(version, out NuGetVersion currentVersion))
if (NuGetVersion.TryParse(version, out NuGetVersion? currentVersion))
{
previewVersionInstalled = currentVersion.IsPrerelease;
previewVersionInstalled = currentVersion!.IsPrerelease;
}

FloatRange floatRange = new FloatRange(previewVersionInstalled ? NuGetVersionFloatBehavior.AbsoluteLatest : NuGetVersionFloatBehavior.Major);
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ internal async Task<string> DownloadPackageAsync(
else
{
_nugetLogger.LogDebug($"[NuGet Package Manager] Getting package metadata {identifier}::{version}.");
packageVersion = new NuGetVersion(version);
packageVersion = new NuGetVersion(version!);
(source, packageMetadata) = await GetPackageMetadataAsync(identifier, packageVersion, packagesSources, cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task<IDownloadedPackInfo> DownloadPackageAsync(ITemplatePackageInfo
using Stream packageStream = File.Create(outputPackageFileNameFullPath);
if (await _downloadResource.CopyNupkgToStreamAsync(
packinfo.Name,
new NuGetVersion(packinfo.Version),
new NuGetVersion(packinfo.Version!),
packageStream,
_cacheContext,
NullLogger.Instance,
Expand Down

0 comments on commit afffc77

Please sign in to comment.