Thursday, December 22, 2016

How are the use of layers in Orchard CMS?

What is Layer?

A layer is a group of widgets (with their specific configuration, which includes their positioning -zone name and ordering-) that is activated by a specific rule.

For example, the TheHomePage layer is activated by a rule that specifically selects the home page. The Default layer is always active no matter what page is displayed.

The Authenticated layer is only active when users have identified themselves. When more than one layer is active on any given page, all the widgets from all those layers get displayed at the same time. Orchard orders them based on their position string.

What is the use of Layer?

Layers change the layout of your new page without affecting the rest of the site you can create a new layer for a specific pages by specifying layer rule. These help to render some content on a specific location of the page except other pages does not change.

See the below example:

Adding a New Page to Your Site

  1. In the Orchard Dashboard, under New, select Page.
  2. Enter a title for the page. When you enter a title for the page and save it (for example, "Download"), the permalink (URL) for the page will be filled in automatically ("download"). You can edit this link if you prefer a different URL.
  3. Enter some text for the content page body.

    clip_image001
  4. In the Tags field, add comma-separated tags such as "download" and "Orchard" so that you can search and filter using those tags later.
  5. Check Show on main menu and enter the menu text ("Downloads") to use in the site's main menu.
  6. Select Publish Now to make the updates to the page visible immediately. You can also save the page as a draft (to edit later before publishing), or you can choose to publish the page at a specific date and time.

    clip_image002
  7. Select Your Site in the upper-left side of the Dashboard to view the modified home page with the new menu. Clik Downloads and you will see your new page.

Adding New Layer for a Page

To change the layout of your new page without affecting the rest of the site you can create a new layer, that will be applied only to the Downloads page. Then you can place some widgets on that layer and they will be visible only in the Downloads page.

  1. Go to the Dashboard and select Widgets. Then click add a new layer to add a new layer for this page which will allow you to customize the layout for the new page at a later point in time.

    clip_image003
  2. Write a name for the layer, a description, and a layer rule: url"~/download". This will instruct the Orchard System to show the widgets in this layer only when the url of the browser is pointing to "download". Select Save.

    clip_image004

Adding a New HTML Widget

  1. To check that your layer rule is working you can add a widget to it. Ensure that Current Layer is Download. Click Add in AsideFirst.

    clip_image005
  2. Add a new Html Widget.
    clip_image006
  3. Write a title and a body for it. Save it.

    clip_image007
  4. Select Your Site in the upper-left side of the Dashboard. Navigate to Downloads. You should see the custom layout.
    clip_image008

Now you will see that ‘Downloads’ page has different layout rather than other pages because it uses different layer except other pages use different.

Friday, October 7, 2016

How to configure log4net in .NET projects?

log4net is an open source library that help the programmer output log statements to a variety of output targets in .NET .
Here we are going setup logging using the Log4Net. Below are the necessary step to get Log4Net in the project and configure it:
  1. Right click on the solution in the “Solution Explorer” and select “Manage Nuget Packages for Solutions..

    image_thumb[9][4]_thumb[2][1]

    Now search for the log4net using the search box and you will find the log4net by Apache Software foundation. The another thing need to remember is that you have to select the projects on the right side where log4net reference is required. It should be in start up project and another projects are optional to add the reference of the log4net.

    image_thumb[10][4]_thumb[3][1]
    After this you will find log4net in referenced libraries of the selected projects.

    image_thumb13[4]_thumb[1][1]


    This can be done by running the “Install-Package” command on the “Package Manager Console” as seen in below image:

    image_thumb[13][4]_thumb[1][1]

    Alternative, you can download the binaries from Apache.Org website and reference them manually in the project where logging is required’'.
  2. Now you need to configure log4net to log the information or errors to different targets e.g Console, file, database etc. Right now we are going to configure it for the easiest way to log the information.

    Using log4net is a three stage process. First thing we need to do is configure log4net. For an example, below are simple steps to configure the BasicConfigurator.
    log4net.Config.BasicConfigurator.Configure();
    In second step, is to get Logger object using the static method GetLogger of the LogManager to log using the log4net:
    var log = log4net.LogManager.GetLogger(typeof(Program));
    After that use the logger object to log the message:

    log.Info("Exception Message");

