'typeof(T).FullName' is never null #3664
Replies: 4 comments
-
There are lots of APIs in .NET, especially in the reflection/metadata namespaces that will never return Is this one really that special in comparison? |
Beta Was this translation helpful? Give feedback.
-
Moving to csharplang as this is really a language design topic. Essentially the question comes down to whether or not we want the language to override the annotations of the runtime library in specific contexts like |
Beta Was this translation helpful? Give feedback.
-
Asked about this some time ago myself. Stephen gave a good explanation: https://github.com/dotnet/runtime/issues/31558#issuecomment-557932606 |
Beta Was this translation helpful? Give feedback.
-
This would be addressed by a proposal to make |
Beta Was this translation helpful? Give feedback.
-
Version Used: 3.7, targeting netcoreapp3.1
Steps to Reproduce:
Expected Behavior:
No warning is reported for the expression returned from
TypeName
.Actual Behavior:
Additional Information:
While the
FullName
property can returnnull
in some cases, it cannot return null for the syntax seen here. There is no way to annotate the property as having a non-null value conditioned on language-specific syntax producing theType
instance.Beta Was this translation helpful? Give feedback.
All reactions