-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Milestone
Description
Version used: 80ccf3f
using System;
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class A : Attribute { public A(int i) { } }
class C
{
[A(1)] [method: A(2)] [param: A(3)] [return: A(4)] [field: A(5)] event Action E;
}- Warning is reported that
[param:]is an invalid attribute location. However, the attribute is actually emitted to metadata for the param. This seems like a compiler bug. Per the current spec, the warning is correct, the emit is wrong. Ideally, the spec would be changed to allow this. Alternatively, the compiler could be fixed to not emit the attribute - that's a breaking change, though. - It feels like
[param:]and[return:]should be allowed for field-like andexternevents. Those don't have user-defined accessors so there is no other way to specify such attributes. This would need a spec change. - The spec doesn't seem to allow
[method:]onexternevents either (it's allowed only on field-like events), but that's currently allowed by the compiler. Ideally, the spec would be changed to allow this.
See also #77182 (comment).
To get started on implementing this, consider reverting this commit: d38b97c
Reactions are currently unavailable