awesome-roslyn

Compiler platform guide

A curated collection of resources and tutorials for building and using the Roslyn compiler platform for C# and VB.NET languages.

Curated list of awesome Roslyn books, tutorials, open-source projects, analyzers, code fixes, refactorings, and source generators

GitHub

673 stars
42 watching
59 forks
last commit: over 2 years ago
Linked from 5 awesome lists

awesomeawesome-listcode-generationcsharphacktoberfestroslynroslyn-analyzerroslyn-apivbnet

Books

Roslyn Succinctlyby Alessandro Del Sole and the perfect book to start with. Explains Roslyn APIs and afterward focuses on writing analyzers and refactorings
.NET Development Using the Compiler APIBook by Jason Bock. Besides analyzers and refactorings, it also explains the scripting API and provides an interesting reflection on the future of the Compiler API
Roslyn CookbookBook by Manish Vasani, a member of the Roslyn analyzers team. After covering analyzers, refactorings, and scripting in detail, the book goes in-depth explaining how to develop new C# language features and contribute to the Roslyn source code

Tutorials

Learn Roslyn NowSeries of blog posts that explore the Roslyn compiler API. It introduces the power of Roslyn through small self-contained examples. A perfect tutorial to start with :-)
How To Write a C# Analyzer and Code Fix19,145almost 2 years agoThe mother of all Roslyn tutorials :-) A realistic step-by-step introduction to syntax and semantic analysis as well as the syntax transformation
C# and Visual Basic - Use Roslyn to Write a Live Code Analyzer for Your APIOlder but still not outdated, very detailed MSDN article on writing code analyzers
C# - Adding a Code Fix to Your Roslyn AnalyzerThe sequel to the previous MSDN article. A detailed introduction into code fixes
Introducing C# Source GeneratorsOriginal announcement of the C# 9.0 Source Generators feature. Explains what source generators are, in which scenarios they are useful, and shows how to write a simple source generator
New C# Source Generator SamplesSamples on how to write a non-trivial code generator driven by additional, non-code files like CSV files or templates
C# Source Generators2,096about 2 years agoComprehensive list of additional learning sources, samples, and experimental and productive source generators. A perfect reference once you grasp the basics

Open Source Projects

BridgeC# to JavaScript transpiler. Write modern mobile and web apps in C# and run them anywhere in JavaScript
Code Converter842almost 2 years agoC# to VB.NET and VB.NET to C# transpiler
CodeAnalysis.CSharp.PatternMatching29over 8 years agoIntuitive pattern matching for Roslyn syntax trees. Simplifies C# syntax and semantic analysis
CodeGeneration.Roslyn409almost 6 years agoRoslyn-based Code Generation during a build with design-time support
dotnet-script2,772almost 2 years agoRuns C# scripts from the .NET CLI, defines NuGet packages inline and edit/debugs them in VS Code
FlubuCore909over 2 years agoCross platform build automation tool for building projects and executing deployment scripts using C# code
MirrorSharp221almost 2 years agoOnline C#, VB.NET, and F# code editor. Features code completion, method signature help, quick fixes, and diagnostics
OmniSharpEnables a cross platform .NET development in the editor of your choice. A family of open source projects, each with one goal: To enable a great .NET experience in your editor of choice
roslyn-linq-rewrite716over 6 years agoCompiles C# code by first rewriting the syntax trees of LINQ expressions using plain procedural code. This increases performance by minimizes heap allocations and dynamic dispatch
RoslynPadCross-platform C# editor. Features code completion, method signature help, quick fixes, and diagnostics
RoslynQuoter957almost 2 years agoOnline tool that for a given C# program generates syntax tree API calls that construct syntax tree of that program
scriptcsTurns C# into a powerful scripting tool. Features C# REPL, installation of NuGet packages, and execution of scripts with a single line of code
Scripty620almost 4 years agoTool to use Roslyn-powered C# scripts for code generation. You can think of it as a scripted alternative to T4 templates
SharpenVisual Studio extension that intelligently introduces new C# language features into your existing code base
SharpLab.NET code playground. Displays intermediate steps and results of code compilation. Shows the code as compiler sees it. Allows selecting different branches and versions of Roslyn. Runs C#, VB.NET, and F# code in the browser
Testura.Code297over 2 years agoWrapper around the Roslyn API used for generation, saving, and compiling C# code. Provides methods and helpers to generate classes, methods, statements, and expressions
Uno SourceGenerator129about 3 years agoC# source code generator based on a project being built, using all of its syntactic and semantic model information

Open Source Analyzers, Code Fixes, and Refactorings

