-
Notifications
You must be signed in to change notification settings - Fork 736
Updating via Checkboxes no longer causes Null Reference Exception #3864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6975,6 +6975,73 @@ await nuGetPackageManager.PreviewBuildIntegratedProjectsActionsAsync( | |
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Repro for a bug caused by a NullReferenceException being thrown due to a null <see cref="PackageIdentity.Version"/> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What kind of value does this test provide us beyond being great for this review? It's an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The input error is "by design". So you either handle the input error (I did not change this), Then, you have a test that can be easily flipped if/when we decide on a different design. Most of the test work is done, and the PR will be more clear.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you decide against adding an input check?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I'm trying to fix a bug specifically. Not redesign the inners of Package Manager.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this can be considered in scope.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't have proof of that. And it's a 16.9 blocking bug, so not the time to start paying our debts. I think as part of 16.10 refactoring, this could be evaluated.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Synced up offline. Call it good for 16.9, consider additional quality improvements in NuGetPackageManager for 16.10. |
||
| /// (https://github.com/NuGet/Home/issues/9882). | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| [Fact] | ||
| public async Task TestPacMan_PreviewInstallPackage_BuildIntegrated_NullVersion_Throws() | ||
| { | ||
| // Arrange | ||
|
|
||
| // Set up Package Source | ||
| var packages = new List<SourcePackageDependencyInfo> | ||
| { | ||
| new SourcePackageDependencyInfo("a", new NuGetVersion(1, 0, 0), new PackageDependency[] { }, true, null), | ||
| new SourcePackageDependencyInfo("a", new NuGetVersion(2, 0, 0), new PackageDependency[] { }, true, null), | ||
| new SourcePackageDependencyInfo("a", new NuGetVersion(3, 0, 0), new PackageDependency[] { }, true, null), | ||
| }; | ||
|
|
||
| SourceRepositoryProvider sourceRepositoryProvider = CreateSource(packages); | ||
|
|
||
| // Set up NuGetProject | ||
| var fwk45 = NuGetFramework.Parse("net45"); | ||
|
|
||
| var installedPackages = new List<NuGet.Packaging.PackageReference> | ||
| { | ||
| new PackageReference(new PackageIdentity("a", new NuGetVersion(1, 0, 0)), fwk45, true), | ||
| }; | ||
|
|
||
| var packageIdentity = _packageWithDependents[0]; | ||
|
|
||
| // Create Package Manager | ||
| using (var solutionManager = new TestSolutionManager()) | ||
| { | ||
| var nuGetPackageManager = new NuGetPackageManager( | ||
| sourceRepositoryProvider, | ||
| NullSettings.Instance, | ||
| solutionManager, | ||
| new TestDeleteOnRestartManager()); | ||
|
|
||
| var buildIntegratedProjectA = new Mock<BuildIntegratedNuGetProject>(); | ||
| buildIntegratedProjectA.Setup(p => p.GetInstalledPackagesAsync(CancellationToken.None)) | ||
| .Returns(() => Task.FromResult(installedPackages.AsEnumerable())); | ||
|
|
||
| var projectList = new List<NuGetProject> { buildIntegratedProjectA.Object }; | ||
| solutionManager.NuGetProjects = projectList; | ||
|
|
||
| // Main Act | ||
| var targets = new List<PackageIdentity> | ||
| { | ||
| new PackageIdentity("a", null) | ||
| }; | ||
|
|
||
| // Assert | ||
| var ex = await Assert.ThrowsAsync<NullReferenceException>(async () => | ||
| { | ||
| IEnumerable<NuGetProjectAction> result = await nuGetPackageManager.PreviewUpdatePackagesAsync( | ||
| targets, | ||
| projectList, | ||
| new ResolutionContext(), | ||
| new TestNuGetProjectContext(), | ||
| sourceRepositoryProvider.GetRepositories(), | ||
| sourceRepositoryProvider.GetRepositories(), | ||
| CancellationToken.None); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| private void VerifyPreviewActionsTelemetryEvents_PackagesConfig(IEnumerable<string> actual) | ||
| { | ||
| Assert.True(actual.Contains(TelemetryConstants.GatherDependencyStepName)); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.