Fix ITypeSymbolExtensions.IsOrDerivedFromExceptionType to handle type...
Fix ITypeSymbolExtensions.IsOrDerivedFromExceptionType to handle type parameters constrained on Exception type or its subtype Fixes https://github.com/dotnet/roslyn/issues/3254 User scenario: User writes code where they have explicit casts to a type parameter deriving from Exception type or its subtype. We will offer incorrect cast removal fixes to remove these explicit casts. Removing such casts will cause their code to not compile. Even worse, if they apply a FixAll occurrences code fix, then all such casts across their (document/project/solution) will be removed, causing tons of compile errors. Fix description: IsOrDerivedFromExceptionType was only checking for base types of the given type symbol to detect if the type is an Exception type. We also need to handle type parameters which are constrained by Exception or its subtypes. Testing: Added regression tests + existing tests.
Showing
想要评论请 注册 或 登录