Writing

Roslyn

The C# compiler platform: syntax rewriters, and what Roslyn emits for everyday C# code.

  1. C# behind the scenes: Local functions

    How the C# compiler turns local functions into ordinary methods, and how captured variables move into a generated display struct.

  2. C# behind the scenes: yield

    How the C# compiler turns an iterator method that uses yield return into a generated state machine class.

  3. Value type methods: call, callvirt, constrained, and hidden boxing

    How call, callvirt, and the constrained prefix work for value type methods, and when calling ToString on a struct quietly boxes it.

  4. Making a method static with Roslyn

    A Roslyn syntax rewriter that turns an instance method into a static method, with the source on GitHub.

  5. Converting LINQ query syntax to fluent syntax with Roslyn

    A Roslyn syntax rewriter that converts LINQ query comprehension syntax into the equivalent fluent method calls.