Repository navigation
Ensure GenAPI can resolve implementation-only assemblies when regenerating ref source - #130704
Merged
tannergooding merged 2 commits intoJul 16, 2026
Conversation
…ating ref source Core types such as enums, the 'init' accessor marker, the System.Enum constraint and System.Decimal are defined in System.Private.CoreLib and the shared framework and merely type-forwarded by the reference facades. Those implementation assemblies are never part of a reference pack, so GenAPI couldn't resolve them and silently degraded its output (raw enum integers, 'init' accessors turned into 'set', dropped constraints, 'decimal' rendered as 'System.Decimal'). Seed GenAPILibPath with the CoreLib and shared framework directories so the regenerated source is faithful. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the build engineering targets used by libraries to improve GenAPI’s assembly resolution when running GenerateReferenceAssemblySource, by ensuring GenAPI can locate runtime implementation-only assemblies (e.g., CoreLib / shared framework) in addition to the standard ReferencePath-derived inputs.
Changes:
- Adds a new MSBuild target (
AddImplementationAssembliesToGenAPIResolutionPath) that runs afterResolveAssemblyReferencesto populateGenAPILibPathwithReferencePathdirectories plus runtime implementation assembly directories. - Limits the behavior to non-Mono builds and to cases where
GenAPILibPathhasn’t already been explicitly set.
Show a summary per file
| File | Description |
|---|---|
| eng/resolveContract.targets | Adds a new target to seed GenAPILibPath with additional implementation-assembly search paths for GenAPI when regenerating reference source. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot App <[email protected]>
jeffhandley
approved these changes
Jul 16, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When regenerating reference source via
GenerateReferenceAssemblySource, GenAPI was unable to resolve the runtime implementation assemblies (System.Private.CoreLiband the shared framework, e.g.System.Private.Uri). These are implementation-only and never part of a reference pack, so they aren't on the assembly resolution path GenAPI derives fromReferencePath. Many core types -- enums (e.g.System.AttributeTargets), theinitaccessor marker (IsExternalInit), theSystem.Enumgeneric constraint, andSystem.Decimal-- are defined there and merely type-forwarded by the reference facades.Without those assemblies GenAPI silently degrades its output:
EditorBrowsableAttribute(1),AttributeUsageAttribute(32),DynamicallyAccessedMembersAttribute(1)initaccessors turned intosetwhere T : System.Enumconstraint dropped towhere T : structdecimalrendered asSystem.DecimalThis is the source of most of the manual fixups the reference sources have accumulated, and it makes
GenerateReferenceAssemblySourceproduce output that then has to be hand-corrected -- defeating the point of the tool.This seeds
GenAPILibPath(GenAPI's own resolution path, distinct from the compilation reference set) with theReferencePathdirectories plus the CoreLib and shared framework directories, so the regenerated source is faithful. The target firesAfterTargets="ResolveAssemblyReferences"soReferencePathis populated and it stays deterministic under parallel (/m) builds; it never runs on the cross-targeting outer build and doesn't touch the compile reference set.Verified against
System.Text.JsonandMicrosoft.Extensions.Hosting.Abstractions: enum-as-int,init->set,DynamicallyAccessedMembers-as-int and all "Unable to resolve assembly" warnings drop to0.Note
This PR description was drafted with the assistance of GitHub Copilot.