Complete code snippet:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Log4NetConsoleCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            log4net.Config.BasicConfigurator.Configure();

            var log = log4net.LogManager.GetLogger(typeof(Program));

            log.Info("Exception Message");

            Console.ReadKey();
        }
    }
}
If we run the program then it will show log message in console.
image_thumb15[4]_thumb[1][1]




Wednesday, September 28, 2016

CodeRush for Roslyn is now available RTM Version

 

CodeRush helps the developers to write, refactor, navigate and debug C# and VB source code faster and more efficiently. Along this CodeRush includes the world's fastest .NET test runner which helps developers to complete software development tasks with less effort (both physical and cognitive), and in less time.

What makes this CR for Roslyn better than Classic version?

This newer version of CodeRush for Roslyn uses significantly less memory, works faster, and lets the Visual Studio to start faster the CodeRush Classic. It leverages Visual Studio's solution-parsing data and automatically supports new C# and VB language features as they become available in Visual Studio.

Features provided by CR for Roslyn:

  1. Visualize Code and Intuitively Debug
  2. Move at Warp Speed
    It helps to find symbols and files quickly in your solution and easily navigate to code constructions related to the current context. CodeRush includes the Quick Navigation and Quick File Navigation features, which make it fast and easy to find symbols and open files.
  3. Navigation features are available via the Navigation menu, which can be invoked using the Ctrl+Alt+N shortcut.

  4. Validate Quality Faster
    CodeRush lets you create new test cases or new test suites in a single keystroke. CodeRush for Roslyn automatically detects unit tests for NUnit, xUnit, MSpec and MSTest frameworks, and can optionally run tests located across multiple assemblies concurrently. The Test Runner also runs CoreCLR test cases in the DNX environment. The Sessions support makes it very easy to organize tests and run only those that are required.
  5. Code Refactoring
  6. Code Analysis
  7. Code Formatting and Cleanup
  8. many more…

Complete feature comparison matrix between CodeRush editions is available at Download Classic or Roslyn Version.

Wednesday, August 10, 2016

When to use CodeRush Classic or CodeRush for Roslyn?

Microsoft’s has started new way of development in Open Source world with the  paradigm “Compiler as a service”. Now Microsoft has lots of open source projects including the .NET Compiler Platform (“Roslyn”).NET Compiler Platform (“Roslyn”). The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs. You can build code analysis tools with the same APIs that Microsoft is using to implement Visual Studio!.

According to these dramatic changes in the development on the Microsoft platform lots of tools are adopting ways to move along these. After a while again I got chance to install CodeRush in Visual Studio IDE and I there are two different flavours of CodeRush. This makes me little confuse that which one should i install to work with.

After checking through documentation and ready some blog posts related to my question I got that When to use this newer version of CodeRush for Roslyn or CodeRush Classic. Actually CodeRush Classic work with the prior version of .NET Framework 4.6. With this newer version of .NET framework which is shipped with the Microsoft’s open source projects which based on the Rosyln compiler platform. Below are points which help you to decide that which version suits to your development environment:

  1. If you are using Visual Studio  2015 and .NET framework 4.6 (above) then CodeRush classic does work for you. In this case you should install CodeRush for Roslyn. This does not has all the feature of the CodeRush Classic but newer version will defiantly improve this open source stack.
  2. If you are working with older version of .NET Framework then you’ll need CodeRush Classic. If you need both, you can install both versions simultaneously and defiantly i try this too.
  3. CodeRush Classic supports C# 5.0, VB10, ASP.NET, HTML, JavaScript, XML, and XAML. In this case, for the newer version of language CodeRush for Roslyn is the only option and may be in near future Classic version of CodeRush go obsolete.

