Metalama.Framework
An open-source patterns & architecture toolkit for C#. Define your team's patterns once: the compiler writes the repetitive parts at build time and enforces your rules as you type.
Install
| Product | Versions |
|---|---|
| .NET Standard |
README
An open-source patterns & architecture toolkit for C#.
Metalama lets you define your team's patterns once: the compiler writes the repetitive parts at build time and enforces your rules as you type.
Why Metalama?
- Write the pattern once, apply it everywhere: Aspects generate the repetitive code at compile time; the boilerplate never lands in the repo, so it never needs review or maintenance.
- Enforce architecture as you type: Dependency rules, naming conventions, and pattern guidelines in plain C#, with real-time IDE feedback long before the pull request.
- Stay consistent in the AI era: Hand-written or AI-generated, every line is checked against your rules; a pattern change is one file edit and the whole codebase follows at the next build.
Built on Roslyn by the PostSharp team, who have been doing compiler-level meta-programming in .NET since 2004.
When to use it?
Metalama is ideal for:
- Large projects: Automate repetitive patterns across dozens of entities and hundreds of properties or methods.
- Large teams: Align developers on consistent patterns and practices.
- Long lifecycle projects: Maintain quality over years of development.
Its main use cases are:
- Design Patterns: Singleton, Memento, Factory, Builder, Decorator, Proxy, ...
- UI Patterns: INotifyPropertyChanged, Change Tracking, Memoization, Undo/Redo, Command, Dependency Properties, ...
- Object Services: Cloning, ToString, Comparison, ...
- Defensive Programming: Code Contracts (preconditions, post-conditions, invariants)
- DevOps: Logging & Tracing, Metrics, Caching, Exception Handling
License
Metalama is vendor-led open source: built and maintained by full-time engineers, funded by commercial licenses.
The core framework, which is the large majority of the codebase, is released under the MIT license. It cannot be taken away, relicensed, or paywalled.
Some optional extensions and IDE tooling are released under a proprietary license. π
Features
- Code Generation
- Code Validation
- Architecture Validation π
- Immediate Editor Feedback
- Code Fix Toolkit π
- Ready-to-Use Aspect Libraries
- Visual Studio Tooling π
- Test Frameworks
- Debugging of Transformed Code
- Roslyn Extensibility SDK
- Code Query API
Resources
- Metalama Website
- Documentation
- Annotated Examples
- Changelogs
- Release Notes
- Metalama Tools for Visual Studio Extension
Quick Start
Add the
Metalama.Frameworkpackage to your project:dotnet add package Metalama.FrameworkOptionally, install Metalama Tools for Visual Studio Extension. It's free for individuals, non-commercial uses, and companies with up to 3 users.
Explore the Metalama Marketplace for ready-made aspects or examples.
Follow the Getting Started guide to create your first aspect.
Building Metalama from Source
Please check instructions here.
Contributing
Contributions are accepted through the following channels:
- Share your aspects on the Metalama Marketplace.
- Contribute aspects to Metalama.Community.
- Improve the documentation. Learn how.
- Fix bugs or contribute code. Learn how.
For more details, see Contributing to Metalama.
Support
- Report issues on GitHub. Follow these recommendations.
- Ask questions and submit proposals in GitHub discussions.
- Enterprise support is available. Learn more about premium support. π
Related Packages
- Metalama.Extensions.DependencyInjection: allows you to inject services into your aspects using a dependency injection framework.
- Metalama.Extensions.Metrics: allows your aspects or fabrics to rely on code metrics, e.g. number of lines of code.
- Metalama.Extensions.Validation π: provides an API allowing to validate code and references, usages and dependencies.
- Metalama.Extensions.Architecture π: built on
Metalama.Extensions.Validation, implements concrete rules for architecture verification. - Metalama.Extensions.CodeFixes π: allows you to attach code fix suggestions to errors and warnings or to suggest code refactorings.
- Metalama.Patterns.*: a set of ready-made, professionally-built aspect libraries built with
Metalama.Framework, most of them open-source.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.