Skip to content

[Data Model Improvements] Add Transitive and Installed package models - #6313

Merged
jgonz120 merged 5 commits into
dev-feature-PackageDomainModelfrom
dev-jgonz120-newModels
Mar 14, 2025
Merged

jgonz120 merged 5 commits into
dev-feature-PackageDomainModelfrom
dev-jgonz120-newModels

Conversation

@jgonz120

Copy link
Copy Markdown
Contributor

Bug

Fixes:

Description

Add Transitive and Installed package models

PR Checklist

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

@jgonz120
jgonz120 requested a review from a team as a code owner March 12, 2025 22:14
@jgonz120
jgonz120 changed the base branch from dev to dev-feature-PackageDomainModel March 12, 2025 22:14
@jgonz120
jgonz120 requested a review from Copilot March 12, 2025 22:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds models for transitive and installed packages and updates related tests and supporting classes. Key changes include:

  • Addition of InstalledPackageModel and TransitivePackageModel classes along with corresponding tests.
  • Updates to PackageModel, LocalPackageModel, and RemotePackageModel constructors to include a published date.
  • Adjustments in test cases to account for changes in dependency set handling.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/InstalledPackageModelTests.cs Added tests verifying the ReportAbuseUrl initialization.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/TransitivePackageModelTests.cs Added tests to validate transitive origins in the TransitivePackageModel.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/TransitivePackageModel.cs Introduced TransitivePackageModel inheriting from InstalledPackageModel with transitive origins.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/InstalledPackageModel.cs Extended InstalledPackageModel to include ReportAbuseUrl initialization.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/PackageModel.cs Updated the constructor to pass a published date to the model.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/LocalPackageModel.cs Updated the constructor with additional parameters for consistency.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/RemotePackageModel.cs Modified the constructor to use a publishedDate parameter and removed dependency set property assignment.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/RemotePackageModelTests.cs Adjusted tests to match the modified constructor signature and removed dependency set assertions.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/TestPackageModel.cs Updated the dependencySets parameter type to IReadOnlyCollection for consistency.
Comments suppressed due to low confidence (3)

src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/RemotePackageModel.cs:37

  • The removal of the DependencySets property assignment may lead to loss of dependency set data in RemotePackageModel. If this change is intentional, please update the documentation and verify that all consumers are aware of the removal.
-            DependencySets = dependencySets;

test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/RemotePackageModelTests.cs:54

  • The removal of the dependencySets assertion in the test indicates that RemotePackageModel no longer exposes dependency set data. Confirm that this behavior is intended and that any related documentation or consumer code is updated accordingly.
-            Assert.Equal(dependencySets, package.DependencySets);

test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/RemotePackageModelTests.cs:45

  • [nitpick] Consider renaming the 'dateTimeOffset' variable in this test to 'publishedDate' to match the updated parameter naming in the RemotePackageModel constructor.
var package = new TestRemotePackageModel(identity, vulnerableCapability.Object, null, null, null, null, null, null, isListed, dateTimeOffset, packageDetailsUrl, downloadCount);

@jgonz120 jgonz120 changed the title Add Transitive and Installed package models [Data Model Improvements] Add Transitive and Installed package models Mar 13, 2025

namespace NuGet.PackageManagement.UI.Models
{
public class ReferencedPackageModel : LocalPackageModel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We talked about this offline. ReferencedPackageModel is not a type of LocalPackageModel as this inheritance hierarchy suggests. We will consider having both these package types share a base class or local capability of sorts. We can handle that in a future PR.

@jgonz120
jgonz120 merged commit 2ea6e0e into dev-feature-PackageDomainModel Mar 14, 2025
@jgonz120
jgonz120 deleted the dev-jgonz120-newModels branch March 14, 2025 00:52
jebriede pushed a commit that referenced this pull request Mar 24, 2025
…#6313)

* Updated model

* Updated to include readme

* Add class modifiers

* rename

* remove newline
jebriede pushed a commit that referenced this pull request Apr 16, 2025
…#6313)

* Updated model

* Updated to include readme

* Add class modifiers

* rename

* remove newline
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.

3 participants