A commercial Metalama extension that allows to verify the code against architecture rules.
$ dotnet add package Metalama.Extensions.ArchitectureThe 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.
#pragma warning disable.Metalama.Extensions.Validation, Metalama.Framework and Roslyn.This package is a commercial extension of the open-source Metalama.Framework and requires a Metalama Professional license.
There are two ways to use this package:
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]By using fabrics, using the extension methods in the ArchitectureExtensions types
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 );
}
}
Metalama.Extensions.Architecture is built.