-
Notifications
You must be signed in to change notification settings - Fork 87
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
Prohibiting Certain Attributes on Property and Event Accessors #375
Comments
Further to Rex’s deduction we find in the second bulleted list in §22.3:
To me it looks like the wording around Given the loose language I don’t think is a Standard or compiler bug per se, I do wonder what the compiler does when importing a CLS compliant property accessor with this attribute (its a CLS requirement). I think we just punt on this one, not worth changing the Standard now, but leave a note to make things clear come v8. |
During the 2021-10-20 call, we agreed to leave the spec unchanged, even if it might be slightly broken, as the reportedly “missing” prohibition is lifted in V8. |
Closing as per comment above. |
It is lifted for ObsoleteAttribute but AFAIK not for ConditionalAttribute. I think ConditionalAttribute could be useful on the |
V8 removes a restriction on the
Obsolete
attribute by allowing it on property and event accessors. However, I don’t see that this was ever disallowed in early versions.@gafter challenges this assertion in Roslyn Issue 32472 (dotnet/roslyn#32472 (comment)), by stating
I disagree; in an attribute context, accessors are treated like methods (which are members). I deduce that from the fact that for an attribute to be allowed on an accessor, the attribute type must have
System.AttributeUsage(… System.AttributeTargets.Method …)
.While researching this, I also found that the
Conditional
attribute is also disallowed on accessors, but, again, the spec does not say so. This type has[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)]
. 22.5.3.2, “Conditional methods”, https://github.com/dotnet/csharpstandard/blob/draft-v6/standard/attributes.md#22532-conditional-methods, has no statement analogous to the one Neal cited forObsolete
.I propose that we modify the spec where property and event accessors are defined, adding prohibitions on the use of these two attributes. And then add Notes in the Attribute chapter where these attributes are spec’d, pointing back to those prohibitions.
Then for V8, we'll remove the prohibition on
Obsolete
.The text was updated successfully, but these errors were encountered: