Introduction

This chapter enables developers to add new functionality to the Roslyn C# compiler.
Let's briefly walk through the different parts of the Roslyn source tree. You can take a quick look at the topmost source folder of the Roslyn repo in the VS2017 branch: https://github.com/dotnet/roslyn/tree/Visual-Studio-2017/src


The most important source folders and corresponding components are:

  • Compilers: This implements the Roslyn C# and VB compilers and the core Microsoft Code Analysis layer, which exposes the rich-language agnostic API to perform syntactic and semantic analysis of source code. Core concepts of this layer are SyntaxTree (source file), SemanticModel (semantics of a source file), Symbol (declaration in source), and Compilation (collection of source files and options).
  • Workspaces: This implements the Workspaces layer and the corresponding APIs to do workspace-level code analysis and refactoring of projects and solutions. This layer is completely agnostic to the host operating on the workspace, such as Visual Studio or command-line tools. Core concepts of this layer are Document (syntax tree with an associated semantic model), Project (collection of documents and assembly references comprising a compilation and properties for configuring a compilation), Solution (collection of projects), and Workspace-level Options.
  • Features: Extensible IDE features built on top of the Workspaces layer, such as Code fixes, refactorings, intellisense, completion, find references, navigate to definition, edit and continue (EnC), diagnostics, and so on, lie in this layer. This layer is not coupled to Visual Studio and can be hosted within different hosts or command-line tools.
  • VisualStudio: Visual Studio-specific components built on top of the Features and Workspaces layers provide an end-to-end C# and VB IDE experience. Core concepts of this layer are the Visual Studio Workspace, Project system (component that bridges the gap between static program representation to a live IDE representation by populating the workspace and lighting up the above noted IDE features), and Language services (core language semantic services exposed to the project system).
  • ExpressionEvaluator: C# and VB expression evaluators to parse and evaluate simple expressions and compute the runtime results.
  • Samples: Samples and walkthroughs to demonstrate Roslyn API usage. You can read more details at https://github.com/dotnet/roslyn/wiki/Samples-and-Walkthroughs.
You can read a more detailed Roslyn overview at https://github.com/dotnet/roslyn/wiki/Roslyn%20Overview.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset