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

[feature request] Insight into what exceptions can reach a certain part of the code #71308

Open vsfeedback opened 10 months ago

vsfeedback commented 10 months ago

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


Roslyn must be able to see what exceptions are thrown and what exceptions are caught/handled and which are not. It would be nice if Visual Studio could inform us about what exceptions can reach a certain part in the code and offer a non obtrusive way to add an exception handler for it. It would also be nice if these exceptions are on top of the list of exceptions when intellisense shows a suggestion when writing a catch clause.


Original Comments

Feedback Bot on 9/20/2023, 07:38 PM:

(private comment, text removed)

dodexahedron commented 6 months ago

Does the <exception cref="SomeExceptionType>Description of when that exception occurs.</exception> XmlDoc tag not do what you are wanting, at least for intellisense?

As for actual static analysis of it, yeah it would be nice if VS did that natively. But there are a few extensions that have that ability, in the meantime. I use ReSharper plus a ReSharper plugin called "Exceptional," but this VS extension does a pretty good job for free. There's also a nuget package for it, which is the more typical means of consuming analyzers.