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.07k stars 4.04k forks source link

IOperation representation for locals defined by IDeclarationPattern #20313

Open mavasani opened 7 years ago

mavasani commented 7 years ago

C# declaration patterns declare locals which are owned by the enclosing statement nodes. We need to ensure that these locals are correctly exposed off the enclosing pattern case clause and pattern switch statement (for patterns in switch statement) and off the enclosing statement for is pattern expression.

As part of this work, we also need to add unit tests. See https://github.com/dotnet/roslyn/pull/20276/files#r122779797

AlekseyTs commented 7 years ago

The problem is not specific to pattern switch statement, it affects regular switch as well, regular locals can be declared inside a switch and they are scoped to the switch.

jinujoseph commented 7 years ago

Design Team Decision For switch statement and section we should expose the locals

mavasani commented 7 years ago

@jinujoseph Pushing this out, its a new API.