Skip to main content
.NETStandard2.0

A commercial Metalama extension that allows to verify the code against architecture rules.

Published
Oct 2, 2026
16d ago
Total Downloads
99.0K
98,983

Install

dotnet add package Metalama.Extensions.Architecture --version 2026.1.29
ProductVersions
.NET Standard
netstandard2.0

README

Metalama by PostSharp

About

The Metalama.Extensions.Architecture package allows you to validate your source code against architecture rules both in real time, straight in the IDE, or at compile time.

Features

  • API: choose between custom attributes or a fluent API.
  • Warnings appear as familiar C# warnings.
  • Immediate feedback as you type in the IDE.
  • Warnings can be suppressed using the standard mechanisms such as #pragma warning disable.
  • Validate code references and dependencies.
  • Validate naming conventions.
  • Validate child/derived classes.
  • Works across projects.
  • Fully extensible using Metalama.Extensions.Validation, Metalama.Framework and Roslyn.
  • Commercially supported.

License

This package is a commercial extension of the open-source Metalama.Framework and requires a Metalama Professional license.

Principal Types

There are two ways to use this package:

  1. By adding to your code one of the following architecture custom attributes from the Metalama.Extensions.Architecture.Aspects namespace:

    • [CannotBeUsedFrom]
    • [CanOnlyBeUsedFrom]
    • [InternalsCannotBeUsedFrom]
    • [InternalsCanOnlyBeUsedFrom]
    • [Experimental]
    • [InternalImplementOnly]
    • [DerivedTypesMustRespectNamingConvention]
    • [DerivedTypesMustRespectRegexNamingConvention]
  2. By using fabrics, using the extension methods in the ArchitectureExtensions types

Example

The following snippet reports warnings whenever an internal type or member of the current namespace is used from a different namespace.

    namespace SomeNamespace;

    using Metalama.Extensions.Architecture.Fabrics;
    using Metalama.Framework.Fabrics;

    public class Fabric : NamespaceFabric
    {
        public override void AmendNamespace( INamespaceAmender amender )
        {
            amender.Verify().InternalsCanOnlyBeUsedFrom( UsageRule.OwnNamespace );
        }
    }

Documentation

Related Packages

Changes from Previous Version

No structural changes between v2026.1.28 and v2026.1.29.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.