You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can we reflect over the nullability of props, params etc e.g. for string vs string? with the new C# 8 nullability output? Is there a new api for that?
Thanks for bringing this to our attention @RSuter It's a very good point.
Preview 1 is a bit early for this content, as some details are still being discussed and subject to change. I've tagged it for the .NET Core 3 release, and added a milestone to make sure we cover this in one of the later previews.
I’m writing libraries to generate JSON Schema (NJsonSchema) and OpenAPI/Swagger specs (NSwag). These libraries rely heavily on reflection. I looked into the Nullable Reference Types feature because I’d really like to use it in these generators…
This issue has been closed as part of the issue backlog grooming process outlined in #22351.
That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs team for visibility.
Activity
BillWagner commentedon Jan 14, 2019
Thanks for bringing this to our attention @RSuter It's a very good point.
Preview 1 is a bit early for this content, as some details are still being discussed and subject to change. I've tagged it for the .NET Core 3 release, and added a milestone to make sure we cover this in one of the later previews.
RicoSuter commentedon Jan 15, 2019
Is there already some discussions, description, info about that? Can you provide some links e.g. to GitHub issues?
jcouv commentedon Mar 14, 2019
It should be possible to figure this out via reflection, but not trivial.
The Nullable attribute is generated so that it stores the relevant flags, so that the flags are accessible via reflection.
Once you have the flags, you’d need to decode them (which requires traversing the tree of nested types). The decoding is similar to that of
dynamic.Here’s our doc on encoding:
https://github.com/dotnet/roslyn/blob/master/docs/features/nullable-reference-types.md#annotations
I can also dig up the section of our tests that cover this, if that helps.
I'm curious to understand the scenarios where this is useful to get this information at runtime via reflection. Can you share some more details?
BillWagner commentedon Mar 14, 2019
@jcouv From the blog post @RSuter references above:
16 remaining items
RicoSuter commentedon Sep 30, 2019
I implemented my own lib for nullability reflection: https://github.com/RicoSuter/Namotion.Reflection/blob/master/README.md#nullability-reflection-c-8
Now used in NSwag and NJS
dotnet-bot commentedon Jan 25, 2021
This issue has been closed as part of the issue backlog grooming process outlined in #22351.
That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the
@dotnet/docsteam for visibility.