- Open Roslyn.sln in Visual Studio 2017.
- Open source file <%REPO_ROOT%>\src\Compilers\CSharp\Test\Syntax\Parsing\ExpressionParsingTests.cs.
- [Parsing Test] Add the following new unit test at the end of the source file:
[Fact]public void TestSwitchExpression(){ var text = @"expr ?: [0, 1, 2] : [""Zero"", ""One"", ""Two"", ""More than two""]"; var expr = SyntaxFactory.ParseExpression(text); Assert.NotNull(expr); Assert.Equal(SyntaxKind.SwitchExpression, expr.Kind()); Assert.Equal(text, expr. ToString()); Assert.Equal(0, expr.Errors().Length); var switchExpr = (SwitchExpressionSyntax)expr; Assert.NotNull(switchExpr.Expression); Assert.Equal("expr", switchExpr.Expression.ToString()); Assert.NotNull(switchExpr.QuestionColonToken); ...