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

Generic Attribute not possible when passing on generic type #67569

Closed
R0boC0p opened this issue Mar 30, 2023 · 2 comments
Closed

Generic Attribute not possible when passing on generic type #67569

R0boC0p opened this issue Mar 30, 2023 · 2 comments
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design
Milestone

Comments

@R0boC0p
Copy link

R0boC0p commented Mar 30, 2023

Hi guys,
.net 7 provides generic Attributes, which works as expected. But if you are passing on a generic type from a wrapping class, it shows a CS8968 compiler error. I wonder if you can help me here.
Thanks a lot in advance.

Version Used:
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.3
.net core: 7.0.202

Steps to Reproduce:

  1. Create a generic class derived from Attribute.
  2. Create another generic class.
  3. Use the type of the attribute within the previously created class, using its generic parameter.
public class ReproAttribute<T> : Attribute { }

public class Repro<T>
{
    [Repro<T>]
    public string Test { get; set; }
}

Expected Behavior:

Generic attribute to work inside a generic class like it would in global scope.

Actual Behavior:

CS8968: 'T' an attribute type argument cannot use type parameters.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 30, 2023
@R0boC0p R0boC0p changed the title Generic Attribute not possible if passing on generic type Generic Attribute not possible when passing on generic type Mar 30, 2023
@ufcpp
Copy link
Contributor

ufcpp commented Mar 30, 2023

You should suggest to csharplang because this is by design so far. Also, there is a runtime limitation, so a suggestion to runtime is also needed.

Proposal issue: dotnet/csharplang#124

@jcouv
Copy link
Member

jcouv commented Apr 14, 2023

Thanks @ufcpp. This limitation is indeed by-design at the moment. Closing as such

@jcouv jcouv closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2023
@jcouv jcouv added Resolution-By Design The behavior reported in the issue matches the current design and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 14, 2023
@jcouv jcouv added this to the 17.7 milestone Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design
Projects
None yet
Development

No branches or pull requests

3 participants