Skip to content
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

Output a more debuggable message if a single value isn't specified #5533

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

jasonmalinowski
Copy link
Member

@jasonmalinowski jasonmalinowski commented Dec 7, 2023

A number of places call GetSingleNonEvaluatedPropertyOrNull to get the single value that spans all TFMs -- if that's not distinct though the failure that would bubble up to the user wouldn't point to the underlying issue. This makes the failure easier.

Bug

Fixes: NuGet/Home#8749

Regression? No.

Description

This adds a better exception message than simply calling SingleOrDefault(). The test changes mostly involve extracting out a helper function for other tests doing the same thing.

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

@jasonmalinowski jasonmalinowski requested a review from a team as a code owner December 7, 2023 06:10
@ghost ghost added the Community PRs created by someone not in the NuGet team label Dec 7, 2023
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.

The change looks great!

A few things:

@jasonmalinowski
Copy link
Member Author

@nkolev92: looking to see if there was an existing bug, I see NuGet/Home#8749 looks somewhat related -- want to call this as fixing that or have me file a new bug?

@nkolev92
Copy link
Member

nkolev92 commented Dec 8, 2023

@nkolev92: looking to see if there was an existing bug, I see NuGet/Home#8749 looks somewhat related -- want to call this as fixing that or have me file a new bug?

Nice catch, that's perfect.

A number of places call GetSingleNonEvaluatedPropertyOrNull to get
the single value that spans all TFMs -- if that's not distinct though
the failure that would bubble up to the user wouldn't point to the
underlying issue. This makes the failure easier.

Fixes NuGet/Home#8749
@jasonmalinowski jasonmalinowski force-pushed the add-better-logging-for-properties branch from 4a1eb15 to b0a0ec8 Compare December 8, 2023 20:40
@jasonmalinowski
Copy link
Member Author

@nkolev92 Exception message is now localized, and tests added. I broke out a test refactoring into a prior commit so it's a touch easier to review.

@nkolev92 nkolev92 self-assigned this Dec 8, 2023
@jeffkl jeffkl changed the title Output a more debuggable message if a single value isn't Output a more debuggable message if a single value isn't specified Dec 12, 2023
@nkolev92 nkolev92 enabled auto-merge (squash) December 13, 2023 16:55
@nkolev92 nkolev92 merged commit 947c839 into NuGet:dev Dec 13, 2023
15 of 16 checks passed
@jasonmalinowski jasonmalinowski deleted the add-better-logging-for-properties branch June 1, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PRs created by someone not in the NuGet team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NuGet should handle duplicate nomination data better.
3 participants