Roslyn: The .NET Compiler Platform

Roslyn is the .NET Compiler Platform: the open-source compiler for C# and Visual Basic that exposes its own internals, syntax trees, semantic models, and diagnostic pipeline, as an API rather than a black box. That exposure is what makes source generators, analyzers, and code fix providers possible in the first place.

The articles in this collection cover Roslyn from the perspective of people building on it: incremental source generator pipelines, custom analyzer rules, MSBuild integration for multi-targeted analyzer packages, and the pitfalls that only show up once you multi-target several Roslyn API versions or share tooling across Visual Studio’s MEF composition.

Incremental Source Generators Done Right: The Equality Contract

The Equality Contract

IIncrementalGenerator exists for one reason: to run only when its inputs actually change. Most generators fail at exactly that, because somewhere in the pipeline a value is compared by reference and the cache silently misses. This is part 1 of a 4-part series on getting incrementalism right, and it starts where every broken generator starts: the equality contract, the ImmutableArray trap, and the EquatableArray that fixes it.