Uh oh!
There was an error while loading. Please reload this page.
Expose nullability info - #54985
Conversation
ghost
commented
Jun 30, 2021
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| return nullability; | ||
| } | ||
| private bool IsPublicOnly(bool isPrivate, bool isFamilyAndAssembly, bool isAssembly, Module module) |
There was a problem hiding this comment.
Should isFamilyOrAssembly (aka protected internal) also be considered? Are there tests for that?
There was a problem hiding this comment.
I will test that, as far as i know, protected members was not affected
There was a problem hiding this comment.
Added some test, could not test exactly as could not find an assembly that removed nullability attribute for the internal member's too, it only applied for private members, for now i just guess that because of protected modifier protected internal members will not be affected
Uh oh!
There was an error while loading. Please reload this page.
9bdfed9 to
930026aCompare…thod(MetadataToken)
930026a to
e190c91CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
n9
commented
Jul 9, 2021
Does this PR provide information about generic arguments of implemented interfaces? For instance: interfaceIBar<T>{}classBar:IBar<string>{}classBarN:IBar<string?>{}Context: #49900 |
buyaa-n
commented
Jul 9, 2021
No, and I don't think there is a way to distinguish If there is a member declared with a generic interface it would have the nullability of the generic type interfaceIBar<T>{}classC{publicIBar<string>bar;// {ReadState=NotNull, GenericTypeArguments = {ReadState=NotNull, ...}, ... } publicIBar<string?>nBar;// {ReadState=NotNull, GenericTypeArguments = {ReadState=Nullable, ...}, ... } } |
n9
commented
Jul 9, 2021
@buyaa-n There are different flags in the IL: |
buyaa-n
commented
Jul 9, 2021
@n9 I don't see that info in runtime, anyway, the API is not for |
steveharter
left a comment
There was a problem hiding this comment.
Per discussion, looks good pending known open items (Mono test failures, readonly properties should return "unknown")
There was a problem hiding this comment.
Even NullablePublicOnlyAttribute is set the nullability attributes not being removed for private events (not sure if this is Roslyn bug or by design), therefore not checking that info for EventInfo
3704065 to
86a287dCompare
Fixes#29723
Approved API shape:
[MaybeNullWhen]should work same as[MaybeNull].if the
NullablePublicOnlyAttributeset in the module we returnNullabilityState.Unknownfor private and/or internal membersThe nullability for generic type
Tshould be tracked by the user, a field declarationList<string?> listorList<string> listwill have type parameter nullability info but nullability for otherList<T>API calls should be tracked by the user. For example forlist.Add(T item)the nullability ofitemwill be evaluated as follows:Nullableif the declaration has?i.e.GenericType<T?>(even ifTis value type it is nullable value type)NullableforGenericType<T>when nullability context enabled and the concrete type ofTis ref type or nullable value type. (In this case the nullability of parameterTofList.Add(T item)will beNullablefor bothList<string>andList<string?>instance, we might want 4th nullability state for this scenario) CC @terrajobstNotNullforGenericType<T>when concreteTis non-nullable value typeUnknownforGenericType<T>when nullability context disabled and the concrete type ofTis ref typeTFor value type nullability:
int?is nullableintis not null no matter nullability contextAllowNull/DisallowNull/NotNull/MaybeNullatributes affect write/read state ofint?type, but notint