It's an absolute massive codebase, but the compilers and analyzers in Roslyn[0] are very clearly written.
For a random example, here is the analyzer finding variable swaps of the form
tmp = a;
a = b;
b = tmp;
that can better be done using tuples:
https://github.com/dotnet/roslyn/blob/main/src/Analyzers/CSh...And here is the code fix that automatically performs the substitution: https://github.com/dotnet/roslyn/blob/main/src/Analyzers/CSh...