This workshop is the day-long hands-on version of the "Adding a New Language Feature to C# in 60 Minutes" talk.
Attendees will start off by forking the Roslyn compiler project on GitHub, clone the repository locally, build the compiler, and then use Visual Studio to implement a new language feature right in the compiler source code.
During this journey, you'll learn about the different phases of the compiler, including lexing and parsing to produce a syntax tree, binding to produce a bound tree, reporting diagnostics to the user, lowering code to a simpler form in order to finally emit executable code.
To accomplish all of these tasks, we'll take an iterative approach by compiling the compiler project in Visual Studio, run it under the debugger, add new functionality for each consecutive phase of compilation, rinse and repeat.
At the end of the workshop, you'll have a custom build of the C# compiler supporting a new simple language feature. More importantly, you'll have gained some familiarity with the Roslyn source code, you'll be able to follow the compiler development on GitHub by perusing pull requests, and maybe you'll even want to impress your friends and colleagues by contributing a pull request to Roslyn.
Prereqs:
- Installation of Visual Studio 2022 with .NET workload enabled.
- Visual Studio 2022 IDE - Programming Tool for Software Developers (microsoft.com)
- Installation of Git.
- Git - Downloads (git-scm.com)
- GitHub account.
- GitHub
- Fork Roslyn repo.
- Fork dotnet/roslyn (github.com)
- Git clone and build forked repo.
- mkdir %USERPROFILE%\source\repos
- cd %USERPROFILE%\source\repos
- git clone https://github.com/xyz/roslyn.git (replace <xyz> with your GitHub user name)
- cd roslyn
- restore.cmd
- build.cmd
- Install .NET 7 RC1 SDK
- Download .NET 7.0 (Linux, macOS, and Windows) (microsoft.com)
- Install ILSpy
- ILSpy - Microsoft Store Apps