Learning and source of information:
CodeRush
.NET Developer Tooling: The Roslyn Revolution
CodeRush on Roslyn

Tuesday, July 26, 2016

How to add Intellisense to Visual Studio Code for bootstrap

Peoples who are habitual of using intellisense in Visual Studio and suddenly it is found missing then they really get mad during the work. Today I am trying to create some html pages with bootstrap for learning. I was feeling little hard to do code with bootstrap, because I am not able remember all of the class names of the bootstrap.

There are lots of glyphicon classes which is hard to remember. Visual Studio has this nice feature by adding JavaScript library path to the “_references.js” file and after that everything available in autosuggest mode.

What happened with me, I am not able to find the correct gylphicon class name without intellisense. Regarding this I have googled and found that this feature is not currently available in VS Code right now. However, it has been added as a feature request for upcoming updates.

Do not disappoint, There is also hope to do work with intellisense in VSCode. You can use extension"HTML CSS Class Completion".

Open Command Palette by press ctrl+ship+p Then run  “ext install HTML CSS Class Completion” to install this extension. Check the results in below image to see after enabling this extension.

image

Happy coding!

Thursday, July 21, 2016

Customize context menu in Nevron Diagram

Scenario:

I had a requirement for preventing user to edit the “Composite Shape” elements (e.g. Text Primitives, Ports etc.). This restriction is required during the development for most of the cases because programs are using these shapes for some special purpose representation and these should not be altered by the use at run time to keep them consistent.

If user change these shapes then it will be hard to know that it has been modified this diagram is saved as XML string in some data store. If shape elements are used to identify the shape elements by name then it will break the program for being consistent for these shapes. See the below image, If the edited port name is used in program to  identity the center port then it will be distinguish the center  port in all of these ports.

clip_image002[5]_thumb[1]


Finally, it is required to remove some commands from the context menu of the shape in the diagram view for the user so that user will not able to modify the shape elements.

Solution:

At first place, you need to use the “Protection” on the shape to prevent some operation. You can restrict few operation on the shape for the user.

clip_image003[9]_thumb[1]


These can be set programmatically, these are just for making restrictions on the shape not for the context menu operations. See below code example:
NAbilities shapeAbilities = new NAbilities();
shapeAbilities.All = false;
shapeAbilities.InplaceEdit = true;
shapeAbilities.ResizeX = true;
shapeAbilities.ResizeY = true;
shapeAbilities.Export = false;
NShape shape = (NShape)nDrawingDocument1.ActiveLayer.Children(null)[0];
shape.Protection = shapeAbilities;

Real Solution 
The simplest solution is that create a custom context menu builder for creating context menu for the current diagram view.  This will create/add the required command that you want to provide to the user while working in the diagram.
First create a Custom ContextMenuBuilder by inheriting “NDiagramContextMenuBuilder” class and override “BuildContextMenu” method. There you need to create the context menu and add the required commands to the created context menu.

internal class CustomContextMenuBuilder : NDiagramContextMenuBuilder
{
    public override NContextMenu BuildContextMenu(object obj)
    {
        NContextMenu contextMenu = new NContextMenu();
        contextMenu.Commands.Add(CreateCommand((int)DiagramCommand.Delete, false));

        return contextMenu;
    }
}
After that create an instance of this custom context menu builder and assign it to the ContextMenuBuilder property of your diagram command bars manager:
nDiagramCommandBarsManager1.ContextMenuBuilder = new CustomContextMenuBuilder();

Create and preview website page using Visual Studio Code

