Can NDepend output code in all methods for the dependency tree for specific methods?

It seems to me that we can integrate into our assembly process the ability to compare after each assembly against the previous assembly any code changes made in any dependencies for a list of specific methods.

So, if I have two methods that access the database, I want to find out if there was any method that called one of these two methods, everything related to the dependency tree changed the code.

+6
source share
1 answer

Such a code request should answer your needs:

// <Name>Methods that call Parse(String) or get_TestName() and that was added or where cpde was changed</Name> from m in Methods let depth0 = m.DepthOfIsUsing("NUnit.Core.RuntimeFramework.Parse(String)") let depth1 = m.DepthOfIsUsing("NUnit.Core.Test.get_TestName()") where (depth0 >= 0 || depth1 >= 0) && (m.CodeWasChanged() || m.WasAdded()) orderby (depth0 != null ? depth0 : depth1) select new { m, depth0, depth1 } 

Of course, with the warnif count > 0 prefix warnif count > 0 you can convert it to a rule if you want.

Here is the code request in action, underline methods are those where the code has changed since the baseline, methods in bold are those that are added after the baseline.

NDepend calls in dependency tree tree methods

You can click on the underlined methods by asking them to see the diff in the source code using your preferred comparison tool.

You can also export the result to a graph ( Export to Graph button), but then you can get disjoint graphs, since the methods will be absent without changes:

enter image description here

+4
source

All Articles