Using C#-like syntax for `dynamic` (and other keywords that compile to attributes)
See original GitHub issueWould you be interested in showing [System.Runtime.CompilerServices.DynamicAttribute()] object
as dynamic
, similar to the C# syntax that you’d see in intellisense when interacting with the API?
An argument against it might be that it’s better to put lower-level realities in your face in case the API is used from a language where the attribute is not specially-recognized.
Maybe an argument for it would be that it would be consistent with [ParamsAttribute]
, [ExtensionAttribute]
, etc, and the same kind of thing with C# 8 attributes: https://github.com/ApiApprover/ApiApprover/issues/54
A few other attributes have cropped up like the ones for the C# 7.0 ref
and readonly
keywords when declaring a struct:
public readonly ref struct Foo
{
}
Desugared:
[IsByRefLike]
[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
[IsReadOnly]
public struct Foo
{
}
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA+ABAzAAlgQwBMIA7AGwE88YAzHAZwBcoBXMRnAMQggFgAoAN4CAvkA=
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (11 by maintainers)
The modreq indicates how important it is as API. Modreqs are how you can express “this object requires special handling.”
If you access a volatile field, the compiler emits a
volatile.
prefix before the stfld/ldfld instructions. It should show up in a dramatic way in your public API if the volatility changes because it’s a breaking change. It’s a binary behavioral breaking change because libraries compiled against an older version of your library will not usevolatile.
when they should, and it’s a compile-time break because errors begin showing up if you take a ref to a suddenly-volatile field.(Happy to open a separate issue though.)
Unfortunately, I don’t remember anything about
dynamic
gist at all. Perhaps the point is thatdynamic
is encoded in a special way, something like NRT: https://sharplab.io/#gist:a135eb77630b190590b751c7af429743