Determine nullability of list item type at runtime #104782
Unanswered
skrysmanski
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently writing a serializer and am looking at nullable reference types.
I'm using
NullabilityInfoContext
which works fine in most scenarios. However, there is one scenario where I don't know how to get the information I need.I want to determine the nullability of the items in a collection.
Assume the following classes (with nullable reference types enabled):
For the first two properties, I can get the correct/desired nullability information like this:
But when I determine nullability info for
Value3
I just get this:I even tried this:
But with this I get
Unknown
forinfo.GenericTypeArguments[0].ReadState
.Is there any way to get the information I'm looking for with
NullabilityInfoContext
(on .NET 8)?Beta Was this translation helpful? Give feedback.
All reactions