An example projects that includes Roslyn analyzers with code fix providers. Enjoy this template to learn from and modify analyzers for your own needs.
We will try to cover at least two of the following bullet points:
- Quick Introduction to Compilers and Roslyn
- Developing a Semantic Code Analyzer
- Providing a Code Fix Provider for the Analyzer
The workshop would be interactive and we do live coding.
- Some knowledge of programming 😁😜
- Laptop 💻
- .NET Core installed on your machine; see all versions for more information
- Have your preferred IDE installed;
- JetBrains Rider
- VS Code with C# extension, C# Dev Kit [Optional]
- Clone the CodeJoyRide repository from GitHub if you want to implement with us step by step
- Last but not least, You 👩🏻💻👨🏻💻
A .NET Standard project with implementations of sample analyzers and code fix providers. You must build this project to see the results (warnings) in the IDE.
- MaybeSemanticAnalyzer.cs: An analyzer that reports invalid usage of the
Maybe
type. - MaybeCodeFixProvider.cs: A code fix that replaces a
throw
statement withMaybe.None
. The fix is linked to MaybeSemanticAnalyzer.cs.
A project that references the CodeJoyRide.Fx analyzers. Note the parameters of ProjectReference
in CodeJoyRide.Api.csproj, they make sure that the project is referenced as a set of analyzers.
Unit tests for the CodeJoyRide analyzers and code fix provider. The easiest way to develop language-related features is to start with unit tests.
- Use the launchSettings.json profile.
- Debug tests.
- Consider using https://sharplab.io/ and set the Result to
Szntax Tree
- On Visual Studio Code, consider installing the extension CSharp Syntax Visualizer
- Consider installing the Roslyn syntax tree viewer plugin Rossynt.
- Unfortunately, based on my experience this one is not working on Rider's latest versions.
The complete set of information is available at roslyn github repo wiki.