Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes#19315
Merged
T-Gro merged 2 commits intodotnet:mainfrom Apr 14, 2026
Merged
Conversation
Contributor
❗ Release notes required
|
Contributor
Author
|
This is ready! |
T-Gro
reviewed
Mar 2, 2026
cd42e58 to
c08bf2d
Compare
T-Gro
approved these changes
Apr 1, 2026
Member
T-Gro
left a comment
There was a problem hiding this comment.
This is good now, thanks for the fix!
a4bb978 to
7834a63
Compare
Contributor
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 19315 in repo dotnet/fsharp |
Contributor
Author
|
@T-Gro this is ready!! |
Contributor
Author
|
@T-Gro Closing this PR. I do not have much time to keep fixing merge conflicts . Feel free to pick the changes if needed. Thanks |
Member
|
@edgarfgp , ok, let me try resolving them 👍 |
T-Gro
added a commit
that referenced
this pull request
Apr 14, 2026
…tes (#17107) The F# compiler was not walking the inheritance chain for IL-imported (C#) attribute types when checking AllowMultiple. The supersOfTyconRef function only used tcaug_super, which is not populated for IL types. This fix simplifies TryFindAttributeUsageAttribute to only check the current type, and adds a recursive allowsMultiple function in PostInferenceChecks that walks the inheritance chain using GetSuperTypeOfType, which correctly handles both F# and IL-imported types. Based on work by edgarfgp in PR #19315. Fixes #17107 Co-authored-by: edgarfgp <31915729+edgarfgp@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 tasks
3dbe06f to
9d42343
Compare
…tes (dotnet#17107) The F# compiler was not walking the inheritance chain for IL-imported (C#) attribute types when checking AllowMultiple. The supersOfTyconRef function only used tcaug_super, which is not populated for IL types. This fix simplifies TryFindAttributeUsageAttribute to only check the current type, and adds a recursive allowsMultiple function in PostInferenceChecks that walks the inheritance chain using GetSuperTypeOfType, which correctly handles both F# and IL-imported types. Based on work by edgarfgp in PR dotnet#19315. Fixes dotnet#17107 Co-authored-by: edgarfgp <31915729+edgarfgp@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9d42343 to
93849f3
Compare
Switch TryFindAttributeUsageAttribute to use tryBindTyconRefAttributeCore with ValueSome WellKnownILAttributes.AttributeUsageAttribute, enabling O(1) early exit on IL types that lack [AttributeUsage]. This avoids a full linear attribute scan at each level of the inheritance chain walk. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 14, 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 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
The F# compiler was not walking the inheritance chain for IL-imported (C#) attribute types when checking AllowMultiple. The
supersOfTyconReffunction only usedtcaug_super, which is not populated for IL types.This fix parameterizes
TryFindAttributeUsageAttributewith a getSuper resolver function. The caller in PostInferenceChecks now passes a resolver using GetSuperTypeOfType, which correctly handles both F# and IL-imported types via ILTypeDef.Extends.Fixes #17107
Checklist