Repository navigation
Exact match for dependency - #36
Conversation
…ion class in order to 1) implement matching rules only once and 2) hide details from others.
…f the Dependency Search
|
Hi Alexy, Thanks for this. There's a lot going on in this pull request. I'll need to take some time to really understand the problems it is trying to solve before accepting it. The false positives certainly need fixing. Good spot. However, is anybody out there really checking for 12,000 prohibited dependencies against 10,000 source types? It would be useful to know at which point this becomes genuinely problematic. |
|
Hi Ben, Thank you for your reply to this pull request! Unfortunately, yes, the example with 12,000 source types and 10,000 prohibited dependencies I've got from real life. The project I'm working on is more than 10 years old and you could imagine how much code base is. It would be great, if we could prohibit whole namespaces, since it would drastically reduce the set of dependencies to scan (BTW, trying that I found those false positives). Bad luck for us: namespaces in our legacy are shared between assemblies and technical layers, so that we have to consider every single type. Sure, we'd like to redesign it, but we need a tool to be able to formulate expected relations (e.g. dependencies, derivations etc.) and verify them and ideally every developer should be able to get a feedback as fast as possible. That is how the performance became a bottleneck for us. So, solving the problem of false positives I also found that it improves the performance. Thus, on my laptop execution time of that stress test was reduced from 3 hours to 11 seconds. Not sure, if anybody in the world (except our team) needs such an amount of source types and dependencies to work with, but for us it is the reality. |
| @@ -0,0 +1,193 @@ | |||
| // Copyright (c) 2020 Siemens AG. | |||
There was a problem hiding this comment.
Yes, this file is currently 100% Siemens code, given to the community under the terms of the MIT license, so all good 😃
There was a problem hiding this comment.
I'd prefer not to have copyright headers in individual files. Several reasons:
- IMHO it's unnecessary - your copyright is automatic when you make the contribution and is tracked in the GitHub history.
- It may actively discourage people from contributing. It implies that somebody "owns" the file, even though this is all under MIT. Copyright notices from large companies in particular can be off-putting.
- Adding copyright notices to the top of source files doesn't really scale as an approach. What if half a dozen people make contributions to the file?
- I would prefer a consistent approach - one person alone adding copyright notices does not foster clarity.
One of the better discussions I've seen on the subject is here: https://opensource.com/law/14/2/copyright-statements-source-files
There was a problem hiding this comment.
I had the same remarks as you, but our legal team thinks it's better to have those copyright statements in the files. I'll talk to them again! I'm pretty sure we'll find a way that works for all of us, so feel free to continue reviewing the functional changes 👍
There was a problem hiding this comment.
Thank you Flo!
There was a problem hiding this comment.
OK, we'll remove these copyright statements. Feel free to check out https://reuse.software/ to understand the reasoning for having copyright and licenses within source files and decide on your own what to do with this information 👍
There was a problem hiding this comment.
Source branch for the pull request (e.g. siemens:ExactMatchForDependency) is now up-to-date: all copyright notices are removed.
|
Merge conflicts with recent changes on master branch are now resolved. |
|
I've finally had the time to sit down with this properly and understand the change. It's a significant improvement - thanks very much for the code. It does add complexity to dependency searching, but the scalability gain is worth it IMHO. It also reduces the reliance on slightly sketchy string pattern matching by separating out each part of the namesapce. Thanks very much for removing the copyright notices - I recognise that this is one of those rather nuanced debates with no clear consensus. I'll release a new NuGet package tomorrow as there have been a few changes and bug fixes since the last release. |
Short description of the issue.
var result = Types.InAssemblies(...) .ShouldNot().HaveDependencyOnAny(new[] {"Namespace.Rectangle"}) .GetResult();This predicate fails, if a type has dependency on the "Namespace.RectangleWithRoundCorners".
Similarly, types from the "NamespaceTwo" are reported as dependencies from the "Namespace".
Short description of the fix suggested.
Namespace.Rectanglefrom the example above produces the chainNamespace,Rectangle. That builds indexed tree of names.string.StartsWith(...)method on each referenced type, its full name is also splitted, e.g.Namespace.RectangleWithRoundCorners==>Namespace,RectangleWithRoundCorners.Test cases
P.S.: should I create more detailed issue for the project?