Allow disabling architecture and rule evaluation cache#459
Merged
alexanderlinne merged 15 commits intomainfrom Mar 27, 2026
Merged
Allow disabling architecture and rule evaluation cache#459alexanderlinne merged 15 commits intomainfrom
alexanderlinne merged 15 commits intomainfrom
Conversation
- Convert DotNetCoreAssemblyResolver.AssemblyPath from public field to auto-property for better encapsulation - Make FilterResult static fields readonly to prevent mutation - Optimize MethodReference.BuildFullName with early return and StringBuilder instead of string concatenation via Aggregate Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Replace List<AssemblyNameReference> with HashSet<string> keyed by FullName for tracking processed assemblies. The previous approach used List.Contains with reference equality on AssemblyNameReference objects, which could fail to detect duplicates when different reference instances point to the same assembly. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
The RegexUtils.MatchNamespaces helper simply delegates to string.StartsWith. Inline the check directly in ArchBuilder to remove an unnecessary indirection. The remaining RegexUtils methods (MatchGetPropertyName, MatchSetPropertyName) are still in use. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Function pointer types are synthetic types created during dependency resolution, not types directly loaded from assemblies. Setting isStub=true ensures they are correctly classified as referenced types rather than primary architecture types. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
The class creates and caches IType, MethodMember, FieldMember, Assembly, and Namespace instances — far more than a type factory. DomainResolver better reflects its primary role: resolving Mono.Cecil references into cached domain objects. This is a pure mechanical rename with no structural or behavioral changes. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
…ls into DomainResolver Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
…ass ScanMethodBody Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
…istry Replace ILoadTask interface and LoadTaskRegistry with static Execute methods on each load task class. Move type processing orchestration from DomainResolver into ArchBuilder.ProcessTypes() with explicit phased execution. Remove RegexUtils (property matching now uses dictionary lookup in AddMethodDependencies). Remove LoadBaseTask/LoadNonBaseTasks from DomainResolver since type processing is now driven externally by ArchBuilder. Remove RegexUtils tests (only BackingFieldExamples test fixture class retained). Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Replace immediate module loading with a deferred instruction pattern. Introduce LoadInstruction hierarchy (FileLoadInstruction, DirectoryLoadInstruction) to accumulate load specifications. Create resolver and builder locally in Build() with try/finally for proper disposal. Make LoadModule and AddReferencedAssembliesRecursively static, removing instance field dependencies on _archBuilder and _assemblyResolver. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Replace separate ObjectProviderCache class with a ConcurrentDictionary field directly in Architecture. Inline the cache lookup logic into GetOrCreateObjects<T>. Delete ObjectProviderCache.cs. Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
…ching Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #459 +/- ##
==========================================
+ Coverage 77.16% 77.26% +0.09%
==========================================
Files 275 259 -16
Lines 14381 14311 -70
Branches 1336 1353 +17
==========================================
- Hits 11097 11057 -40
+ Misses 2866 2845 -21
+ Partials 418 409 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces explicit switches to disable both the global Architecture cache and the per-architecture rule evaluation cache, and refactors the loader pipeline to support those options cleanly.
Changes:
- Add
ArchLoader.WithoutRuleEvaluationCache()andArchLoader.WithoutArchitectureCache()and thread those options throughArchBuilder/ArchitectureCacheKey/Architecture. - Replace the old loader “load task” infrastructure with a phased
TypeProcessor+DomainResolverapproach. - Update docs and tests to cover the new cache behavior and ensure deterministic test architectures.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| documentation/docs/guide.md | Document the two cache layers and how to disable them via ArchLoader. |
| ArchUnitNETTests/StaticTestArchitectures.cs | Build most test architectures with caching disabled/bypassed for isolation. |
| ArchUnitNETTests/Loader/RegexUtilsTests.cs | Remove obsolete RegexUtils tests; keep BackingFieldExamples fixture type. |
| ArchUnitNETTests/Loader/ArchLoaderTests.cs | Add tests asserting default caching vs disabled caching behavior. |
| ArchUnitNETTests/Domain/Extensions/TypeExtensionTests.cs | Update fixture type reference after removing RegexUtilsTest. |
| ArchUnitNETTests/Domain/ArchitectureCacheKeyTests.cs | Add equality/hash tests for rule-evaluation-cache flag in the cache key. |
| ArchUnitNET/Loader/TypeProcessor.cs | New phased type-processing pipeline (members/deps/attrs/backrefs/namespaces). |
| ArchUnitNET/Loader/RegistryUtils.cs | Deleted (no longer needed after resolver refactor). |
| ArchUnitNET/Loader/RegexUtils.cs | Deleted (old property accessor matching approach removed). |
| ArchUnitNET/Loader/NamespaceRegistry.cs | Deleted (namespace caching moved into DomainResolver). |
| ArchUnitNET/Loader/MonoCecilMemberExtensions.cs | Optimize full-name building and consolidate method body scanning. |
| ArchUnitNET/Loader/MonoCecilAttributeExtensions.cs | Switch from TypeFactory to DomainResolver for type resolution. |
| ArchUnitNET/Loader/LoadTasks/ILoadTask.cs | Deleted (load-task system removed). |
| ArchUnitNET/Loader/LoadTasks/* | Deleted (replaced by TypeProcessor phases). |
| ArchUnitNET/Loader/LoadTaskRegistry.cs | Deleted (load-task system removed). |
| ArchUnitNET/Loader/FilterResult.cs | Make static instances readonly. |
| ArchUnitNET/Loader/DotNetCoreAssemblyResolver.cs | Change AssemblyPath to a property. |
| ArchUnitNET/Loader/DomainResolver.cs | Rename/refactor from TypeFactory; centralize caches for assemblies/namespaces/types/members. |
| ArchUnitNET/Loader/AssemblyRegistry.cs | Deleted (assembly caching moved into DomainResolver). |
| ArchUnitNET/Loader/ArchLoader.cs | Add cache toggles + defer instruction processing until Build(). |
| ArchUnitNET/Loader/ArchBuilder.cs | Support skipping caches; drive the new phased processing and new cache-key behavior. |
| ArchUnitNET/Domain/ObjectProviderCache.cs | Deleted (logic moved into Architecture with opt-out flag). |
| ArchUnitNET/Domain/ArchitectureCacheKey.cs | Include “rule evaluation cache disabled” flag in equality/hash. |
| ArchUnitNET/Domain/ArchitectureCache.cs | Add documentation/comments; no functional change beyond API usage. |
| ArchUnitNET/Domain/Architecture.cs | Implement rule evaluation cache internally and allow disabling it. |
Comments suppressed due to low confidence (1)
ArchUnitNET/Loader/DomainResolver.cs:327
GetOrCreateTypeInstanceFromTypeDefinitioncallsGetOrCreateAssembly(assemblyFullName, assemblyFullName, ...), which can createAssemblyobjects whoseNameis the full display name (with version/culture/etc.) instead of the simple assembly name. UsetypeDefinition.Module.Assembly.Name.Name(or equivalent) for theassemblyNameparameter soAssembly.Namestays consistent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
mak638
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.