PostSharp
PostSharp is the proven MSIL-based aspect-oriented framework that PostSharp Technologies has built and supported since 2004. Metalama is the same team’s open-source patterns & architecture toolkit for C#: the same idea of factoring out cross-cutting concerns, built on Roslyn instead of MSIL rewriting. Both products are actively maintained, supported, and updated for each new .NET release; the difference is how they transform your code and what that buys you.
MSIL rewriting versus Roslyn
PostSharp works by rewriting the compiled MSIL: it runs after the C# compiler and modifies the binary assembly. The transformation happens below the source level: aspects are applied at build time, you debug your original source, and inspecting the woven code takes a decompiler.
Metalama works at the source level, as a Roslyn source generator. The result is ordinary C# that the compiler, debugger, and IDE all understand, which is what makes its design-time experience possible:
- You can read and step into the generated code, because it is C#, not IL.
- You get real-time feedback in the IDE (CodeLens, a source ↔ transformed diff, and diagnostics as you type), rather than waiting for a post-build weaving step.
- Hand-written code can reference generated declarations, because they exist as Roslyn symbols during compilation.
- The core is open source (MIT), where PostSharp is commercial.
Which one to choose
- For new projects on the current .NET stack, start with Metalama. It is in active development and gives you the source-level, design-time, open-core experience above.
- Existing PostSharp codebases need no migration. PostSharp is actively maintained and updated for each new version of .NET, C#, and Visual Studio. A few of its capabilities are not yet in Metalama, and Metalama is a redesign on Roslyn rather than a drop-in binary-compatible port.
Either way, you are working with the same team, the same support channels, and the same long-term commitment to .NET developer tools.