Skip to content

Conversation

@donnie-msft
Copy link
Contributor

@donnie-msft donnie-msft commented Jan 25, 2021

Bug

Fixes: NuGet/Home#9882

Regression? Last working version: 16.7

Description

Use an always populated Version object. LatestVersion is only set on a subset of packages. Version is always set.
A new unit test demonstrates the logic that will throw for a null version.

Added an ArgumentNullException that could cause a similar error.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@donnie-msft donnie-msft marked this pull request as ready for review January 25, 2021 18:38
@donnie-msft donnie-msft requested a review from a team as a code owner January 25, 2021 18:38
Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch :)

}

/// <summary>
/// Repro for a bug caused by a NullReferenceException being thrown due to a null <see cref="PackageIdentity.Version"/>
Copy link
Member

Choose a reason for hiding this comment

The 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 input error, not necessarily a contract we're going to try to maintain.

Copy link
Contributor Author

@donnie-msft donnie-msft Jan 26, 2021

Choose a reason for hiding this comment

The 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),
or you have a test proving it does what you found it does. It also helps someone see this code depends on non-null versions

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide against adding an input check?
Will the call always fail if the input PackageIdentity has a null version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Not always, nope. Has to be BuildIntegrated project, with at least 1 update available.

Copy link
Member

Choose a reason for hiding this comment

The 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.

I think this can be considered in scope.
Changing the NuGetPackageManager class to ensure we don't run into unexpected exceptions is in scope.
Especially because there wouldn't be any side-effects.

Copy link
Contributor Author

@donnie-msft donnie-msft Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially because there wouldn't be any side-effects.

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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updating in PMUI causes Object reference not set to an instance of an object

3 participants