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 attributes should disallow type arguments which are disallowed by 'typeof' #54778

Closed
RikkiGibson opened this issue Jul 12, 2021 · 0 comments

Comments

@RikkiGibson
Copy link
Contributor

RikkiGibson commented Jul 12, 2021

Version Used: 3661e83

Steps to Reproduce:

using System;

class Attr1 : Attribute
{
    public Attr1(Type t) { }
}

class Attr2<T> : Attribute { }

[Attr1(typeof(dynamic))]
[Attr2<dynamic>]
class C { }

Expected Behavior: Error on typeof(dynamic) as well as on Attr2<dynamic>.

Actual Behavior: Error only on typeof(dynamic).

We want to do this because when we emit attribute type arguments there's nowhere to put things like DynamicAttribute, for example. So the fact that the type argument is dynamic cannot round trip.

LDM has tentatively expressed support for the change. We should still probably create a speclet in csharplang for this feature so that all these behaviors are documented.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 12, 2021
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 13, 2021
@jaredpar jaredpar added this to the 17.0 milestone Jul 13, 2021
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