roslyn: ITryOperation.Finally.Syntax returns BlockSyntax instead of FinallyClauseSyntax

Version Used: Microsoft.CodeAnalysis v2.8.0

Steps to Reproduce:

  1. Obtain ITryOperation for the next try statement:
try
{
}
catch (System.Exception ex)
{
}
finally
{
}

  1. Inspect its .Finally.Syntax property
  2. This returns a BlockSyntax, whose .Parent returns FinallyClauseSyntax

Expected Behavior: ITryOperation.Finally.Syntax points to a FinallyClauseSyntax, similar to how ITryOperation.Syntax points to a TryStatementSyntax instead of its block.

Actual Behavior: ITryOperation.Finally.Syntax points to a BlockSyntax.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (27 by maintainers)

Most upvoted comments

An API to get operation block(s) from an IMethodSymbol

Filed https://github.com/dotnet/roslyn/issues/28097

It would be nice if IBranchOperation, when it represents a break or continue statement, exposed a reference to the parent loop that it is breaking from or continuing at.

IBranchOperation.Target points the the destination label symbol. ILoopOperation now exposes the break and continue label symbols and ISwitchOperation exposes an exit lable, so you should be able to match the branches with parent loop/switch if desired. I filed https://github.com/dotnet/roslyn/issues/28095 to track this request.

@bkoelman CFG work merged into the dev15.8-preview3 branch yesterday, and should make it into master sometime today. I would also definitely encourage opening issue(s) for anything we’re not yet tracking. A lot of our initial design for IOperation and CFG was driven by the idea that we’d come back and add convenience APIs for things in a community-driven manner, as we had a limited time budget for V1. So your feedback is very important for shaping the future direction of the API.