Skip to content

Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes#19315

Open
edgarfgp wants to merge 8 commits intodotnet:mainfrom
edgarfgp:fix-17107-allowmultiple-inherited-csharp
Open

Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes#19315
edgarfgp wants to merge 8 commits intodotnet:mainfrom
edgarfgp:fix-17107-allowmultiple-inherited-csharp

Conversation

@edgarfgp
Copy link
Copy Markdown
Contributor

@edgarfgp edgarfgp commented Feb 17, 2026

Description

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 parameterizes TryFindAttributeUsageAttribute with 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

  • Test cases added
  • Release notes entry updated

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 17, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@edgarfgp edgarfgp marked this pull request as ready for review February 17, 2026 19:01
@edgarfgp edgarfgp requested a review from a team as a code owner February 17, 2026 19:01
@edgarfgp
Copy link
Copy Markdown
Contributor Author

This is ready!

@edgarfgp edgarfgp closed this Feb 19, 2026
@edgarfgp edgarfgp reopened this Feb 19, 2026
@edgarfgp edgarfgp force-pushed the fix-17107-allowmultiple-inherited-csharp branch from cd42e58 to c08bf2d Compare March 13, 2026 22:06
Copy link
Copy Markdown
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good now, thanks for the fix!

edgarfgp added 4 commits April 1, 2026 09:56
…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 parameterizes TryFindAttributeUsageAttribute with 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.
# Conflicts:
#	docs/release-notes/.FSharp.Compiler.Service/10.0.300.md
…eAttribute

Move hierarchy walking logic to PostInferenceChecks.fs where ImportMap
is directly available via GetSuperTypeOfType. TryFindAttributeUsageAttribute
now performs a single-tcref lookup; the recursive walk up the inheritance
chain is handled at the call site in CheckAttribs.
@edgarfgp edgarfgp force-pushed the fix-17107-allowmultiple-inherited-csharp branch from a4bb978 to 7834a63 Compare April 1, 2026 15:05
@edgarfgp
Copy link
Copy Markdown
Contributor Author

edgarfgp commented Apr 1, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 19315 in repo dotnet/fsharp

@edgarfgp edgarfgp closed this Apr 1, 2026
@edgarfgp edgarfgp reopened this Apr 1, 2026
@edgarfgp
Copy link
Copy Markdown
Contributor Author

edgarfgp commented Apr 9, 2026

@T-Gro this is ready!!

@edgarfgp edgarfgp closed this Apr 10, 2026
@edgarfgp edgarfgp reopened this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

AttributeUsage.AllowMultiple is not inherited for attributes defined (subclassed) in C#

2 participants