Warning | This is not a practical project. If you find yourself ever needing this, consider rethinking everything.
compiler hacking!!!!!1!! but for c#
Experimental, questionable Roslyn activities.
Modify Roslyn in-memory with MonoMod (RuntimeDetour) and a somewhat convenient little bit of API boilerplate:
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class MyAnalyzer : DiagnosticAnalyzer {
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
ImmutableArray<DiagnosticDescriptor>.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).