Skip to content

Update models to use capabilities - #6334

Merged
jgonz120 merged 5 commits into
dev-feature-PackageDomainModelfrom
dev-jgonz120-UpdateModelsToUseCapabilities
Mar 20, 2025
Merged

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

Conversation

@jgonz120

Copy link
Copy Markdown
Contributor

Bug

Fixes:

Description

Update models to use capabilities

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 20, 2025 20:30
@jgonz120
jgonz120 changed the base branch from dev to dev-feature-PackageDomainModel March 20, 2025 20:31
@jgonz120
jgonz120 requested a review from Copilot March 20, 2025 20:31

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 PR updates several NuGet package model classes to introduce deprecation capabilities alongside existing vulnerability handling. Key changes include:

  • Adding a public IDeprecationCapable interface to the UI models.
  • Updating constructors and method implementations in PackageModel and its derivatives (ReferencedPackageModel, RemotePackageModel, LocalPackageModel, TransitivelyReferencedPackageModel) to accept and use deprecation capability.
  • Modifying and expanding tests across the project to cover the new deprecation functionality.

Reviewed Changes

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

Show a summary per file
File Description
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/IDeprecationCapable.cs Changed interface visibility to public so it can be used by models.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/ReferencedPackageModelTests.cs Added mocks/tests for deprecation capability and verified deprecation-related properties and behaviors.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/PackageModel.cs Introduced IVulnerableCapable dependency and updated PopulateDataAsync to delegate calls accordingly.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/PackageModelTests.cs Updated tests to use shared mocks for embedded resources and vulnerability/deprecation capabilities.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/RemotePackageModelTests.cs Adjusted RemotePackageModel tests to include deprecation capability verifications.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/ReferencedPackageModel.cs Replaced IVulnerableCapable with IDeprecationCapable for deprecation-related functionality and updated PopulateDataAsync accordingly.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/RemotePackageModel.cs Updated the capability handling to use deprecation capability instead of vulnerability and modified the PopulateDataAsync method.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/LocalPackageModel.cs Adjusted constructor to pass the vulnerability capability to the base class without additional deprecation handling.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/TransitivelyReferencedPackageModelTests.cs Updated tests to pass the deprecation capability alongside the vulnerable capability.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/TransitivelyReferencedPackageModel.cs Updated constructor signature to add a deprecation capability parameter.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/TestPackageModel.cs Updated constructor call to include the vulnerable capability as required by the new base class constructor.
Comments suppressed due to low confidence (1)

src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/ReferencedPackageModel.cs:24

  • [nitpick] Consider renaming the 'deprecationCapability' parameter (or adding clarifying comments) to better distinguish its role from the vulnerability capability expected by the base class, to improve readability.
IDeprecationCapable deprecationCapability,

@jebriede jebriede 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.

Great job! The Recommended Package should have been added now. Can we handle that one too in this PR?

@jgonz120
jgonz120 requested a review from Copilot March 20, 2025 21:08

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 updates the models to integrate a new deprecation capability alongside the existing vulnerability support. The changes include refactoring models and tests to inject and use deprecation capabilities, modifying access modifiers to internal where appropriate, and updating tests to cover the new behavior.

Reviewed Changes

Copilot reviewed 18 out of 18 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/ReferencedPackageModelTests.cs Updated tests to include deprecation capability and validate its behavior.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/RemotePackageModelTests.cs Modified tests to use deprecation capability and updated constructor parameters.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/IEmbeddedResources.cs Changed interface accessibility from public to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/PackageModel.cs Changed class accessibility to internal and ensured dependency injection consistency.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/LocalPackageModelTests.cs Updated tests to use shared mock capabilities with revised constructor parameters.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/PackageModelTests.cs Updated tests to consistently inject the embedded resources mock.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/RemotePackageModel.cs Refactored to inject an IDeprecationCapable alongside IVulnerableCapable, and updated error-checking.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/IDeprecationCapable.cs Changed interface accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/VulnerableCapabilityBase.cs Changed class accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/IKnownOwnersCapable.cs Changed interface accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/IVulnerableCapable.cs Changed interface accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/ReferencedPackageModel.cs Integrated deprecation capability and modified constructor parameters.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/LocalPackageModel.cs Updated dependency injection and ensured proper null-checking.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/VulnerableDatabaseCapability.cs Changed class accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/KnownOwnersCapability.cs Changed class accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/EmbeddedResourcesCapability.cs Changed class accessibility to internal.
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/TransitivelyReferencedPackageModel.cs Updated to accept a deprecation capability and modified constructor chaining.
test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/TransitivelyReferencedPackageModelTests.cs Adjusted tests for TransitivelyReferencedPackageModel to inject the additional deprecation capability.
Comments suppressed due to low confidence (2)

src/NuGet.Clients/NuGet.PackageManagement.UI/Models/Package/LocalPackageModel.cs:19

  • [nitpick] Consider marking '_vulnerableCapability' as readonly if it is not meant to change after initialization for improved immutability and consistency with other injected dependencies.
private IVulnerableCapable _vulnerableCapability;

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

  • [nitpick] Consider renaming '_vulnerableCapable' to '_vulnerableCapability' for consistency with naming conventions used in other models.
private readonly IVulnerableCapable _vulnerableCapable;

@jgonz120
jgonz120 requested a review from jebriede March 20, 2025 22:00

@jebriede jebriede 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.

Great! Approved w/ suggestion.

@jgonz120
jgonz120 merged commit c4e12c4 into dev-feature-PackageDomainModel Mar 20, 2025
@jgonz120
jgonz120 deleted the dev-jgonz120-UpdateModelsToUseCapabilities branch March 20, 2025 23:21
jebriede pushed a commit that referenced this pull request Mar 24, 2025
* Added capabilities to different models

* moved vulnerabiity off of base package

* update access modifiers to internal

* rename

* Update test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/LocalPackageModelTests.cs
jebriede pushed a commit that referenced this pull request Apr 16, 2025
* Added capabilities to different models

* moved vulnerabiity off of base package

* update access modifiers to internal

* rename

* Update test/NuGet.Clients.Tests/NuGet.PackageManagement.UI.Test/Models/Package/LocalPackageModelTests.cs
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