Skip to content

Architecture validation issues due to permanent ArchitectureCache #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thojaw opened this issue Jun 10, 2024 · 2 comments
Closed

Architecture validation issues due to permanent ArchitectureCache #269

thojaw opened this issue Jun 10, 2024 · 2 comments

Comments

@thojaw
Copy link

thojaw commented Jun 10, 2024

Problem overview

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
thojaw pushed a commit to thojaw/ArchUnitNET that referenced this issue Jun 10, 2024
Least effort implementation of a clearable Architecture cache
thojaw pushed a commit to thojaw/ArchUnitNET that referenced this issue Jun 10, 2024
Least effort implementation of a clearable Architecture cache

Signed-off-by: Thomas Haid <thomas.haid.ext@siemens-healthineers.com>
@thojaw
Copy link
Author

thojaw commented Jun 10, 2024

Implementation in #270 only aims to "Add the ability to manually clear the ArchitectureCache"

mak638 added a commit that referenced this issue Jun 15, 2024
Issue: #269 Least effort implementation of a clearable Architecture cache
@mak638
Copy link
Collaborator

mak638 commented Jun 15, 2024

Hi @thojaw. Thank you for your contribution. It will be added in the next version of ArchUnitNET.

@mak638 mak638 closed this as completed Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants