From cabd01a3b5b5351823294e3a2c329baedff9bb25 Mon Sep 17 00:00:00 2001 From: Tomat Date: Tue, 31 Jan 2023 09:53:28 -0800 Subject: [PATCH] Update README.md --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 832b320..be11b5f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ +> **Warning** | This is not a practical project. If you find yourself ever needing this, consider rethinking everything. + # cle-elum -Experimental Roslyn activities and other fun stuff. +> compiler hacking!!!!!1!! but for c# + +--- + +Experimental, questionable Roslyn activities. + +## Things + +### Roslyn Modding + +Modify Roslyn in-memory with [MonoMod](https://github.com/MonoMod/MonoMod) (RuntimeDetour) and a somewhat convenient little bit of API boilerplate: + +```cs +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public sealed class MyAnalyzer : DiagnosticAnalyzer { + public override ImmutableArray SupportedDiagnostics => + ImmutableArray.Empty; + + public MyAnalyzer() { + // Your entrypoint lies within this class' constructor. + BootstrapAnalyzer.EnsureInitialized(); + Patch(); + } + + public override void Initialize(AnalysisContext context) { } + + private static void Patch() { + // use monomod here + } +} +``` + +General changes that make normally-invalid stuff valid will be reflected properly in Visual Studio, but not anything that doesn't use Roslyn (such as Rider).