Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of using Roslyn - compiler as a service

Tags:

What is CaaS (Compiler As A Service) in regards to the Roslyn project?

How does using the Roslyn feature improve the performance of a C# application over the current C# 4.0 compiler?

What are the known limitations/issues in the Roslyn-CTP?

like image 387
VSS Avatar asked Jan 19 '12 06:01

VSS


People also ask

What is Roslyn compiler used for?

NET Compiler Platform, better known as Roslyn. Roslyn is a collection of open-source compilers, code analysis and refactoring tools which work with C# and Visual Basic source codes. This set of compilers and tools can be used to create full-fledged compilers, including, first and foremost, source code analysis tools.

What is Roslyn compiler .NET core?

Roslyn, the . NET Compiler Platform, empowers the C# compiler on . NET Core and allows developers to leverage the rich code analysis APIs to perform code generation, analysis and compilation.

What is Roslyn Visual Studio?

NET Compiler Platform ("Roslyn") is opening up the C# and Visual Basic compilers and allowing tools and developers to share in the rich information compilers have about programs. Code analysis tools improve code quality, and code generators aid in application construction.

What is Roslyn MSBuild?

Roslyn is a compilation engine. MsBuild is is mostly a set of specifications of how a project is set up - i.e. basically a definition schema for . csproj, . sln files and so on.


2 Answers

What exactly does Compiler as a Service (CaaS) mean in relation to Roslyn? You can watch a video where Anders Hejlsberg explains that (talk about Roslyn starts at 35 minutes in). Basically, the old C# compiler is a "black box": source code comes in, compiled assemblies come out. Roslyn gives you access inside that box. That means you can get syntactic and semantic information about some code, modify it and give it back to the compiler to process it further. You can use that to do code analysis, refactoring, code generation and more.

There is a long list of features that are not implemented in the current CTP on the Roslyn forum.

Regarding performance, I don't think that's among the goals of Roslyn. Besides, the JIT compiler is more important for performance optimizations than the C#/VB compiler. And Roslyn replaces the C#/VB compiler, not th JIT compiler.

like image 149
svick Avatar answered Oct 16 '22 17:10

svick


Compiler as a service (CaaS) with respect to Roslyn just means the compilation process is broken down into pieces with a public API that lets you examine the syntactic and semantic models built by the compiler during compilation. The Roslyn C# and VB compilers completely replace the existing compilers, so you can continue to use them in the same way you use the compilers today (as separate executables that converts text files into .net assemblies.) You can also use the compilers as a library of APIs that help you build tools that do deeper or different kinds of code analysis.

Roslyn does not give you specific performance advantage over using the existing compilers because when Roslyn releases they will be one and the same. However, it is possible to use roslyn to build specialized code refactorings that improve your source code.

like image 30
Matt Warren Avatar answered Oct 16 '22 17:10

Matt Warren