Conan is a lightweight fork of the .NET Compiler Platform ("Roslyn") by adding a compiler plugin infrastructure. These plugins can be deployed and installed as regular Diagnostic Analyzers.
This repository is under construction, a documentation will follow in the coming weeks
- Create a
netstandard1.3
library - Add the latest
Conan.CodeAnalysis
package (alpha5+
) - Create a new class an inherit from
CompilationRewriter
. SeeHelloWorld
plugin example[DiagnosticAnalyzer(LanguageNames.CSharp)] public class MyCompilationRewriter : CompilationRewriter { public override Compilation Rewrite(CompilationRewriterContext context) { var compilation = context.Compilation; // Transform compilation ... return compilation; } }
- If you want to create a NuGet package for this plugin, you can add a reference to the NuGet package AnalyzerPack and it will transform automatically your package into a Diagnostic Analyzer NuGet package (when doing a dotnet/msbuild Pack)
- Add the package
Conan.Net.Compilers
to your project: This will make the Conan compiler as the default CSharp/VB compiler and replace the default Roslyn compiler (This package works for both Full framework and Core framework unlike the Roslyn packages) - Add your plugin you developed either by:
- Adding directly a reference to it into your csproj. This is what is used by the HelloWorld package:
<ItemGroup> <Analyzer Include="..\Conan.Plugin.HelloWorld\bin\$(Configuration)\netstandard1.3\Conan.Plugin.HelloWorld.dll" /> </ItemGroup>
- Adding a reference to the NuGet package of your plugin (that has been through
AnalyzerPack
)
- Adding directly a reference to it into your csproj. This is what is used by the HelloWorld package:
- If you compile your project, the plugin will be automatically loaded and executed, check the logs!
Their are 2 fundamental root packages in Conan:
- Conan.Net.Compilers: This is the Conan compiler that is replacing the default Roslyn compiler, working with both .NET full framework and .NET Core projects. This compiler will be responsible to load your Conan plugins (as Diagnostic Analyzers)
- Conan.CodeAnalysis: This is the root package for developing a Conan compiler plugin that you should reference from your plugin compiler library
Roslyn | Conan | NuGet |
---|---|---|
Microsoft.Net.Compilers Microsoft.NETCore.Compilers |
Conan.Net.Compilers | |
Microsoft.CodeAnalysis | Conan.CodeAnalysis | |
• Microsoft.CodeAnalysis.Common | • Conan.CodeAnalysis.Common | |
• Microsoft.CodeAnalysis.CSharp | • Conan.CodeAnalysis.CSharp | |
• Microsoft.CodeAnalysis.CSharp.Workspaces | • Conan.CodeAnalysis.CSharp.Workspaces | |
• Microsoft.CodeAnalysis.VisualBasic | • Conan.CodeAnalysis.VisualBasic | |
• Microsoft.CodeAnalysis.VisualBasic.Workspaces | • Conan.CodeAnalysis.VisualBasic.Workspaces | |
• Microsoft.CodeAnalysis.Workspaces.Common | • Conan.CodeAnalysis.Workspaces.Common |
All the people involved behind the .NET Compiler Platform ("Roslyn"). Conan is a very little addition to the huge work already done there.
The logo is called Lion created by Jennifer Keana from the Noun Project
Same license than Roslyn: Apache-2.0
Alexandre MUTEL aka xoofx