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 Generic Attributes #17701

Closed
Mafii opened this issue Mar 10, 2017 · 3 comments
Closed

Allow Generic Attributes #17701

Mafii opened this issue Mar 10, 2017 · 3 comments
Labels
Area-External Area-Language Design Resolution-External The behavior lies outside the functionality covered by this repository

Comments

@Mafii
Copy link

Mafii commented Mar 10, 2017

As explained in this answer by Jon Skeet (also paraphrasing Eric Lippert) it is mentioned, that implementing Generic Attributes should be available in terms of IL - they just aren't used in C#- or actually actively blocked (the compiler doesn't allow them).

Some time has passed since then - from my view it makes sense to bring this idea up again.

The feature of generic attributes adds value because it makes the langue more generic and more flexible.

As an example, this could be:

[AttributeUsage(AttributeTargets.Field)]
private class TypeAssociationAttribute : Attribute
{
  public Type AssociatedType { get; set; }
}

But with generic attributes it could be like this:

[AttributeUsage(AttributeTargets.Field)]
class TypeAssociationAttribute<TType> : Attribute
{
}

Also, the generic argument would allow me to put constraints onto the type.

I think it's fair to say it would improve the language,
Wheter it's effort is worth it, is obviously desicion of the design team. I think it is.

@DavidArno
Copy link

Hi, language feature requests like this should now be posted to the csharplang repo.

@gafter
Copy link
Member

gafter commented Mar 11, 2017

This idea is being tracked at dotnet/csharplang#124 where you are welcome to repeat this and start more discussion.

@gafter gafter closed this as completed Mar 11, 2017
@gafter gafter added Area-External Area-Language Design Resolution-External The behavior lies outside the functionality covered by this repository labels Mar 11, 2017
@Mafii
Copy link
Author

Mafii commented Mar 14, 2017

@gafter thank you so much for your work. Sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External Area-Language Design Resolution-External The behavior lies outside the functionality covered by this repository
Projects
None yet
Development

No branches or pull requests

3 participants