-
https://github.com/dotnet/csharplang/blob/master/spec/attributes.md#reserved-attributes says:
and lists Shouldn't (Does the presence of |
Beta Was this translation helpful? Give feedback.
Replies: 20 comments
-
Should |
Beta Was this translation helpful? Give feedback.
-
Nope, you can use bit-wise operators without |
Beta Was this translation helpful? Give feedback.
-
@Joe4evr You are right, my bad. However,
Output:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@jnm2 I think the difference between the two groups is that attributes like From the point of view of someone who uses the C# language, but never inspects the generated IL (using Reflection or some other means), you need to know about I'm not against calling out attributes from the second group in the spec (since they have an effect on the C# language, in that you are not allowed to use those attributes directly), but they're not on the same level as the ones that are already there. Also, it might be useful to document how the C# compiler represents its constructs in IL (whether that documentation would be part of the spec or not), since that information is useful for authors of other .Net languages who want to interoperate with C#. But that's probably a different discussion. |
Beta Was this translation helpful? Give feedback.
-
@svick But any of them can appear directly in source and do affect C# syntax when they do. For example, there's no reason I can't write In other words, when listing attributes that “affect the language in some way,” |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@svick Good catch, but suffice it to say that you might be writing using 1) an older version of the compiler which doesn't recognize the attribute, 2) a different language like IL where you are still interested in how the attributes “affect the [C#] language in some way,” 3) a tool which needs an exhaustive list of such attributes to reverse-engineer the C# syntax and determine breaking changes to consuming code. Also, |
Beta Was this translation helpful? Give feedback.
-
InternalsVisibleTo doesn’t actually change the syntax, does it? |
Beta Was this translation helpful? Give feedback.
-
@yaakov-h If you remove or change it, syntax that was previously valid starts giving a visibility error message in exactly the same manner as |
Beta Was this translation helpful? Give feedback.
-
@jnm2 Those are valid reasons to document those attributes and I agree that they should be documented. Though I don't know if the spec is the right place to do it (at least for those that are just metadata representations of C# features like |
Beta Was this translation helpful? Give feedback.
-
The spec already started down the path of documenting them at https://github.com/dotnet/csharplang/blob/master/spec/attributes.md#reserved-attributes, so I'm not sure why it wouldn't be logical to just flesh out the section. If the section moves to another C#-to-IL-representation spec, so be it. Either way, this issue tracks fleshing it out. |
Beta Was this translation helpful? Give feedback.
-
New one shipping in .NET Framework 4.7.1 too: |
Beta Was this translation helpful? Give feedback.
-
@gafter, what's the likelihood that this (and similar C# documentation issues) will get organized? |
Beta Was this translation helpful? Give feedback.
-
@jnm2 I think it is getting organized right here. We don't currently have any plans to devote our own resources to the task. |
Beta Was this translation helpful? Give feedback.
-
I spotted new ones with C# 7.2: Any I missed? |
Beta Was this translation helpful? Give feedback.
-
There's also |
Beta Was this translation helpful? Give feedback.
-
Just put two and two together thanks to @svick and realized |
Beta Was this translation helpful? Give feedback.
-
@jnm2, most of the attributes in the
|
Beta Was this translation helpful? Give feedback.
-
C# documentation now has 'Language Reference > Attributes read by the compiler'! https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/general |
Beta Was this translation helpful? Give feedback.
C# documentation now has 'Language Reference > Attributes read by the compiler'!
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/general