Skip to content

fix: analyze string const by comparing with full name - #82

Merged
BenMorris merged 5 commits into
BenMorris:masterfrom
Lorilatschki:second-fix
May 16, 2021
Merged

BenMorris merged 5 commits into
BenMorris:masterfrom
Lorilatschki:second-fix

Conversation

@Lorilatschki

@Lorilatschki Lorilatschki commented Nov 8, 2020 •

Copy link
Copy Markdown

Here the final PR (based on #79) which uses the search tree to check for the depenency in string const fields. I was not able to use the _cachedAnswersFromSearchTree as I don't exactly know how to impl. a GetNode() for a string, which might be a type, namespace, generic or at least nothing of that. In such a case a simple string comparison might be better, but I had no idea how to integrate it into you search tree. Hope the current version fits to your idea of the search tree pattern, otherwise please let me know how to improve that.

The version <=1.2.6 has checked const string values. This is missing in the new dependency implementation and has been fixed by this commit. Test has also been added.

The version <=1.2.6 has checked const string values. This is missing in the new dependency implementation and has been fixed by this commit. A test has also been added.
@Lorilatschki

Copy link
Copy Markdown
Author

@BenMorris is there any chance to get this into a new release on nuget.org? We would like to use the performance optimized library because we do have a lot of architecture rules which might increase our execution time.

@BenMorris
BenMorris merged commit 62d191a into BenMorris:master May 16, 2021
@BenMorris

Copy link
Copy Markdown
Owner

This has been shipped as version 1.3.1: https://www.nuget.org/packages/NetArchTest.Rules/1.3.1

@NeVeSpl

NeVeSpl commented May 17, 2021 •

Copy link
Copy Markdown
Contributor

After this PR all const string literals assigned to fields are treated as a dependency, even if they contain some regular text. For HaveDependencyOnAny and HaveDependencyOnAll it does not matter because they only match to given dependencies by the user. But it affects OnlyHaveDependenciesOnAnyOrNone, OnlyHaveDependenciesOnAny, OnlyHaveDependenciesOnAll, HaveDependencyOtherThan, all const strings literals that are just regular text will be detected as false positive dependency by them...

Since having dependency in strings is very rare, I would propose to make this PR optional, as an opt-in and not as a default behaviour.

@BenMorris

BenMorris commented May 17, 2021 •

Copy link
Copy Markdown
Owner

This makes sense, but the catch here is that making this optional will involve quite a lot of code changes scattered throughout the implementation... is there an elegant way of including a switch?

NeVeSpl added a commit to NeVeSpl/NetArchTest that referenced this pull request May 17, 2021
@NeVeSpl NeVeSpl mentioned this pull request May 17, 2021
@Lorilatschki
Lorilatschki deleted the second-fix branch May 17, 2021 20:16
BenMorris added a commit that referenced this pull request May 18, 2021
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

Successfully merging this pull request may close these issues.

3 participants