Repository navigation
Conversation
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
marked this pull request as draft
November 5, 2026 19:36
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description Of Changes
bool SupportsInstances { get; }to theIPackageMetadatainterface (IChocolateyPackageMetadata.cs), and remove the note that said it was deliberately left off.ManifestMetadataandPackageBuilderalready have the property, so they now implement the interface member.ChocolateyManifestMetadata.FinishContructionandChocolateyPackageBuilder.FinishPopulatewith a direct read from the interface.NuGet.Packaging.IPackageMetadata.SupportsInstances.get -> boolinPublicAPI.Unshipped.txtfornet472,netcoreapp5.0andnetstandard2.0.ManifestMetadataCopiesSupportsInstancesFromAnyPackageMetadatatoManifestTest.cs.Motivation and Context
supportsInstanceswas added in #66 (merged in #67) and shipped in 3.6.0, but only onManifestMetadata,PackageBuilderandNuspecReader. It was left offIPackageMetadataon 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,SoftwareDisplayVersionandPackageSourceUrl), but not this one. The copy paths also had to cast to the concrete types, and any otherIPackageMetadataimplementer silently yieldedfalse.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
Build
NuGet.Packagingand its tests on this branch.Run the new test and confirm it passes for both cases:
NuGet.Packaging.Test.ManifestTest.ManifestMetadataCopiesSupportsInstancesFromAnyPackageMetadata(trueandfalse).Negative control: in
ChocolateyManifestMetadata.cs, temporarily changeSupportsInstances = copy.SupportsInstances;toSupportsInstances = false;. Expected: thetruecase fails. Restore the line afterwards.Check the public API files: the
NuGet.Packagingbuild 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 thePublicAPI.Unshipped.txtfiles, the build reports the member as missing from the declared public API.Run the rest of the
NuGet.Packagingtests to confirm the pack and read paths that usesupportsInstancesare unaffected.Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
Fixes #68