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

Refactoring the method that fetches the project context in the Solution PM UI #6065

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

jebriede
Copy link
Contributor

@jebriede jebriede commented Sep 27, 2024

Refactoring the method that fetches the project context in the Solution PM UI to return only a single package and simplify the caller logic

Bug

Fixes: NuGet/Home#13216

Description

Addressing feedback from the original pull request for the Transitive Packages in Solution PM UI feature: #6044 (comment). This is a better design to only return one package context object and simplifies the caller logic in determining if the package is top-level or transitive. Removed an outdated comment on the method, and renamed the method to more accurately reflect its purpose.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests - Refactoring existing method. No new functionality to test.
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

…on PM UI to return only a single package to simplify the caller logic
martinrrm
martinrrm previously approved these changes Oct 1, 2024
}
else
{
project.InstalledVersion = null;
project.PackageLevel = null;
project.PackageLevel = packageContext is ITransitivePackageReferenceContextInfo ? PackageLevel.Transitive : PackageLevel.TopLevel;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why set PackageLevel outside of the helper method UpdateProjectInstallationInfo?

}
else
{
project.InstalledVersion = null;
project.PackageLevel = null;
project.PackageLevel = packageContext is ITransitivePackageReferenceContextInfo ? PackageLevel.Transitive : PackageLevel.TopLevel;
Copy link
Contributor

Choose a reason for hiding this comment

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

May be out of scope for this PR. Looking at the is operator, I think ITransitivePackageReferenceContextInfo interface contract can be improved. Here are the reasons.

  • AFAIK, there is a concept called "Transitive package" but no such thing called "Transitive package reference" in NuGet.
  • ITransitivePackageReferenceContextInfo inherting IPackageReferenceContextInfo interface seems incorrect to me because it is primarily meant for obtaining "Transitive origins" for a package.
public interface IPackageReferenceContextInfo
{
    PackageIdentity Identity { get; }
    NuGetFramework? Framework { get; }
    VersionRange? AllowedVersions { get; }
    bool IsAutoReferenced { get; }
    bool IsUserInstalled { get; }
    bool IsDevelopmentDependency { get; }
    VersionRange? VersionOverride { get; }
}

public interface ITransitivePackageContextInfo
{
    PackageIdentity Identity { get; }
    IEnumerable<IPackageReferenceContextInfo> TransitiveOrigins { get; }
}

I am open for feedback and happy to create a tech debt tracking issue.

Copy link
Contributor Author

@jebriede jebriede Oct 1, 2024

Choose a reason for hiding this comment

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

Definitely out of scope for this refactor. Please open an issue that explains the alternative you propose. I'll add details on the issue about how this evolved such that Transitive Packages became a specialized PackageReferenceContextInfo. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@jebriede jebriede merged commit 764d370 into dev Oct 7, 2024
28 checks passed
@jebriede jebriede deleted the dev-jebriede-GettingSolutionPMUIPkgContextInfo branch October 7, 2024 18:00
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.

[Feature] Enable Transitive Dependencies for Solution-level in Visual Studio
4 participants