Today is the first day when i have used Visual Studio code after uninstalling the Bracket. Bracket has nice feature live preview to run the html document in the browser. I was expecting the same in Visual Studio code but it took me half an hour to figure that how to run the html from VSCode. VSCode use Node.js for most of the work to be done.
Finally i have figure out that how to start a small project, containing only a single HTML file in VSCode and edit it with preview in a browser similar to live preview feature in Bracket. I have all my tools setup to start creating my first project in VSCode but if you are not installed VSCode and Node.js then download VSCode and Node.js.  You can find little bit information to install Node.js here.
After you have done installation of the Node.js, either you need to setup the PATH variables in windows or the setup automatically done this work for you. You can verify this by typing below command on command prompt that Node package manager is globally accessible or not:
npm -v
Now it the right time to setup the webserver. Run the below command on the command prompt:
npm install -g live-server
image_thumb[3][9]
Now create a html file in VSCode configured folder.
image_thumb[6][9]
To preview the html document, run the below command at the project folder.
live-server

image_thumb[10][9] It is also possible to see the live preview in VSCode split windows. You have follow below steps to do this:
  1. Create a live-view.md file with this in it (Place it wherever you want. I put it at the base folder of all my projects since I can use it for whatever I'm currently working on):
    <div style="border:1px solid #777;
    position:absolute;left:10px;top:10px;bottom:10px;right:10px;"> 
      <iframe src="http://localhost:8080/"; width="100%" height="100%" frameborder="0" /> 
    </div>
    
  2. Open live-view.md in the second/split pane in VS Code and click the "Open preview" button (top right of file).
Happy coding.

Thursday, July 14, 2016

Run CSharp “Hello World!” program on Developer Command prompt

To start writing your first program without using the Visual Studio or other tools, you just need to open “Command Prompt”. Just type command on the search in Start menu either you are using Windows 7 or any higher.
image_thumb[10]_thumb[3][4]
Visual Studio installs few command line tools to do some operation using command tools and these can be invoked using the “Developer Command Prompt for VS2015”(For Visual Studio 2015). If someone has not installed Visual Studio then just install .NET Framework on the computer.
After this we are ready to create and compile our “Hello World!” program using the .NET Framework compilers.
Now create a file “hello.cs” using the “notepad”. We are going to write our code to print “Hello World!” on the screen for this example. “.cs” is the common extension for the C# file and “.vb” for Visual Basic. So now we going to create a C# program now so this file will contain C# code.
image_thumb[16]_thumb[1][4]
After running this command a prompt will appear with message “Do you want to create a new file?”. Click on “Yes” to create a new file.
In this we are going to create a class with a static method “Main”. In a Console application that would run on command prompt, CLR look for class named “Program” with a “Main” method to run the program.
image_thumb[8][3]
Now save this file and come back to the command prompt.
Now one of the tool “csc.exe” exists in the “Windows” directory in the .NET framework installation paths. It can be located at the path “C:\Windows\Microsoft.NET\Framework\{.NET Framework}”. Under the Framework folder you will find installation of .NET Framework multiple version. Below is the path of the latest one on my system. It is the “Visual C# Command Line Compiler” which compiles the C# code.
image_thumb[24][4]
Now we are going to compile the C# code then execute the program. After compiling the program C# compiler produce a executable file(.exe).
To compile the created C# code file, use the below command line on command prompt. Just pass the created “hello.cs” as parameter.
  1. csc hello.cs 
image_thumb[29][4]
On windows we can run exe. Now run the hello.exe to view the result of our example program.
image_thumb[32][4]
That’s all done. We have created an example program run on the command prompt using the C# command line compiler.
Actually it transforms C# code into Microsoft Intermediate Language. This can either an exe or dynamic link library. We specify the assembly format to the csc.exe using the /targe:library option. See below image for various target options:
image_thumb[37][4]
  Happy Coding!



















Tuesday, July 12, 2016

Configuring Orchard CMS blog in Open Live Writer

After using Windows Live Writer, now I have start using Open Live Writer to do remote blogging. Right now WLW is not able to connect with few blogging platforms like blogger.com and also Microsoft has stopped putting efforts on the amazing tool for the bloggers.
OLW is an open source tool which is developed by the contribution of the developer community. Lots of features of this tool is under development. It has the main advantage that there are many tools available as compare to the HTML editor on the remote blog. You can work offline, which might be good if you’re in a situation where you don’t have a decent internet connection or not able to connect to internet for days. It will let you write blog posts and save them to draft for later publishing.
In this article, you will go through the steps to configure Open Live Writer for the Orchard CMS. This provide support for remote bloging through XmlRcp. Both WLW and OLW are able to connect with the Orchard CMS blog using this feature.
Orchard provides this XML-RPC feature out of the box and You have to enable it in the Modules section inside your Orchard CMS Orchard admin panel.
Prerequisites:
  1. You have setup Orchard CMS on your web hosting or local IIS and created a blog on website.
  2. Installed OLW on your computer.
If you have done pre work then go to the Administration Dashboard of Orchard and click the Modules. There you will find Remote Blog Publishing feature under the Content Publishing section. It is dependent on XmlRpc so if you enable it then XmlRpc feature will automatically enabled.
clip_image002
To enable Remote Blog Publishing click the Enable link. After clicking the enable link you will see both of them enabled at once since they are dependent features. After you click Enable, if everything is Ok then you will see following message:
clip_image004
After enabling these modules you are ready to configure Orchard blog in Open Live Writer. Now, launch Live Writer from your Start menu in Windows.
In Blog Accounts section, click on 'Add blog account'
clip_image006


When you choose “Add blog account” then you will see below prompt to select the blog service. Choose “Other blog service” from the available options and click Next.
clip_image007
Type the URL to your Orchard blog, along with the admin user name and password that you defined when you set-up Orchard for the first time.
clip_image008
Click Next. Open Live Writer will connect to your blog in order to read the XML-RPC capabilities that Orchard supports and download the current Theme (for previewing posts before publishing). If you are prompted to create a temporary post during this step, select "Yes" in the dialog.
clip_image009
After that it will complete downloading supporting files and template for making blog post writing intuitive.
clip_image010
Once it finishes, you will have window where you can specify the name of your blog you have just configured in Open Live Writer, click Finish.
clip_image011
Now you are ready to write blog post for your Orchard CMS blog.






















Thursday, July 7, 2016

Prevent minification to manipulate Angular JS controller parameters

In AngularJS controller can have $scope or $http parameters. These must be $scope or $http rather than s or h. Minification process removes extra spaces and convert JavaScript method parameters to single character so that it tries to convert them in single character parameters.
When we declare a controller using the module then most of us just simply specify the controller method as below:
    var app = angular.module("githubViewer", []);   
    //Controller
    var MainController = function($scope, $http) {   
    };   
    app.controller("MainController", MainController); //MainController is controller method
During the learning, I get to know that during the minification process these parameters are changes to some single character. If these are renamed then AngularJS will not able to find the $scope and $http parameter. It expect them as 6 character $scope and 5 character $http in the controller method. To avoid this happen you need manually specify the parameters name when you specify the controller name and controller method to the module.

app.controller("MainController", ["$scope", "$http", MainController]);
Hope this help someone to avoid making this mistake..

Tuesday, July 5, 2016

“Object reference not set to an instance of an object” after install of Visual Studio 2015 Update 3.

Yesterday I have installed update 3 for Visual Studio  2015 Community edition. At that time set failed due to internet disconnection during the installation. Somehow setup completed but when Visual studio was not working correctly. It was showing “Object reference not set to an instance of an object” when try to select any item in visual studio as shown below:

image

To resolve this issue I have tried to repair the Visual Studio using Program and Features in Control Panel but still the situation is same. After doing some research I found that it is the issue with the configuration setting and common files for the visual studio located at following locations:

  1. C:\Users\{user}\AppData\Local\Microsoft\VisualStudio
  2. C:\Users\{user}\AppData\Local\Microsoft\VSCommon

Delete the content from these folders. If you do this way then all of your user settings such as Visual Studio layout, linked Microsoft account or start page settings get lost.

If you have installed multiple version of the Visual Studio then it is sufficient do delete folder ComponentModelCache on path
C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\{version - 14 or 12}. It will preserve other setting of the Visual Studio. If it does not work then delete all content from the “Visual Studio” folder.

Some times it require to run “devenv /resetuserdata” command to reset the user data of the visual studio. I did it also using the Developer Command Prompt for Visual Studio Console but you can find this command tool at following locations:

  1. [x64] C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
  2. [x86] C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE

image

Hope it will save time for someone rather doing uninstall or install for Visual Studio again.

Wednesday, June 29, 2016

New feature “Add a reference to a NuGet package” in Visual Studio 2015 Update 3

Microsoft announced the release of Visual Studio 2015 Update 3 two days ago. They have addressed issues from previous update and improved few things. In the list of improvements, I found an interesting thing that you can now quickly include NuGet packages by just using the resolve reference method. You can say it An option to add a reference to a NuGet package as a quick fix.

nugetbulb

You can enable this option from Tools > Options > Text Editor > C# > Advanced, under "Using Directives":

nuget

Visual Studio is improving in most of the expects for the development of the Universal Application development. There kind of improvements can make you more productive..

Monday, May 2, 2016

Analyzing the Quality of your code with NDepend

Throughout my carrier I have worked on various projects in different environment. Few of them are completed solo and few are with small or big teams. As per my opinion and learning till now “Writing a good and clean code is an art”. This is improved with experience and learning about the “Design Patterns”.

When you are doing project as one man army then you are good to write better code and refactor it maximum as per your understanding and knowledge, but when it done with in a large project and team then a project manager or Architect will definitely worry about the quality and success of the project.

In starting days of my carrier, One day my manager asked me to learn about the Cohesion and Coupling. I was not able to understand it much at that time and tried so many time to implement it in my coding practices. After continuously taking care of such factors and knowing about the “Design Patterns” e.g. SOLID, FAÇADE etc. what I have realized that all of these things redirect the programmers to make “Quality Code”.

After this when it comes to manage a big project then you require some tools which help to find issues in a large project. It makes an architect to keep free from these below question for some instance:

  • Is the code looking good?
  • What about its complexity and test coverage?
  • Can you consider the code as maintainable with a good scalability?
  • Are there instances of copy and paste code smells?
  • How loosely and tightly coupled is the architecture? (In terms of cohesion and coupling etc.)

Doing this task manually is a time consuming process because checking and running every module will definitely consume some time. Without running the project it is possible in manually compiling and inspecting but with the tools it is much time saving process.

To check the quality of the code and analyze, I put my hands on Visual Studio inbuilt tools e.g. Unit Test Runner, Code Metrics, and Static Code Analyzes. These tools are good to work but there are few third party tools available to do some task with high precision analyzes e.g. FxCop, JustCode, ReSharper, and NDepend.

In this article, I am going to explorer the features and benefits of NDepend.


What is NDepend and its use??

NDepend is a static code analyzes for .NET. NDepend can be used in both standalone and Visual Studio integrated mode (Through Visual Studio extension). This nice tool is create by Patrick Smacchia for the developer community.

NDepend Visual Studio extension performs a range of analyzes across a solution, either during design time or retrospectively across an existing project. Current version of NDepend 6 provides 82 Code Metrics which are analyzed and reported on by the tool either in GUI or html format.

Right now I have used it in Visual Studio Integration mode. I prefer to use in integrated environment rather than doing application switch for doing same thing in different window and NDepend provide most of its functionality in Visual Studio while working with the project through a separate menu.

clip_image001

Setting NDepend Integration with Visual Studio:

To enable work NDepend in Visual Studio, NDepend guys provides an extension installer “NDepend.VisualStudioExtension.Installer.exe”. Check highlighted file in the below image.

clip_image002

Once you run this extension installer it will pop up an installation dialog which let us to integrate NDepend in our desired version of Visual Studio. Right now I am using Visual Studio 2015, so I installed for my IDE.

clip_image003[6]

After completing installation, you can access to various metrics, rules, graph, reports, analyzer results and tools at one place to analyze the project for different aspect of the quality measures.

NDepend is mainly a static analyzes tool and more. It provide out of the box rule and customizability of rule through CQLinq, Visual Dependency representation, Build Integration and Change tracking. NDepend allow us to write own custom rules and you can visualize your code base and its dependencies with series of matrices and graphs as well.

It does more than providing snapshot of the code base at moment some times. It integrates in to Build process and allows us to monitor the evolution of the code and decide whether you making progress towards quality or not.

Start analyzing my first project with NDepend

After installing NDepend in Visual Studio, I found it very user friendly and quite intuitive. You can just select project from the NDepend menu to start analyzing it. Let see how its start screen looks like in first glance.

clip_image004

Here you can select specific menu to start working with NDepend. Now my solution is open so I am just going attach a new NDepend project to current solution. Just click on the circle in status bar of the Visual Studio and you have access to NDepend here also. See below image.

clip_image005

Now select “Attach new NDepend project to current VS Solution”. Now it prompt to select the assembly to analyze and you can also add another assemblies on below screen.

clip_image006[6]

Just click on “Analyze a single .NET Assembly”. Now it start analyzing the assembly and after completion of process it will pop up a dialog and along this generates html report about the analyze results.

clip_image007

I am going to click on the View NDepend Dashboard and it redirected me to dashboard.

clip_image008[6]

  And html generated report is shown as below:

clip_image009

In Visual Studio, there are lots of windows available through NDepend to analyze quality of the code base and even you can customize these. I am going through main features of the NDepend one by one. See below screen shot with Queries and Rules Explorer, Dependency Graph and Queries editor. 

clip_image010[6]

Code Rule and Code Query over LINQ (CQLinq)

NDepend project provides build-in metrics when you create a new project to analyze an assembly. As I saw in Queries and Rules Explorer, there are more than 200 default project rules and their queries.

These rules are made up using the CQLinq. CQLinq is default scripting for NDepend to create rule queries. So in this way you can create our own queries and customize them too. CQLinq editor provides code completion and intellisense with live error description.

clip_image011

Dependency Matrix

Dependency Matrix shows dependency and coupling between the projects and their module. NDepend must responsive and easy navigate through the dependencies between the projects. When you click on any cell then it shows graph and information in tooltip manner. I liked this behavior because I do not need to switch between dependency graph and dependency matrix. They are shown in a synchronized way and easy to visualize and analyze the results.

clip_image012[6]

Dependency Graph

It is an interactive way to represent coupling between the code base elements. Actually NDepend provide this graph for various code exploration scenarios. You can find full description about these in documentation - Exploring Existing Code Architecture in Visual Studio through Dependency Graph.

  • Dependency Graph
  • Call Graph
  • Class Inheritance Graph
  • Coupling Graph
  • Path Graph
  • All Paths Graph
  • Cycle Graph

These various type of graphs are accessible from NDepend->Graph menu items.

clip_image013

clip_image014[6]

Code Metrics View

Code metrics view represents tree-structured data in rectangular blocks format.

clip_image015

Continuous Integration Reporting

These feature matter much analyzing a huge code base. Along with CQLinq, I like NDepend for this feature. NDepend integrate with TFS, Team city etc. in build process to check for the violation of CQLinq rules continuously and these are reported to the development teams to improve the code.

NDepend can analyze source code and .NET assemblies through NDepend.Console.exe. Each time it analyzes a code base, NDepend yields a report that can inform you about the status of our development. As I described in the starting of article about the html document which generated during the analyzing process is generated during build process.

This exe is located in the installation folder and the file name is “NDepend.Console.exe”. It is integrated in the building process by specifying command line arguments.

Conclusion

These are the few features which I have used so far but NDepend is loaded with lots features. In my opinion NDepend is light weight, powerful and intuitive application. Customization with the rules and metrics is an additional advantage using its best part CQLinq. It also integrate with Reflector and other tools which improves the productivity. I found it much better tool for maintaining quality of the application so far. Hope NDepend will continue improving this tool in future and let development process to improvise in easy way.