18 .NET Compiler Platform

What’s In This Chapter?

  • Compiler Pipeline Overview
  • Syntax Analysis
  • Semantics Analysis
  • Code Transformation
  • Code Refactoring

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/ professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • WPFSyntaxTree
  • SyntaxQuery
  • SyntaxWalker
  • SemanticsCompilation
  • TransformMethods
  • SyntaxRewriter
  • PropertyCodeRefactoring

Introduction

The most important change of C# 6 is that C# has a new compiler delivered by the .NET compiler platform (code named Roslyn). Originally, the C# compiler was written with C++. Now main parts of it are created with C# and .NET. The compiler platform is available open source at http://github.com/dotnet/Roslyn.

One advantage of this update is that Microsoft cleaned up a lot of legacy code that has been written within the last 20 years. With the new codebase it is a lot easier to implement new features with C#; the new code is more maintainable. That’s the reason you see so many small C# language improvements with version 6. That’s a scenario not only Microsoft is seeing; with projects maintained for many years, it becomes difficult to do updates with the source code. At some point it becomes better to start the project from scratch.

An even bigger advantage of the rewrite of the C# compiler is that now it’s possible to take advantage of the compiler pipeline, add functionality ...

Get Professional C# 6 and .NET Core 1.0 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.