From a608b23f6b79149493d8281f071c2fea2b55f83f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 01:53:22 +0000 Subject: [PATCH 1/4] Bump NuGet.Configuration from 6.6.1 to 6.7.0 in /eng/dependabot Bumps [NuGet.Configuration](https://github.com/NuGet/NuGet.Client) from 6.6.1 to 6.7.0. - [Release notes](https://github.com/NuGet/NuGet.Client/releases) - [Commits](https://github.com/NuGet/NuGet.Client/commits) --- updated-dependencies: - dependency-name: NuGet.Configuration dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- eng/dependabot/Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/dependabot/Packages.props b/eng/dependabot/Packages.props index f7c11e7dc45..b5c0a9d71de 100644 --- a/eng/dependabot/Packages.props +++ b/eng/dependabot/Packages.props @@ -12,7 +12,7 @@ - + From aa392ba39dc5892d48febd1254068a82c4e67116 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Wed, 16 Aug 2023 09:01:43 -0700 Subject: [PATCH 2/4] Collapse NuGet updates to a single PR --- eng/dependabot/Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/dependabot/Packages.props b/eng/dependabot/Packages.props index b5c0a9d71de..d43a4acb62a 100644 --- a/eng/dependabot/Packages.props +++ b/eng/dependabot/Packages.props @@ -13,8 +13,8 @@ - - + + From f0031d811b7ff1a5e5e970cab2a4e749cea46a9f Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Tue, 12 Sep 2023 03:34:27 -0700 Subject: [PATCH 3/4] Fixed errors caused by nullable --- .../Constraints/NuGetFloatRangeSpecification.cs | 4 ++-- .../Constraints/NuGetVersionRangeSpecification.cs | 4 ++-- .../Constraints/NuGetVersionSpecification.cs | 4 ++-- .../Installers/NuGet/NuGetVersionHelper.cs | 4 ++-- .../Installers/NuGet/NugetApiPackageManager.cs | 6 +++--- test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs | 2 +- .../NuGet/NugetPackProvider.cs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs index c0e219f5522..9bec8690992 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs @@ -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); } @@ -28,7 +28,7 @@ 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); return true; diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs index edb9c9053d2..d7a8f78259b 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs @@ -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); } @@ -28,7 +28,7 @@ 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); return true; diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs index f5e8e26b3f1..b76f4db5c5b 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs @@ -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; } @@ -28,7 +28,7 @@ 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); return true; diff --git a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NuGetVersionHelper.cs b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NuGetVersionHelper.cs index 2e1b7c73a89..f6627490c18 100644 --- a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NuGetVersionHelper.cs +++ b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NuGetVersionHelper.cs @@ -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) @@ -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; } diff --git a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs index 2897de0be70..5d005fe1ae2 100644 --- a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs +++ b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs @@ -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); } @@ -94,7 +94,7 @@ await GetLatestVersionInternalAsync( throw new VulnerablePackageException( string.Format(LocalizableStrings.NuGetApiPackageManager_DownloadError_VulnerablePackage, source), packageMetadata.Identity.Id, - foundPackageVersion, + foundPackageVersion!, packageMetadata.Vulnerabilities); } @@ -204,7 +204,7 @@ 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; } diff --git a/test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs b/test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs index 8942bce05e7..c9f3e8bb810 100644 --- a/test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs +++ b/test/Microsoft.TemplateEngine.TestHelper/PackageManager.cs @@ -192,7 +192,7 @@ internal async Task 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); } diff --git a/tools/Microsoft.TemplateSearch.TemplateDiscovery/NuGet/NugetPackProvider.cs b/tools/Microsoft.TemplateSearch.TemplateDiscovery/NuGet/NugetPackProvider.cs index 8487f377e34..164eba81d9c 100644 --- a/tools/Microsoft.TemplateSearch.TemplateDiscovery/NuGet/NugetPackProvider.cs +++ b/tools/Microsoft.TemplateSearch.TemplateDiscovery/NuGet/NugetPackProvider.cs @@ -146,7 +146,7 @@ public async Task 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, From 865b2fe2c001a710ae6f0b6b55212acad2c0d4c5 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Mon, 18 Sep 2023 19:54:34 -0700 Subject: [PATCH 4/4] Fix null reference exception --- .../Constraints/NuGetFloatRangeSpecification.cs | 2 +- .../Constraints/NuGetVersionRangeSpecification.cs | 2 +- .../Constraints/NuGetVersionSpecification.cs | 2 +- .../Installers/NuGet/NugetApiPackageManager.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs index 9bec8690992..3f51d7fc967 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetFloatRangeSpecification.cs @@ -30,7 +30,7 @@ internal static bool TryParse(string value, out NuGetFloatRangeSpecification? ve { if (FloatRange.TryParse(value, out FloatRange? versionRange)) { - version = new NuGetFloatRangeSpecification(versionRange); + version = new NuGetFloatRangeSpecification(versionRange!); return true; } version = null; diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs index d7a8f78259b..df76d80688c 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionRangeSpecification.cs @@ -30,7 +30,7 @@ internal static bool TryParse(string value, out NuGetVersionRangeSpecification? { if (VersionRange.TryParse(value, out VersionRange? versionRange)) { - version = new NuGetVersionRangeSpecification(versionRange); + version = new NuGetVersionRangeSpecification(versionRange!); return true; } version = null; diff --git a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs index b76f4db5c5b..a8a457746e1 100644 --- a/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs +++ b/src/Microsoft.TemplateEngine.Edge/Constraints/NuGetVersionSpecification.cs @@ -30,7 +30,7 @@ internal static bool TryParse(string value, out NuGetVersionSpecification? versi { if (NuGetVersion.TryParse(value, out NuGetVersion? nuGetVersion)) { - version = new NuGetVersionSpecification(nuGetVersion); + version = new NuGetVersionSpecification(nuGetVersion!); return true; } version = null; diff --git a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs index 015cc6626a6..21907d47690 100644 --- a/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs +++ b/src/Microsoft.TemplateEngine.Edge/Installers/NuGet/NugetApiPackageManager.cs @@ -206,7 +206,7 @@ await GetLatestVersionInternalAsync( bool previewVersionInstalled = false; if (NuGetVersion.TryParse(version, out NuGetVersion? currentVersion)) { - previewVersionInstalled = currentVersion.IsPrerelease; + previewVersionInstalled = currentVersion!.IsPrerelease; } FloatRange floatRange = new FloatRange(previewVersionInstalled ? NuGetVersionFloatBehavior.AbsoluteLatest : NuGetVersionFloatBehavior.Major);