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
19.04k stars 4.03k forks source link

Detection of IDE0059 with C# not working within try/catch statements #65220

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[severity:Other] Detection of IDE0059 Remove unnecessary value assignment is not working when the statement is within a try/catch block. I have an .editorconfig file with the following dotnet_diagnostic.IDE0059.severity = error, and when the offending code is in a regular method it works fine, but when the offending statement is moved into a try/catch it no longer detects the issue. This detection also doesn't seem to work with top-level statements.


Original Comments

Feedback Bot on 10/30/2022, 07:51 PM:

(private comment, text removed)


Original Solutions

(no solutions)

jcouv commented 1 year ago

Chatted with Peter and he showed me the repro. [Corrected below] Here's the repro (expecting IDE0059 but none reported): image