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

Remove NuGetOperationType #5394

Merged
merged 4 commits into from
Sep 5, 2023
Merged

Conversation

nkolev92
Copy link
Member

@nkolev92 nkolev92 commented Sep 1, 2023

Bug

Fixes: NuGet/Home#12866

Regression? Last working version:

Description

While working conditional PR updating, I noticed myself doing a lot of duplicated work. See more details for motivation: https://github.com/NuGet/NuGet.Client/compare/dev-nkolev92-conditionalPackageReferenceUpdating?expand=1

For example, I had to do lots of conversions with NuGetProjectActionType and NuGetOperationType.
This is redundant, and makes our code more complicated.

I looked at the references and the only place where the NuGetOperationType is explicitly used is as an API is ActionTelemetryEvent, which is not used a lot.

Now this is a breaking change to a public API, which is why this refactoring is coming on its own instead as part of the PR that will follow, but the reasoning is that we should reducing duplication and unnecessary conversion. The likelihood of this API breaking anyone is super low.

Note - Note that NuGet.PackageManagement is not part of the .NET SDK. It is the broadest package we ship and is primarily used by component that package all of the NuGet functionality themselves, rather than as an extension of NuGet.

If people are ok with this change, and I'm looking at @zivkan primarily, I'll create a bug matching the reasoning in this description, and mark with Type:BreakingChange.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added - The tests were changed to simply use the new type.
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

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

@nkolev92 nkolev92 requested a review from a team as a code owner September 1, 2023 00:57
/// Uninstall package action.
/// </summary>
Uninstall = 2,
public NuGetProjectActionType OperationType => (NuGetProjectActionType)base[nameof(OperationType)];
Copy link
Contributor

@dtivel dtivel Sep 1, 2023

Choose a reason for hiding this comment

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

If I am understanding correctly, OperationType is emitted telemetry. If so, why not keep NuGetOperationType and remove NuGetProjectActionType. If the current change --- removing NuGetOperationType --- makes more sense, why not update parameter names (operationType -> actionType)? This property can remain as-is for telemetry.

Copy link
Member Author

@nkolev92 nkolev92 Sep 1, 2023

Choose a reason for hiding this comment

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

NuGetProjectActionType is used more heavily overall. 80+ references vs 20ish of NuGetOperationType.

NuGetProjectActionType is also used more in public types. More notable in the NuGetProjectAction which itself is a type that's used a lot.

Copy link
Member

@zivkan zivkan left a comment

Choose a reason for hiding this comment

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

I'm not too concerned about NuGet.PackageManagement.

While sometimes similar but different APIs can be useful for strongly typed language type safety, it's not clear to me these two enums provide any API correctness benefits, so consolidating them is fine with me.

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.

Remove the NuGetOperationType from NuGet.PackageManagement, use NuGetProjectActionType instead
3 participants