{"id":1469,"date":"2011-02-17T22:32:06","date_gmt":"2011-02-17T21:32:06","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=1469"},"modified":"2022-02-21T22:52:26","modified_gmt":"2022-02-21T21:52:26","slug":"fun-with-ndepend-part-one","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2011\/02\/fun-with-ndepend-part-one\/","title":{"rendered":"Fun with NDepend, Part I: Overview"},"content":{"rendered":"<p>Let\u2019s have fun with another tool in the .NET-universe: <a href=\"http:\/\/ndepend.com\/\">NDepend<\/a>. NDepend is a high-level code \/ IL analysis tool. In this post I give a short overview. In future posts I will dig into some details and useful stuff you can do with it.<\/p>\n<p>Download NDepend from this <a href=\"http:\/\/ndepend.com\/NDependDownload.aspx\">website here<\/a>. There\u2019s a free trial version which you can use to play around. NDepend runs as standalone tool, but also can be integrated into Visual Studio.<\/p>\n<p>For this blog post I use the source of one of mine favorite open source .NET libraries, <a href=\"www.autofac.org\">Autofac<\/a> .<\/p>\n<h2>Dependency Analysis<\/h2>\n<div id=\"attachment_1478\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/dependency-analysis.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1478\" class=\"size-medium wp-image-1478\" title=\"dependency-analysis\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/dependency-analysis-300x223.png\" alt=\"Dependency Analysis\" width=\"300\" height=\"223\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/dependency-analysis-300x223.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/dependency-analysis.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1478\" class=\"wp-caption-text\">Dependency Analysis<\/p><\/div>\n<p>The name of the tool already tells you that NDepend can do dependency analysis, and it can do it really well. It can analyze the dependencies between assemblies and Visual Studio projects. The visual representation looks something like this:<\/p>\n<div id=\"attachment_1472\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1472\" class=\"size-medium wp-image-1472\" title=\"ndepend-dependencies\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-300x240.png\" alt=\"Depedency Analysis\" width=\"300\" height=\"240\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-300x240.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-1024x819.png 1024w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies.png 1280w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1472\" class=\"wp-caption-text\">Depedency Analysis<\/p><\/div>\n<p>When you hover on an assembly on the graph or on the list, NDepend highlights all dependencies. For example when you hover over the \u2018Autofac\u2019-assembly, you can see what dependency it has and which other assemblies depend on it. An alternative view for dependencies is the dependency matrix. &nbsp;Again, the popups of NDepend explain what the numbers mean.<\/p>\n<div id=\"attachment_1473\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-matrix.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1473\" class=\"size-medium wp-image-1473\" title=\"ndepend-dependencies-matrix\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-matrix-300x240.png\" alt=\"Dependency Matrix\" width=\"300\" height=\"240\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-matrix-300x240.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-matrix-1024x819.png 1024w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-dependencies-matrix.png 1280w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1473\" class=\"wp-caption-text\">Dependency Matrix<\/p><\/div>\n<p>Of course you cannot only do such dependency analysis on assemblies level, but one other level. From the assembly level, over namespaces and classes down to the single methods. Like here for Autofac.<\/p>\n<div id=\"attachment_1474\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-digg.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1474\" class=\"size-medium wp-image-1474\" title=\"ndepend-digg\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-digg-300x201.png\" alt=\"Analyze dependencies on different levels\" width=\"300\" height=\"201\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-digg-300x201.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-digg-1024x687.png 1024w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-digg.png 1550w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1474\" class=\"wp-caption-text\">Analyze dependencies on different levels<\/p><\/div>\n<h2>CQL<\/h2>\n<p>One of the coolest feature of NDepend hasnothing to do with dependency analysis, but rather code analysis. It\u2019s the \u2018Code Query Language\u2019. This is a SQL dialect which allows you to write queries against the code. Now you wonder what this is useful for? Well mostly for defining your own code-metrics, find code-smells or find out certain properties of your code. NDepend brings already a rich collection of predefined queries with it, ranging from code quality metrics to API usage statistics. All queries can be set up to be a warning when a certain threshold is exceeded. This makes NDepend a nice code quality analysis tool.<\/p>\n<div id=\"attachment_1475\" style=\"width: 302px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1475\" class=\"size-medium wp-image-1475\" title=\"ndepend-cql\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-292x300.png\" alt=\"Query the code\" width=\"292\" height=\"300\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-292x300.png 292w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql.png 837w\" sizes=\"(max-width: 292px) 100vw, 292px\" \/><\/a><p id=\"caption-attachment-1475\" class=\"wp-caption-text\">Query the code<\/p><\/div>\n<div id=\"attachment_1476\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-codequality.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1476\" class=\"size-medium wp-image-1476\" title=\"ndepend-cql-codequality\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-codequality-300x196.png\" alt=\"Queries for measuring code quality\" width=\"300\" height=\"196\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-codequality-300x196.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-cql-codequality.png 882w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1476\" class=\"wp-caption-text\">Queries for measuring code quality<\/p><\/div>\n<div id=\"attachment_1482\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/analyse-inner-workings.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1482\" class=\"size-medium wp-image-1482\" title=\"analyse-inner-workings\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/analyse-inner-workings-300x244.png\" alt=\"Analyse Code\" width=\"300\" height=\"244\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/analyse-inner-workings-300x244.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/analyse-inner-workings.png 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1482\" class=\"wp-caption-text\">Analyse Code<\/p><\/div>\n<h2>Analyze Over Time<\/h2>\n<p>NDepend can analyze two different versions of the same project and then compare the changes. For example NDepend can find out if you have breaking API-changes in a newer version etc.<\/p>\n<div id=\"attachment_1485\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/change-over-time.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1485\" class=\"size-medium wp-image-1485\" title=\"change-over-time\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/change-over-time-300x259.png\" alt=\"Changes over Time\" width=\"300\" height=\"259\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/change-over-time-300x259.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/change-over-time.png 911w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1485\" class=\"wp-caption-text\">Changes over Time<\/p><\/div>\n<div id=\"attachment_1484\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/over-time.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1484\" class=\"size-medium wp-image-1484\" title=\"over-time\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/over-time-300x171.png\" alt=\"Change over time\" width=\"300\" height=\"171\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/over-time-300x171.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/over-time.png 900w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1484\" class=\"wp-caption-text\">Change over time<\/p><\/div>\n<h2>Reports<\/h2>\n<p>Another feature of NDepend is to create nice reports about a project. Those reports contain give an overview over dependencies, statistics etc. I think these reports are a great way to monitor a project. For example you could integrate them into your continues build and monitor if certain metrics are getting better or worse. Take a look at an example report of <a href=\"http:\/\/ndepend.com\/SampleReports\/OnDb4o\/NDependReport.html\">db4o here<\/a>.<\/p>\n<div id=\"attachment_1483\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-writes-reports.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1483\" class=\"size-medium wp-image-1483\" title=\"ndepend-writes-reports\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-writes-reports-300x292.png\" alt=\"Reports, those damned reports\" width=\"300\" height=\"292\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-writes-reports-300x292.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/02\/ndepend-writes-reports.png 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1483\" class=\"wp-caption-text\">Reports, those damned reports<\/p><\/div>\n<h2>Conclusion And Follow-Up<\/h2>\n<p>To sum things up, NDepend is a powerful&nbsp; tool for dependency and code analysis. Play with it <a href=\"http:\/\/ndepend.com\/NDependDownload.aspx\">yourself with the trial version<\/a>.<\/p>\n<p>In the next blog post I\u2019m going to play around with the Code Query Language and show a few use cases for it. Stay tuned.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s have fun with another tool in the .NET-universe: NDepend. NDepend is a high-level code \/ IL analysis tool. In this post I give a short overview. In future posts&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[126,19],"tags":[21,211],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1469"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1469"}],"version-history":[{"count":20,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":3933,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1469\/revisions\/3933"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}