dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19k stars 4.03k forks source link

Clean up GetConvertedTypeWithAnnotatedNullability and GetTypeWithAnnotatedNullability #40961

Open jasonmalinowski opened 4 years ago

jasonmalinowski commented 4 years ago

These two extension methods predate the compiler's nullable types API where the top level nullability is baked into the ITypeSymbol. These were used to do the IDE wrapping when you had a TypeInfo in hand. When we moved to the newer compiler API we removed the wrapping but these methods stayed around as a few odd uses still existed. We assumed that for the most part calling GetTypeInfo on an expression desires the flow state, and that seemed to generally be the case, but the extension methods were trying to do something different.

We need to investigate the remaining uses, figure out what the code is actually trying to do, and then either leave the method (explaining why it's actually the right thing) or just remove them.

jasonmalinowski commented 4 years ago

FYI @jcouv after seeing your PR I filed to track potentially cleaning up those extension methods you saw. At this point we think those are needed only for really rare things (where you're binding an expression and don't want the flow state which is unusual), or it's just doing the wrong thing and we should delete them entirely.