VOOZH about

URL: https://www.nuget.org/packages/TngTech.ArchUnitNET.xUnitV3/

⇱ NuGet Gallery | TngTech.ArchUnitNET.xUnitV3 0.13.3




TngTech.ArchUnitNET.xUnitV3 0.13.3

dotnet add package TngTech.ArchUnitNET.xUnitV3 --version 0.13.3
 
 
NuGet\Install-Package TngTech.ArchUnitNET.xUnitV3 -Version 0.13.3
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TngTech.ArchUnitNET.xUnitV3" Version="0.13.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TngTech.ArchUnitNET.xUnitV3" Version="0.13.3" />
 
Directory.Packages.props
<PackageReference Include="TngTech.ArchUnitNET.xUnitV3" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TngTech.ArchUnitNET.xUnitV3 --version 0.13.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TngTech.ArchUnitNET.xUnitV3, 0.13.3"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TngTech.ArchUnitNET.xUnitV3@0.13.3
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TngTech.ArchUnitNET.xUnitV3&version=0.13.3
 
Install as a Cake Addin
#tool nuget:?package=TngTech.ArchUnitNET.xUnitV3&version=0.13.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

<img src="https://raw.githubusercontent.com/TNG/ArchUnitNET/refs/heads/main/Logo/ArchUnitNET-Logo.png" height="64" alt="ArchUnit">

ArchUnitNET 👁 Build Status
👁 License
👁 Nuget
👁 codecov

Visit our documentation at https://archunitnet.readthedocs.io/en/latest/.

ArchUnitNET is a free, simple library for checking the architecture of C# code. It is the C# fork of https://www.archunit.org/ for Java. ArchUnitNET can check dependencies between classes, members, interfaces, and more. This is done by analyzing C# bytecode and importing all classes into our C# code structure. The main focus of ArchUnitNET is to automatically test architecture and coding rules.

An Example

To use ArchUnitNET, install the ArchUnitNET package from NuGet:

PS> Install-Package TngTech.ArchUnitNET

If you want to use xUnit, NUnit or MSTestV2 for your unit tests, you should instead install the corresponding ArchUnit extension:

PS> Install-Package TngTech.ArchUnitNET.xUnit
PS> Install-Package TngTech.ArchUnitNET.xUnitV3
PS> Install-Package TngTech.ArchUnitNET.NUnit
PS> Install-Package TngTech.ArchUnitNET.MSTestV2
Create a Test

Then you will want to create a class to start testing. We used xUnit with the ArchUnit extension here, but it works similarly with NUnit or other Unit Test Frameworks.


using ArchUnitNET.Domain;
using ArchUnitNET.Loader;
using ArchUnitNET.Fluent;
using Xunit;

//add a using directive to ArchUnitNET.Fluent.ArchRuleDefinition to easily define ArchRules
using static ArchUnitNET.Fluent.ArchRuleDefinition;


namespace ExampleTest
{
 public class ExampleArchUnitTest
 {
 // TIP: load your architecture once at the start to maximize performance of your tests
 private static readonly Architecture Architecture = new ArchLoader().LoadAssemblies(
 System.Reflection.Assembly.Load("ExampleClassAssemblyName"),
 System.Reflection.Assembly.Load("ForbiddenClassAssemblyName")
 ).Build();
 // replace <ExampleClass> and <ForbiddenClass> with classes from the assemblies you want to test

 //declare variables you'll use throughout your tests up here
 //use As() to give them a custom description
 private readonly IObjectProvider<IType> ExampleLayer =
 Types().That().ResideInAssembly("ExampleAssembly").As("Example Layer");

 private readonly IObjectProvider<Class> ExampleClasses =
 Classes().That().ImplementInterface("IExampleInterface").As("Example Classes");

 private readonly IObjectProvider<IType> ForbiddenLayer =
 Types().That().ResideInNamespace("ForbiddenNamespace").As("Forbidden Layer");

 private readonly IObjectProvider<Interface> ForbiddenInterfaces =
 Interfaces().That().HaveFullNameContaining("forbidden").As("Forbidden Interfaces");


 //write some tests
 [Fact]
 public void TypesShouldBeInCorrectLayer()
 {
 //you can use the fluent API to write your own rules
 IArchRule exampleClassesShouldBeInExampleLayer =
 Classes().That().Are(ExampleClasses).Should().Be(ExampleLayer);
 IArchRule forbiddenInterfacesShouldBeInForbiddenLayer =
 Interfaces().That().Are(ForbiddenInterfaces).Should().Be(ForbiddenLayer);

 //check if your architecture fulfils your rules
 exampleClassesShouldBeInExampleLayer.Check(Architecture);
 forbiddenInterfacesShouldBeInForbiddenLayer.Check(Architecture);

 //you can also combine your rules
 IArchRule combinedArchRule =
 exampleClassesShouldBeInExampleLayer.And(forbiddenInterfacesShouldBeInForbiddenLayer);
 combinedArchRule.Check(Architecture);
 }

 [Fact]
 public void ExampleLayerShouldNotAccessForbiddenLayer()
 {
 //you can give your rules a custom reason, which is displayed when it fails
 //(together with the types that failed the rule)
 IArchRule exampleLayerShouldNotAccessForbiddenLayer = Types().That().Are(ExampleLayer).Should()
 .NotDependOnAny(ForbiddenLayer).Because("it's forbidden");
 exampleLayerShouldNotAccessForbiddenLayer.Check(Architecture);
 }

 [Fact]
 public void ForbiddenClassesShouldHaveCorrectName()
 {
 Classes().That().AreAssignableTo(ForbiddenInterfaces).Should().HaveNameContaining("forbidden")
 .Check(Architecture);
 }

 [Fact]
 public void ExampleClassesShouldNotCallForbiddenMethods()
 {
 Classes().That().Are(ExampleClasses).Should().NotCallAny(
 MethodMembers().That().AreDeclaredIn(ForbiddenLayer).Or().HaveNameContaining("forbidden"))
 .Check(Architecture);
 }
 }
}
Run the tests

Since ArchUnitNET is reading the architecture form the analyzed binaries, it is recommended to run ArchUnitNET-based tests in Debug configuration.

dotnet test -c Debug

For more details on known edge cases, see the documentation.

Further Info and Help

Check out test examples for the current release at ArchUnitNET Examples.

License

ArchUnitNET is published under the Apache License 2.0. For more information concerning the license, see Apache License 2.0.

Contributors ✨

Thanks to all the people who have contributed to the project.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 is compatible.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TngTech.ArchUnitNET.xUnitV3:

Package Downloads
Functorium.Testing

Functorium.Testing - Testing utilities for a functional domain framework for .NET

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on TngTech.ArchUnitNET.xUnitV3:

Repository Stars
sveinungf/spreadcheetah
SpreadCheetah is a high-performance .NET library for generating spreadsheet (Microsoft Excel XLSX) files.
ardalis/modulith
Modulith is a dotnet new template for Modular Monoliths. It streamlines the creation of new .Net solutions and the addition of modules to existing ones.
Version Downloads Last Updated
0.13.3 106,899 3/5/2026
0.13.2 38,802 1/23/2026
0.13.1 26,354 12/15/2025
0.13.0 10,366 12/5/2025
0.12.3 42,844 9/26/2025
0.12.2 450 9/24/2025
0.12.1 70,468 7/14/2025
0.12.0 4,055 7/11/2025
0.11.4 7,114 4/28/2025
0.11.3 10,431 2/28/2025