Don't simplify Nullable{T} to T? inside crefs#1996
Conversation
|
@srivatsn @heejaechang @mavasani @jmarolf @tmeschter Could you please take a look? |
There was a problem hiding this comment.
💡 This comment is misleading. The ? syntax is supported in crefs, as long as you are referencing a constructed generic type. For example, the following works fine:
<see cref="Enumerable.Sum(IEnumerable{decimal?})"/>The problem with <see cref="Nullable{T}"/> is you are actually referencing an open generic type. This is exactly the same situation as not being able to use the shorthand syntax for typeof(Nullable<>) (which also references the open generic type).
|
👍 |
|
❗ This change will cause the editor to stop trying to simplify this: <see cref="Enumerable.Sum(IEnumerable{Nullable<decimal>})"/>To this: <see cref="Enumerable.Sum(IEnumerable{decimal?})"/>We do want to support this simplification. Rather than simply use |
|
@sharwell thanks much for your comments and pointers above. In my original testing of this issue, I incorrectly assumed that the |
|
@sharwell looking at the code you linked above, it seems like the checks you have are purely syntactic. In the case of the simplifier, we have access to semantic information which would allow us to check whether or not the nullable type we are trying to simplify is a constructed generic type and offer the simplification only if it is. In other words, we can check the Do you see any issues with this approach? Also including @amcasey to see if he has an opinion. |
ac95e0a to
327d259
Compare
|
Updated commit addresses issues raised above. I ran into some issues on compiler side while trying this fix this - I've logged #2170, #2189, #2196 and #2197 for these issues. @srivatsn @tmeschter @mavasani @heejaechang could you please take a look? |
|
👍 |
|
@shyamnamboodiripad Sounds like we make the right decision going with the syntax approach. 😄 But I'm glad to see these fixed. |
|
😊 Yes. In C# it is at least possible to use a semantics based approach. But VB currently needs to check syntax because of the above bugs. I think it should always be possible to use semantics for type checking in any context in the languages and SemanticModel should ideally never disagree with compiler like in the above bugs. So in some ways, although that ended up delaying this fix, its good that we found these bugs 😊 |
|
@srivatsn @heejaechang - I need one more thumbs up to merge this PR. Could you please take a quick look? |
|
👍 |
…InDocComment
Correctly handle simplification of Nullable{T} to T? inside crefs
Fixes #29
Fixes #29