How to do it...

  1. Open Roslyn.sln in Visual Studio 2017
  2. Open source file %REPO_ROOT%\src\Compilers\CSharp\Portable\Parser\Lexer.cs and add the highlighted else if statement at line 565 in the method ScanSyntaxToken:
case '?':  if (TextWindow.PeekChar() == '?') { ... } else if (TextWindow.PeekChar() == ':') {  TextWindow.AdvanceChar();  info.Kind = SyntaxKind.QuestionColonToken; } else { ... }
  1. Open source file %REPO_ROOT%\src\Compilers\CSharp\Portable\Parser\LanguageParser.cs and add the highlighted else if statement at line 9426 in the method ParseSubExpressionCore:
if (tk == SyntaxKind.QuestionToken && precedence <= Precedence.Ternary){ ...}else if (tk == SyntaxKind.QuestionColonToken && precedence <= Precedence.Ternary){ var questionColonToken ...

Get Roslyn Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.