.NET AnalyzersGitHub organization for the development of Roslyn analyzers. Various repositories within the organization cover analyzers for ASP.NET Core, WPF, IDisposable, usages of System.Reflection, etc
.NET Compiler Platform ("Roslyn") Analyzers1,598almost 2 years agoDiagnostic analyzers developed by the Roslyn team. Initially developed to help flesh out the design and implementation of the static analysis APIs. The analyzers cover code quality, .NET Core, desktop .NET Framework, comments in code, and more
Code Cracker1,130over 2 years agoAnalyzer library for C# and VB.NET. Offers diagnostics in many categories like performance, coding styles, as well as some basic refactorings
CSharpGuidelinesAnalyzer145over 2 years agoReports diagnostics for C# coding guidelines ( )
ErrorProne.NET901almost 2 years agoSet of analyzers and code fixes focusing on the correctness and performance of C# programs. Inspired with Google's
Mapping Generator1,029over 4 years agoCode fix that generates arbitrary complex object-object mappings. It recognizes out of the box a large number of scenarios where mappings are used. A design-time alternative to
Nullable.Extended43over 2 years agoRoslyn tools and analyzers to improve the experience when coding with nullable reference types
Refactoring Essentials for Visual Studio637about 5 years agoRefactorings, analyzers and code fixes for C# and VB.NET
Roslyn Clr Heap Allocation Analyzer645over 4 years agoC# heap allocation analyzer that can detect explicit and many implicit allocations like boxing, closures, implicit delegate creations, etc
Roslynator3,130almost 2 years agoCollection of 190+ analyzers and 190+ refactorings for C#. Covers coding style, code readability and simplification, removing redundancies, fixing compiler errors, and many more
SonarC#802almost 2 years agoStatic code analyzer for C# language used as an extension for the SonarQube platform
StyleCop Analyzers for the .NET Compiler Platform2,674almost 2 years agoPort of StyleCop rules to Roslyn
VSDiagnostics65over 3 years agoCollection of code-quality analyzers. Covers usages of async methods, flags enums, best practices in exception handling as well as many other code-quality checks

Libraries and Frameworks for Testing Analyzers, Code Fixes, and Refactorings

Microsoft.CodeAnalysis.Testing517almost 2 years agoLibrary for testing analyzers and code fixes with NUnit, xUnit and MSTest frameworks. A part of
RoslynTestKit25over 2 years agoLightweight framework for writing unit tests for analyzers, code fixes, refactorings, and completion providers. It's unit testing framework agnostic

Source Generators

DpDtInject32over 4 years agoProof-of-concept of a dependency injection container that transfers huge piece of resolving logic to the compilation stage. Offers additional compile-time safety and fast runtime resolution
Generator.Equals138almost 2 years agoAutomatically implements equality and hashing for classes and records. Supports different comparison strategies. Offers similar functionality like IL weaving-based
JsonSrcGen146about 5 years agoReflection-free JSON serializer. Allows extremely fast JSON processing by generating reflection-free serializers at the compile time
Source Generator PlaygroundOnline application that lets you experiment with source generators. Perfect for learning and testing your ideas. Write your own source generator or learn from built-in examples and see the generated output
StrongInject852about 4 years agoCompile-time dependency injection container. Compile-time checked, reflection-free and runtime code generation free, thus fast and -friendly
StructPacker77about 4 years agoLow-level, lightweight and performance-focused serializer for C# struct types. Auto-generates C# serialization code to achieve peak runtime performance and efficiency
Svg to C# Source Generators3over 5 years agoSVG to C# compiler. Compiles SVG drawing markup to C# using as rendering engine
WrapperValueObject53almost 4 years agoCreates boilerplate free wrappers around types. Especially useful for creating

Blog Posts and Articles

How Microsoft rewrote its C# compiler in C# and made it open sourceRoslyn's journey, presented by Mads Torgersen, the lead designer of C#. Inspiring story on how Roslyn project started and why, and what it took to make it open source
Inside the .NET Compiler Platform – Performance Considerations during Syntax Analysis (#SpeakRoslyn)In-depth look at Roslyn's performance with the focus on memory consumption
Persistence, Facades and Roslyn's Red-Green TreesInspiring introduction on how Roslyn team implemented immutable, reusable trees with cheap parent references and many other goodies. Quote: "But on the Roslyn team we routinely do impossible things" :-)
ReSharper and Roslyn: Q&AExcellent explanation why ReSharper will not use Roslyn. Includes good discussion on static code analysis and some limits of Roslyn
Roslyn performance (Matt Gertz)Insight on how Roslyn team approaches the topic of evaluating and achieving performance

Talks

The Power of RoslynGreat talk by Kasey Uhlenhuth at NDC Oslo 2018 covering Roslyn essentials and APIs and tools for building code analyzers and fixes

Backlinks from these awesome lists:

More related projects: