This appendix is a reference organized so you can quickly look up the entire Functorium ArchitectureRules API at a glance. Use it to quickly check method usage or parameters during tutorial learning.
Inherits TypeValidator<Class, ClassValidator> and verifies class-level architecture rules.
Method Description RequirePublic()Must be a public class RequireInternal()Must be an internal class
Method Description RequireSealed()Must be a sealed class RequireNotSealed()Must not be sealed RequireStatic()Must be a static class RequireNotStatic()Must not be static RequireAbstract()Must be an abstract class RequireNotAbstract()Must not be abstract
Method Description RequireRecord()Must be a record type RequireNotRecord()Must not be a record
Method Description RequireAttribute(string attributeName)Must have the specified attribute
Method Description RequireInherits(Type baseType)Must inherit a specific base class RequireImplements(Type interfaceType)Must implement a specific interface RequireImplementsGenericInterface(string name)Must implement a generic interface
Method Description RequirePrivateAnyParameterlessConstructor()Must have a private parameterless constructor RequireAllPrivateConstructors()All constructors must be private
Method Description RequireProperty(string propertyName)A specific property must exist RequireNoPublicSetters()Must have no public setters RequireNoInstanceFields()Must have no instance fields RequireOnlyPrimitiveProperties(params string[])Only primitive type properties allowed
Method Description RequireNestedClass(string name, Action<ClassValidator>?)Nested class must exist (optional validation) RequireNestedClassIfExists(string name, Action<ClassValidator>?)Validates only if present
Method Description RequireImmutable()Applies ImmutabilityRule (6-dimension immutability verification)
Inherits TypeValidator<Interface, InterfaceValidator> and verifies interface-level rules.
Uses methods inherited from TypeValidator (naming, method verification, dependencies, etc.).
Performs method-level signature verification.
Method Description RequireVisibility(Visibility)Must have specified visibility RequireStatic()Must be a static method RequireNotStatic()Must not be static RequireVirtual()Must be a virtual method RequireNotVirtual()Must not be virtual RequireExtensionMethod()Must be an extension method
Method Description RequireReturnType(Type)Must have a specific return type (open generic supported) RequireReturnTypeOfDeclaringClass()Must return the declaring class type RequireReturnTypeOfDeclaringTopLevelClass()Must return the top-level class type RequireReturnTypeContaining(string)Return type name must contain the string
Method Description RequireParameterCount(int)Exact parameter count RequireParameterCountAtLeast(int)Minimum parameter count RequireFirstParameterTypeContaining(string)First parameter type contains the string RequireAnyParameterTypeContaining(string)Any parameter type contains the string
The common base class inherited by ClassValidator and InterfaceValidator.
Method Description RequireNameStartsWith(string prefix)Name must start with the prefix RequireNameEndsWith(string suffix)Name must end with the suffix RequireNameMatching(string regex)Name must match the regular expression
Method Description RequireNoDependencyOn(string typeNameContains)Must not depend on the specified type
Method Description RequireMethod(string name, Action<MethodValidator>)Verify a specific method RequireMethodIfExists(string name, Action<MethodValidator>)Verify only if present RequireAllMethods(Action<MethodValidator>)Verify all methods RequireAllMethods(Func<MethodMember, bool>, Action<MethodValidator>)Verify filtered methods
Method Description Apply(IArchRule<TType> rule)Apply a custom rule
Extension Method Description ValidateAllClasses(Architecture, Action<ClassValidator>, bool verbose)Extension on IObjectProvider<Class> ValidateAllInterfaces(Architecture, Action<InterfaceValidator>, bool verbose)Extension on IObjectProvider<Interface>
Return type: ValidationResultSummary
Method Description ThrowIfAnyFailures(string ruleName)Throws ArchitectureViolationException on violations
public interface IArchRule< in TType> where TType : IType
string Description { get ; }
IReadOnlyList<RuleViolation> Validate (TType target, Architecture architecture);
// Lambda-based custom rule
var rule = new DelegateArchRule<Class>(
(target, architecture) => {
return violations; // IReadOnlyList<RuleViolation>
// Compose multiple rules with AND
var composite = new CompositeArchRule<Class>(rule1, rule2, rule3);
// Description: "rule1 AND rule2 AND rule3"
public sealed record RuleViolation (
string TargetName, // Full name of the violating type
string RuleName, // Rule name
string Description); // Violation description
Dimension Verification Content Writability Non-static members must be immutable Constructors Must have no public constructors Properties Must have no public setters Fields Must have no public non-static fields Collections Mutable collection types prohibited (List, Dictionary, etc.) Methods Public non-static methods only from the allowed list
Allowed methods: Equals, GetHashCode, ToString, Create, Validate, operators, Getter methods
Pre-built test suites that instantly apply verified architecture rules through inheritance alone.
Provides 21 tests that verify DDD tactical patterns in the domain layer.
Property Type Description ArchitectureArchitectureAssembly architecture loaded with ArchLoader DomainNamespacestringRoot namespace where domain types reside
Property Default Description ValueObjectExcludeFromFactoryMethods[]ValueObject types to exclude from Create/Validate factory method verification DomainServiceAllowedFieldTypes[]Field types to allow in DomainService’s RequireNoInstanceFields
Category Test Verification Content Entity AggregateRoot_ShouldBe_PublicSealedClasspublic sealed, not static Entity AggregateRoot_ShouldHave_CreateAndCreateFromValidatedCreate/CreateFromValidated static factory methods Entity AggregateRoot_ShouldHave_GenerateEntityIdAttribute[GenerateEntityId] attributeEntity AggregateRoot_ShouldHave_AllPrivateConstructorsAll constructors private Entity Entity_ShouldBe_PublicSealedClasspublic sealed, not static (excluding AggregateRoot) Entity Entity_ShouldHave_CreateAndCreateFromValidatedCreate/CreateFromValidated static factory methods Entity Entity_ShouldHave_AllPrivateConstructorsAll constructors private ValueObject ValueObject_ShouldBe_PublicSealedWithPrivateConstructorspublic sealed + private constructors ValueObject ValueObject_ShouldBe_ImmutableImmutabilityRule 6-dimension immutability ValueObject ValueObject_ShouldHave_CreateFactoryMethodCreate -> Fin<T> return ValueObject ValueObject_ShouldHave_ValidateMethodValidate -> Validation<Error, T> return DomainEvent DomainEvent_ShouldBe_SealedRecordsealed record DomainEvent DomainEvent_ShouldHave_EventSuffix”Event” suffix Specification Specification_ShouldBe_PublicSealedpublic sealed Specification Specification_ShouldInherit_SpecificationBaseSpecification<T> inheritanceSpecification Specification_ShouldResideIn_DomainLayerLocated within domain namespace DomainService DomainService_ShouldBe_PublicSealedpublic sealed DomainService DomainService_ShouldBe_StatelessNo instance fields (excluding allowed types) DomainService DomainService_ShouldNotDependOn_IObservablePortIObservablePort dependency prohibited DomainService DomainService_PublicMethods_ShouldReturn_FinPublic instance methods return Fin<T> DomainService DomainService_ShouldNotBe_RecordNot a record type
Provides 4 tests that verify Command/Query structure in the application layer.
Property Type Description ArchitectureArchitectureAssembly architecture loaded with ArchLoader ApplicationNamespacestringRoot namespace where application types reside
Test Verification Content Command_ShouldHave_ValidatorNestedClassIf a Command has a Validator, it must be sealed + implement AbstractValidator Command_ShouldHave_UsecaseNestedClassCommand must have a Usecase, sealed + implement ICommandUsecase Query_ShouldHave_ValidatorNestedClassIf a Query has a Validator, it must be sealed + implement AbstractValidator Query_ShouldHave_UsecaseNestedClassQuery must have a Usecase, sealed + implement IQueryUsecase
The next appendix provides a cheat sheet for quick reference of ArchUnitNET core APIs.
-> Appendix B: ArchUnitNET Cheat Sheet