Before Visual Studio 2015, it was difficult to create custom warnings that target C# or Visual Basic. However, since we shipped and open sourced the Diagnostics API in the .NET Compiler Platform ("Roslyn"), this once difficult task has become easy! Using our APIs, all you need to do is perform a bit of analysis to identify your issue and (optionally) provide a tree transformation as a code fix. Once you provide that information, we automatically do the heavy-lifting of running your analysis on a background thread, showing squiggly underlines in the editor, populating the Visual Studio Error List, creating "light bulb" suggestions and showing rich previews.
- Visual Studio 2015
- .NET Compiler Platform SDK
- Getting Started C# Syntax Analysis
- Getting Started C# Semantic Analysis
- Getting Started C# Syntax Transformation
- Documentation - repo with documentation.
- API Source Code/Documentation - allows you to browse the Roslyn source code online and easily navigate types.
- RoslynQuoter - a tool that for a given C# program shows syntax tree API calls to construct its syntax tree
- .NET Compiler Platform SDK - provides the Syntax Visualizer which lets you inspect the syntax tree of any C# or VB code file that is open inside the Visual Studio IDE.
- C# and Visual Basic - Use Roslyn to Write a Live Code Analyzer for Your API - MSDN article that walks you through how to write a custom analyzer.
- C# - Adding a Code Fix to Your Roslyn Analyzer - MSDN article that walks you through how to write a custom code fix.
- How To Write an Analyzer and Code Fix (VB | C#)
- Roslyn Diagnostic Analyzer Tutorial - interns on the Roslyn team wrote an article about how they built a meta-analyzer to help you learn how to write an analyzer.
- The Power of Roslyn: Improving Your Productivity with Live Code Analyzers with Dustin Campbell (2016) - introduces the in-progress IOperation API and SyntaxGenerator API while writing an analyzer & code fix for newing up zero-length arrays.
- The Power of Roslyn: Improving Your Productivity with Live Code Analyzers with Kasey Uhlenhuth (2016) - introduces the in-progress IOperation API and SyntaxGenerator API while writing an analyzer & code fix for newing up zero-length arrays.
- All Things Roslyn with Dustin Campbell (2015) - walks you through the tools needed to build a custom analyzer/code fix and then implements an analyzer and a fix for using collection initializers on Immutable Collections.
- .NET Compiler Platform ("Roslyn"): Analyzers and the Rise of Code-Aware Libraries with Anthony D. Green (2015) - explains the power of custom code analyzers and walks through how to build an analyzer for identifying where you've used the keyword
var
. - Improve Your Code Quality Using Live Code Analyzers with Alex Turner (2014) - <5 min video that introduces the concept of live code analysis and analyzers.