Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notes for extensions WG 2024-06-14 #8217

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Add notes for extensions WG 2024-06-14 #8217

merged 1 commit into from
Jun 24, 2024

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jun 14, 2024

Relates to test plan dotnet/roslyn#66722

@jcouv jcouv self-assigned this Jun 14, 2024
@jcouv jcouv marked this pull request as ready for review June 14, 2024 18:41
@jcouv jcouv requested a review from a team as a code owner June 14, 2024 18:41

### Attribute with typeof-like string

The main problem is how to represent type parameters, since they are currently disallowed in typeof inside attributes.
Copy link
Member

Choose a reason for hiding this comment

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

Should we allow type parameters in typeof inside attributes and use that instead of inventing another way?

Copy link
Member Author

Choose a reason for hiding this comment

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

inventing another way?

The proposal is not to invent another way, but indeed to extend the typeof format.
As for allowing type parameters in typeof in attributes in the language, this involves more complications (update reflection APIs and other tools), so I think that should be separated. But the same format should allow that if we decided to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about your question more, I think the implication is if we could extend typeof first, then the attribute constructor should take a Type instead of a string, if the runtime and other tools could recognize it. I'll capture an open question.

Copy link

Choose a reason for hiding this comment

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

BTW the prototype of using type parameters in generic attributes is here: dotnet/runtime#103213
It's not a non-trivial work for runtime as the coreclr already supports looking up type parameters for an attribute, it's just that the reflection library didn't pass the generic context to the runtime while looking up attributes before.

@jcouv jcouv merged commit 834bf1f into main Jun 24, 2024
1 check passed
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.

3 participants