Hw t Get Set Up and Running with NDepend Whether yu have purchased r dwnladed the trial f NDepend, we thank yu fr yur invlvement and interest in ur prduct. Here we have cmpiled a quick "Getting Started" guide t help yu get up and running with NDepend as quickly as pssible. While we have tried t cllect the basics in this dcument, we urge yu t experiment and explre NDepend n yur wn cde bases. There are a tn f features and pssibilities, many f which are ut f the scpe f this dcument. NDepend has been in develpment fr ver 8 years, and with every versin we take int accunt user feedback and requests. Fr any additinal help, reach ut t us at supprt@ndepend.cm, g t ur User Vice t leave a suggestin, r reach ut t us n Twitter @ndepend. Table f Cntents Installing the NDepend Extensin fr Visual Studi... 2 Analyzing a Visual Studi Slutin... 3 Analyzing.NET applicatins using Visual NDepend... 5 Using CQLinq with NDepend... 6 Using NDepend fr Reprts... 7 NDepend's Dependency Matrix... 9 What des the NDepend reprt tell me abut my cde?... 10 1
Installing the NDepend Extensin fr Visual Studi 1. Dwnlad the NDepend installatin.zip file 2. T install NDepend, just unzip the files in a private flder n yur machine NOTE: DON'T UNZIP THE FILES IN: '%PROGRAMFILES%/NDEPEND' AS THIS WILL CREATE PROBLEMS BECAUSE OF WINDOWS PROTECTION 3. If yu are running the NDepend Prfessinal Versin, cpy yur license file int the same flder where yu unzipped the NDepend files 4. Start NDepend.VisualStudiExtensin.Installer.exe 5. Click the "Install buttn" fr yur versin f Visual Studi 6. Start Visual Studi. 2
Analyzing a Visual Studi Slutin 1. Start Visual Studi after yu have installed the NDepend add-n 2. Open the Visual Studi slutin cntaining the cde t analyze 3. Click the grayed-ut NDepend circle status icn in the bttm right crner f the Visual Studi windw OR In the menu, click NDepend > Attach new NDepend prject t current Visual Studi slutin Nte: An NDepend prject can be attached t multiple Visual Studi slutins. This is useful if yu wish t analyze several.net assemblies cmpiled with several Visual Studi slutins. In additin, it allws ne t navigate acrss several Visual Studi slutins pened in several instances. 3
The pen dialg belw shws the.net assemblies f the Visual Studi slutin. Here yu can add mre.net assemblies cmpiled frm ther slutins. Click "Ok" and the NDepend analysis will start. It will just take a few secnds t analyze yur cde base fr the first time. 4
Analyzing.NET applicatins using Visual NDepend 1. Start VisualNDepend.exe 2. Select ne f the ptins: Analyze VS slutins and VS prjects Analyze.NET assemblies in flder Analyze a set f.net assemblies Click "OK". It will trigger the analysis f yur assemblies and surce cde by NDepend.Cnsle.exe. This analysis will take a few secnds t a few minutes depending n the size f the assemblies. Once finished, the result is displayed in the VisualNDepend.exe UI. 5
Using CQLinq with NDepend CQLinq is a query language based ff f the C# LINQ syntax and is a critical part f NDepend which uses CQLinq queries t assess a cde base and, furthermre, it allws users t create their wn cde queries. This allws architects and develpers t custm make cde rules t test fr custm metrics. Using CQLinq, there is virtually n metric yu can't test. NDepend itself cmes with 200 ready-made cde queries that yu can immediately use n yur cde base. When yu run the analysis n yur cde, yu will see sme clr feedback n the quality. Yellw and red highlighted lines f cde shw yu where rules are being brken, with red being mre severe breaches. Further infrmatin n CQLinq can be fund n the NDepend website. Additinal CQLinq resurces can be fund nline here: Sctt Hanselman created a NDepend Metric Placemat Erik Dietrich has started a blg series n making a metric n the NDepend blg Hw t Measure Mdule Cupling and Instability by Zrvan Hrvat r check ut the discussins n StackOverflw abut CQLinq 6
Using NDepend fr Reprts Reprts can be custmized thrugh the VisualNDepend r the VS addin > Prject Prperties > Reprt sub-panel. Yu can chse t activate many pre-defined sectins like Applicatin and Assemblies metrics, diagrams, CQLinq rules vilatins, and mre. The generated reprts are in.html frmat and are fund in the flder NdependReprtFiles. Any reprts shuld autmatically pen in yur brwser. 7
In additin, the reprts will give a summary f all the main rules vilatins. T custmize which vilatins yu want included in the reprt, yu can check r uncheck the bx next t each ne as well as chse hw the vilatin will be displayed in the reprt. Yu can als set which rules are t be cnsidered critical. Nte: It is recmmended t uncheck the Type Metrics and Type Dependencies when generating reprts n cde bases cntaining mre than a thusand types. This will cause the generated reprt t be very large. It is recmmended that yu use the Interactive UI t brwse metrics and dependencies instead. Here is what the cde rule vilatin part f the reprt lks like: Yu can clearly see the rules n the left, alng with hw many vilatins were fund (in yellw and red). Clicking n a cde rule n the left, gives yu additinal infrmatin abut the vilatins in the infrmatin windw n the right. 8
NDepend's Dependency Matrix The DSM (Dependency Structure Matrix) allws users t quickly get a brad verview f the dependencies and cuplings that exists within their cde base and displays structural patterns at a glance. It is different frm a graph since we fund that a simple dependency graph des nt scale well with larger assemblies f cde. Graphs are very gd at displaying infrmatin abut smaller cde bases but get cnfusing the bigger the base is. The DSM is a grid f clred cells with numbers inside f them. Each clr, blue, green, and black, mean a different thing and are defined via a cntext sensitive help system when hvered ver with yur muse cursr. If the cell has a number, this is the number f cuplings between the bjects in the same rw and clumn. By clicking n an cell, yu will see a dependency graph f that bject. 9
What des the NDepend reprt tell me abut my cde? Applicatin Metric: This sectin gives yu an idea f the tplgy f yur applicatin. Assembly Metric: This sectin gives yu an idea f the size f each assembly within yur applicatin in terms f #IL instructins and ther metrics. VisualNDepend View: This sectin illustrates the size f yur assemblies, namespaces, types and methds in terms f #IL instructins. Yu can brwse this view dynamically by clicking the Launch Visual NDepend n this Prject icn in the NDepend Prject UI. Assembly Abstractness vs. Instability: This sectin illustrates the Abstractness/Instability principle explained in the assemblies metrics sectin. Assembly Dependencies: This sectin shws all the dependencies between the assemblies f yur applicatin in a table. Assembly Dependency Diagram: This sectin shws all the dependencies between the assemblies f yur applicatin in a diagram. Assembly Build Order: This sectin gives yu ne f the pssible build rders fr yur assemblies. If a cycle exists in yur assemblies' dependencies graph, this sectin will reprt it. NDepend Infrmatin and Warnings: This sectins gives yu feedback n yur cde: It warns yu when an assembly depends n a less stable assembly than itself. It warns yu when the visibility f a type r f a member is nt ptimal (in the cntext f the analyzed applicatin). It warns yu when a type r a member is nt used (in the cntext f the analyzed applicatin). CQLinq Queries and Rules: This sectin reprts default CQLinq rules which have been vilated. Mre abut CQLinq here. Type Metrics: This sectin recaps the type metrics in a table. A link t the dcumentatin is prvided fr each metric. Further Infrmatin Can be Fund On Our Website http://www.ndepend.cm 10