Skip to content

(#68) Add SupportsInstances to IPackageMetadata - #69

Draft
gep13 wants to merge 1 commit into
chocolatey:developfrom
gep13:issue68
Draft

gep13 wants to merge 1 commit into
chocolatey:developfrom
gep13:issue68

Conversation

@gep13

@gep13 gep13 commented Nov 5, 2026

Copy link
Copy Markdown
Member

Description Of Changes

  • Add bool SupportsInstances { get; } to the IPackageMetadata interface (IChocolateyPackageMetadata.cs), and remove the note that said it was deliberately left off.
  • ManifestMetadata and PackageBuilder already have the property, so they now implement the interface member.
  • Replace the casts in ChocolateyManifestMetadata.FinishContruction and ChocolateyPackageBuilder.FinishPopulate with a direct read from the interface.
  • Record NuGet.Packaging.IPackageMetadata.SupportsInstances.get -> bool in PublicAPI.Unshipped.txt for net472, netcoreapp5.0 and netstandard2.0.
  • Add ManifestMetadataCopiesSupportsInstancesFromAnyPackageMetadata to ManifestTest.cs.

Motivation and Context

supportsInstances was added in #66 (merged in #67) and shipped in 3.6.0, but only on ManifestMetadata, PackageBuilder and NuspecReader. It was left off IPackageMetadata on purpose: adding a member to a public interface breaks every external implementer, and Package Instances had to ship in a Chocolatey CLI 2.x release, which cannot take breaking changes in its dependencies.

That left the interface inconsistent. It exposes the other Chocolatey nuspec fields (Replaces, Provides, Conflicts, SoftwareDisplayName, SoftwareDisplayVersion and PackageSourceUrl), but not this one. The copy paths also had to cast to the concrete types, and any other IPackageMetadata implementer silently yielded false.

This finishes that work. It is a breaking change for any external type that implements IPackageMetadata, so it should only be released in a version that is allowed to make breaking changes. Nothing in this repository needs the interface member for correctness; it is API completeness.

Testing

  1. Build NuGet.Packaging and its tests on this branch.

  2. Run the new test and confirm it passes for both cases:

    NuGet.Packaging.Test.ManifestTest.ManifestMetadataCopiesSupportsInstancesFromAnyPackageMetadata (true and false).

  3. Negative control: in ChocolateyManifestMetadata.cs, temporarily change SupportsInstances = copy.SupportsInstances; to SupportsInstances = false;. Expected: the true case fails. Restore the line afterwards.

  4. Check the public API files: the NuGet.Packaging build should pass with no public API analyzer errors for any of the three target frameworks. Expected: if you delete the new line from one of the PublicAPI.Unshipped.txt files, the build reports the member as missing from the declared public API.

  5. Run the rest of the NuGet.Packaging tests to confirm the pack and read paths that use supportsInstances are unaffected.

Operating Systems Testing

  • Dev VM4

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?
  • All items are complete on the Definition of Done.

Related Issue

Fixes #68

SupportsInstances was added in 3.6.0 on ManifestMetadata, PackageBuilder
and NuspecReader only, and kept off the IPackageMetadata interface
because adding an interface member is a breaking change for external
implementers, which that release could not take.

Add it to the interface now, so that it carries every Chocolatey nuspec
field as Replaces, Provides, Conflicts and the others already do. Copy
the value straight from the interface in ManifestMetadata and
PackageBuilder, which removes the casts that read it from the concrete
types and silently returned false for any other implementer.

Record the new member in PublicAPI.Unshipped.txt for net472,
netcoreapp5.0 and netstandard2.0, and add a test that copies from an
IPackageMetadata that is neither of the concrete types.
@gep13
gep13 marked this pull request as draft November 5, 2026 19:36
@gep13

gep13 commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Leaving this in draft just now, since we won't be in a position to pull this in until we are ready for CLI 3.0.0, but getting it up just now while I can.

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.

Add SupportsInstances to the IPackageMetadata interface

1 participant