You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Architecture validation issues due to permanent ArchitectureCache #269
The internal class ArchBuilder utilizes the ArchitectureCache.Instance which is a singleton. So even if you create a new ArchLoader instance, it will always reuse the ArchitectureCache.Instance. This can be a benefit for performance, but it's an issue when we want to analyze several folders which can contain the same assemblies (by name) but they have different references.
Assume the following Folder Structure:
MyAppVariant1\
MyRootAssembly.dll
references: ReferencedAssembly.dll
MyAppVariant2\
MyRootAssembly.dll
references: OtherReferencedAssembly.dll
Once you analyze "MyAppVariant1", the cache will remember that MyRootAssembly only references ReferencedAssembly. When you then build the architecture for "MyAppVariant2", the reference change is not being detected.
Please understand that instances of ArchLoader are not necessarily used within short living applications. They could be created from a long running service application for example, which can re-run the same checks in a iterative way. The assembiles being imported might have the same name, but they're not the same.
Potential solutions I can think of
Allow to optional disable the ArchitectureCache using a flag
Add the ability to manually clear the ArchitectureCache (e. g. ArchitectureCache.Instance.Clear()) as a minimum
Open the structure of ArchLoader and ArchBuilder to be public and overridable, with virtual methods, so that one could easily build a CustomCachingArchBuilder.cs class within the own project and, for example provide a custom caching manager
Activity
Issue: TNG#269
Issue: TNG#269
thojaw commentedon Jun 10, 2024
Implementation in #270 only aims to "Add the ability to manually clear the
ArchitectureCache"Merge pull request #270 from thojaw/Issue269ArchitectureCache
mak638 commentedon Jun 15, 2024
Hi @thojaw. Thank you for your contribution. It will be added in the next version of ArchUnitNET.