The samples below are available in the Git sources, under the Samples folder:
  • APISampleUnitTests - A collection of unit tests that show how various APIs can be used. Many of these methods are referenced in the FAQ.
  • AsyncPackage - A set of diagnostics and code fixes that help you use the await/async keywords correctly.
  • ConsoleClassifier - A simple console application that prints colored source code to the console.
  • ConvertToAutoProperty - A code refactoring to change a simple property with a trivial getter and setter into an auto property.
  • FormatSolution - A console application that formats all C# and VB source files in a solution.
  • ImplementNotifyPropertyChanged - A code refactoring to make selected properties of a class support PropertyChanged events. Select the properties to be updated in the editor, press Alt+. to show the refactoring lightbulb menu, and choose "Apply INotifyPropertyChanged pattern."
  • MakeConst - A diagnostic (user defined compiler warning), that indicates when local variables can be made const, and a quick fix to make the variable into a const. The Diagnostic walkthrough below explores this sample in detail.
You can also explore the source repository to see how the Compiler and Workspaces layers make use of the APIs:
  • The Diagnostics folder in the sources has many examples of real-world Diagnostics (mostly reimplemented FxCop rules) and Code Fixes. Just drill down to the leaf-node code files in the CSharp or VisualBasic subfolders.


Before working through the walkthroughs below, you should first familiarize yourself with the Roslyn Overview, which sets up some of the key concepts.

Getting Started

Diagnostics and Code Fixes

Last edited Aug 26, 2014 at 7:57 PM by AlexTurnMSFT, version 10