Add generic friendly Nullable<T>-like structure that also support reference types #1551
Replies: 7 comments
-
Did you search anything related to nullable reference types before posting? |
Beta Was this translation helpful? Give feedback.
-
The same problem was discussed in "nullable reference types" feature (#36 (comment)) but @gafter answers that "nullable reference types" does not solves "generic nullable types" problem. |
Beta Was this translation helpful? Give feedback.
-
Also this problem was discussed here #403 |
Beta Was this translation helpful? Give feedback.
-
But currently I don't know any "non closed" solution for the problem. |
Beta Was this translation helpful? Give feedback.
-
With nullable reference types, I hope we can get |
Beta Was this translation helpful? Give feedback.
-
@alrz, CoreCLR 2.2 + C# 8.0 is a good roadmap point for this change, hope CLR changes will not be toxic and hard. |
Beta Was this translation helpful? Give feedback.
-
@alrz They're going to add extra constraints, but they won't be CLR-enforced. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The problem:
The workaround:
Helper class that wrap anything into struct:
Usage:
This is dirty trick with multiple side-cases
Probably C# vs CoreClr should have more elegant solution for "ValueOrNull" variables in generic type/methods.
One of the possible approach is to relax restriction:
From
To
But this is very very dangerous change, only LDM can predict what will happens after that change.
Beta Was this translation helpful? Give feedback.
All reactions