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

Allow Attributes on Generic Type Parameters #215

Open
AdamSpeight2008 opened this issue Dec 6, 2017 · 6 comments
Open

Allow Attributes on Generic Type Parameters #215

AdamSpeight2008 opened this issue Dec 6, 2017 · 6 comments

Comments

@AdamSpeight2008
Copy link
Contributor

AdamSpeight2008 commented Dec 6, 2017

It is possible to create an attribute (in VB) that can be used on generic parameter.

<AttributeUsage(AttributeTargets.GenericParameter)>
Public Class NumericAttribute : Inherits Attribute
    Public Sub New()
        MyBase.New()
    End Sub
End Class

Yet consuming that attribute in VB isn't permitted.

Public Structure NRange(Of <Numeric>Tx, Sx)
End Structure

produces the following errors on <

Identifier expected.
'As', comma or ')' expected.

We should remedy the issue, and allow them.


Currently syntax node TypeParameterSyntax doesn't support them (in C# in does), so will need to extend the definition. Or define another that inherits from TypeParameterSyntax.
Parsing should be relatively simple as parsing attributes is already implement, so adding an additional parsing step to parsing of a generic parameters should not be to hard.

@ghost
Copy link

ghost commented Dec 6, 2017

This would be very powerful!

@AnthonyDGreen
Copy link
Contributor

Just looks like an oversight that it was never supported.

@AnthonyDGreen
Copy link
Contributor

Update: The 12/6/2017 LDM approved this idea in principle.

@AdamSpeight2008
Copy link
Contributor Author

Was there a preferred implementation?

  • Change the layout of TypeSyntax to unify against C#'s
  • Inherit from TypeSyntax

@AnthonyDGreen
Copy link
Contributor

An implementation should change TypeParameterSyntax to add the attribute list in the front as C# does. And this new capability should apply to type parameters of generic types and generic methods.

@AdamSpeight2008
Copy link
Contributor Author

@KathleenDollard and @AnthonyDGreen
Prototyped in this branch: VB_AttributesOnGenericTypeParameters

Note: Isn't protected via a Feature Flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants