-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add NullableAttribute #29039
Comments
There will likely be other attributes for annotating APIs:
We may add a couple more (we're discussing |
The API shapes looks good to me. Tagging @AlekseyTs @cston FYI The only thing I would add is the attribute targets. Here's what our compiler doc captures: namespace System.Runtime.CompilerServices
{
[AttributeUsage(
AttributeTargets.Class |
AttributeTargets.GenericParameter |
AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Property |
AttributeTargets.Parameter | AttributeTargets.ReturnValue,
AllowMultiple = false)]
public sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte b)
{
NullableFlags = new byte[] { b };
}
public NullableAttribute(byte[] b)
{
NullableFlags = b;
}
}
} |
I assume you don't care whether we expose the flags array as a field or property because you don't ever read it, right? You only care about the metadata passed to the .ctor, correct? |
@terrajobst Correct. The compiler only cares about the signature of the .ctors. |
FYI the metadata format produced by the compiler is going to change in the next week or so. We'll be adding more attributes ( |
We decided to keep doing the code spit because
|
Note: the compiler is going to ship with a very slightly different API than last discussed (see dotnet/roslyn#36604). The field is an array instead of a ReadOnlySpan and it is named |
@jcouv just to confirm - are you guys still planning to do any more changes in the nullability metadata? Your comment above about the changes is more recent than the closed issue it linked to. |
Nope, no more planned changes to metadata, only diagnostic adjustment. |
@agocke thanks for the confirmation! |
@roji, one correction to the spec: The compiler only emits |
Thanks @cston! |
Right now, the C# compiler code spits the attribute. We should add expose them to avoid having to spread them everywhere.
/cc @dotnet/ldm @dotnet/fxdc
The text was updated successfully, but these errors were encountered: