roslyn: Can we analyze function in try block to suggest exception type for catch?

I think intellisense from roslyn should suggest possible exception that could be thrown from try block when we want exception type in catch(

At least for direct instance function and static function. Is it possible?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (17 by maintainers)

Most upvoted comments

With that said, someone could work on building this outside of the roslyn project itself using the APIs that we provide

Sounds like the following (big) workitems would need to be done in order for this to work well

  1. Flow analysis API that could actually answer questions like this
  2. A Roslyn API that can read metadata and return information to the flow analysis API
  3. Some sort of Workspace level analysis engine that allows us to analyze the entire solution

These three pieces may exist someday, but today I think this would take a lot of work upfront and not be very accurate on the other end.

This would be a very inaccurate analysis. What would we do if you called into an interface method? What about if you call into anything from metadata? We would end up filtering out viable exceptions that you may want to complete to.

We tend to under-filter rather than over-filter. over-filtering is very risky and can lead to a bad experience.