Skip to content

[Feature Request] Add caching mechanism to improve performance on large projects #404

@mokarchi

Description

@mokarchi

Motivation

When using ArchUnitNET in large .NET solutions with many assemblies, running architecture tests in CI pipelines can become very slow.
Currently, ArchLoader().LoadAssemblies(...).Build() always scans assemblies from scratch on every test run.

In ArchUnit for Java, this problem was solved by introducing a caching layer for the imported architecture model. This significantly reduced execution time by avoiding redundant scanning when assemblies did not change.

Proposal

Introduce a caching mechanism in ArchUnitNET core:

  • In-memory cache: Reuse the already loaded Architecture model within the same test run.
  • Persistent cache: Serialize the Architecture object to disk and reload it in subsequent runs, if assemblies have not changed.

Cache invalidation

The cache should be invalidated if:

  • An assembly file has changed (e.g. hash or timestamp).
  • ArchUnitNET version changes (internal model may not be compatible).
  • [Optional] Additional cache key provided by user.

Benefits

  • Greatly improves performance in CI/CD pipelines for large solutions.
  • Aligns ArchUnitNET with the Java version, which already supports caching.
  • Reduces feedback time for developers running tests locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions