5

BACKGROUND

As time goes by, I find myself more and more turning to NDepend to gain insight into the design/implementation of legacy applications.

QUESTION

Rather than adding JustMyCode to CQL queries, is there a way to permanently configure NDepend (at the project level) to simply ignore the .NET Framework? I could be wrong, but I am pretty sure that this feature was supported by NDepend v3.

EXAMPLE

  1. Open your solution in Visual Studio and click Rebuild
  2. create an NDepend project based on your solution file (*.sln)
  3. run the Analysis
  4. open the interactive (non-HTML) Dependency Graph
  5. click the Reset arrow in the top left corner (hint: the recycling icon)
  6. click reset to application assemblies only
  7. observe
    • you will no longer see references to the .Net Framework (note: the blue writing is gone)
  8. right click on one of your assemblies: Select Types
  9. click that I use directly
  10. the following CQL will appears in the queries window:
    • from t in Types where t.IsUsedBy ("MyCompany.MyProduct.MyAssemblyName") select new { t, t.NbILInstructions }
  11. observe
    • more than likely you will now see .NET Framework references (note: the blue writing is back) in the query results window
    • add JustMyCode to the CQL query and the .NET references disappear again: from t in JustMyCode.Types where t.IsUsedBy ("MyCompany.MyProduct.MyAssemblyName") select new { t, t.NbILInstructions }

CONTEXT

  • Application: NDepend version 4.1.0.6871
  • View: Dependency Graph
Pressacco
  • 2,815
  • 2
  • 26
  • 45

1 Answers1

1

The only two ways to ignore a .NET assemblies are:

  • Using notmycode/JustMyCode as you wrote
  • Remove the assembly from the Project Properties > Code to Analyze panel.
Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92
  • Thank you for the feedback. It appears that you cannot remove assemblies from the *Code To Analyze* => *Third Party Assemblies* list in NDepend v4 (which includes .NET references like System.Data). Is this correct? – Pressacco Dec 19 '13 at 14:23
  • Oups, I didn't get you were only concerned by third-party assemblies. Indeed, Third-Party assemblies are inferred automatically from application assemblies. In v5 we added the possibility to get a graph or a matrix of application assemblies only (or application namespaces only). In v4, this is possible but you have to write a code query for that (eliminating ThirdParty assemblies), and then export the result to the graph or matrix. – Patrick from NDepend team Dec 19 '13 at 15:32
  • To clarify: I am *only* concerned about application assemblies. That is why I am trying to find a way to permanently ignore Microsoft's .NET Framework. I see now that I either have to use `JustMyCode` in CQL, or upgrade to NDepend 5. Thank you for your help Patrick. – Pressacco Dec 19 '13 at 17:18
  • 1
    Sorry but this answer is horrible for someone new to NDepend. Where do you put this "notmycode/JustMyCode" code? In some rule? In a general rule? You cannot "remove the assembly" as @Pressacco said in NDepend 6. I simply want to analyze MY code, not all the third party assemblies. – Jack Oct 19 '15 at 17:13
  • I guess you followed the link to notmycode/JustMyCode http://www.ndepend.com/docs/cqlinq-syntax#NotMyCode which point is unclear there? all code elements matched by a code query prefixed with notmycode will be discarded from JustMyCode (typed as ICodeBaseView). hence you can easily eliminate some assemblies with notmycode queries, these assemblies won't be enumerated anymore by the JustMyCode code base view. Is it clearer? if no ask specific questions please – Patrick from NDepend team Oct 22 '15 at 11:40