Category name:Code Quality

BizTalk Software Factory v5 for BizTalk 2013R2

If you’re not familiar with the BizTalk Software Factory, please read the documentation on http://bsf.codeplex.com/releases.

Every new release of BizTalk requires some changes in the BizTalk Software Factory (BSF) and the 2013R2 edition is no exception. Most important change is in the Visual Studio version and the BSF relies on the Guidance Automation Toolkit (GAT) and Extensions (GAX) to be available.

Since Microsoft stopped development of the toolkit and extensions I’m happy to see the community continues it by means of the Open GAT/GAX (http://opengax.codeplex.com) project.

To be able to install the BSF (http://bsf.codeplex.com) you need to install the Visual Studio 2013 SDK and the Open GAT/GAX for Visual Studio 2013 upfront.

The functionality of the BSF hasn’t changed but it is important to know that at this moment there is no version of the BizTalk Deployment Framework (BTDF) that supports Visual Studio 2013. Since the BSF supports the BTDF, it currently is available but doesn’t work. Installing BTDF v5.5 on Visual Studio 2013 does work, but Visual Studio will not contain any of the BTDF functionality.

If you run into issues or you like to have some additional functionality in the BSF please let me know.

Didago IT Consultancy

Introducing the BizTalk Port Info Query Tool

Sometimes for a project you have to create a tool which you plan to share with the community. This tool has been on the shelf for at least a year and I finally found time to share it with you.

It started when I got involved as a fire fighter in a BizTalk project at a customer which had a lot of applications and accompanying hundreds of receive and send ports. The architecture was fully based on the pub/sub architecture and it was sometimes very difficult to understand the flow of the message and also to understand where a message would end up. To get a better view of the inner workings I decided to create a small tool to answer questions like:

  • Which ports do uses this specific map?
  • Where is a certain pipeline used?
  • Which ports subscribe to this field?

This tool is capable of reading the management database and retrieve the receive port and send port information via the ExplorerOM assembly. Only port name and so on is not detailed enough, so I added support to retrieve the following information to get a total view:

  • Receive Port Name
  • Receive Locations
  • Receive Transform
  • Receive Pipelines and Pipeline Components + Configuration
  • Receive Adapter Type and Settings like URL’s
  • Send Port Name
  • Send Transforms
  • Send Pipelines and Pipeline Components + Configuration
  • Send Adapter Types and Settings like URL’s
  • Send Port Filter Subscriptions

This information is retrieved for each of the selected applications. Once this information is available, then it is easy to also search through it. So search was added to be able to quickly see which receive ports or send ports are using a certain map or which send ports are subscribed to a certain field value.

It proved to be pretty handy for research purposed. The tool doesn’t require an installer only launching an executable to show up the winforms application. The sources and executable are on CodePlex and are tested with BizTalk 2010 and BizTalk 2013.

If you launch the tool you’ll get the screen below where you can adjust the user id and password to connect to the management database.

StartScreen

Once you click ‘Retrieve BizTalk Applications’ the management database will be queried using the specified credentials to retrieve all deployed BizTalk applications. Depending on the amount of applications this can take some time.

AppsLoaded

The list of applications are prefixed with a checkbox, so you can retrieve the information for specific applications only if you wish. When you’re ready selecting the applications, then click ‘Retrieve Application Info’ to get the details.

PortInfoLoaded

You now see two populated tree view controls on the right hand side. The top one contains the receive port information and the bottom one the send port information. Per BizTalk application there is a hierarchy containing all the details. If you for example expand the tree you’ll see information about the receive locations, transforms, pipelines and so on.

PortInfoExpanded

The following image shows the details of pipeline components and their settings.

PortInfoExpandedPLC

The best part is that you can search through all information in the receive and send port tree views. The search text box scans the trees for a match and displays the results in the bottom list view. In the example below shows a search for every instance containing ‘_to_’ and as expected the maps on the send and receive ports show up, including the path to the applications they reside in.

PortInfoSearch

Sometimes the information (path) is too long, like with filter subscriptions which can take up many characters. In that case you can double-click the entry and the information is displayed in a message box.

PortInfoSearch2

Finally, in situations where you cannot run the tool yourself or if you want to have the information ‘offline’ then you can use the ‘Export App Info’ button. This button saves the tree as a CSV formatted file type which you can open for example in Excel. The export is saved in the folder location the executable is launched from.

Since this started as a tool-with-maximum-use-minimum-UI it is clear the tool can be improved a lot to be more comprehensive and user friendly, but it worked for me. Feel free to take the code and adjust it to your needs!

I hope it helps you guys getting a better understanding of the BizTalk applications you’re faced with 🙂

Greetings,

Jean-Paul

Didago IT Consultancy

Interesting rendez-vous with NDepend

This story starts in December 2008, but I found out only last June…..

Back in 2008 Patrick Smacchia of NDepend contacted me via my blog to ask me if I was interested in testing NDepend, but unfortunately I wasn’t notified of his message. Almost 4 years later (!) I came by accident across his message and decided to contact him and the request still stood Smile.

I already knew NDepend from early releases. Back then I ran into the famous “File or assembly name or one of its dependencies not found” exception and it was sometimes a challenge to find out which dependency was missing. Moreover because the dependencies also might have missing dependencies themselves, and so on. A first look at current NDepend made me happy because I saw the tool has evolved tremendously.

One of the reasons I started developing the BizTalk Software Factory is the fact that I think developers should be assisted in their work to build consistent, reliable and maintainable software. While looking at the features of NDepend I got enthusiastic about that part of the capabilities of NDepend.

This blog post is a review of some of the capabilities of NDepend. It is capable of much much more, so I’d like to refer to the website for additional information, documentation and instruction videos.

So of the list of features of NDepend, I like to focus on Code Quality, Code Query, Code Metrics, Explore Architecture, Detecting Dependency Cycles and Complexity and Diagrams.

If you’re involved in BizTalk development you probably know that tools like FxCop (now called Visual Studio Code Analysis) and things like Visual Studio Code Coverage are almost meaningless because most of the code is generated. But this doesn’t count for custom components like libraries, helper components, custom pipelines, custom functoids etc. It still is valuable to have tools checking the quality of your code and detect unwanted dependencies. But of course, the more custom written code you have, the more valuable tools become.

So lets start with some of the features that I like most from a code quality perspective. For this blog I use NDepend v4.0.2 Professional which I installed as Add-in for Visual Studio 2010. For my website I used the open source Orchard CMS and I took that code to do some testing.

In Visual Studio a new NDepend menu option shows up. With the option “Attach a new NDepend Project to VS Solution” you can add NDepend analysis to a project and it starts analyzing right away (if you leave the checkbox checked).

In the lower right corner of the Visual Studio a circle shaped indicator is visible after installing NDepend and after analyzing Orchard CMS the indicator is red. The results of the analysis are in the image below. Also clicking on the indicator displays the “Queries and Rules Explorer” which shows what rules actually are violated. This is a nice an quick overview of the violations.

 

In this example the “Methods too complex” violation is clicked, resulting in displaying the details in the “Queries and Rules Edit” dialog. By hovering over mehod “indexPOST”, a small dialog will be added on the right side of the explorer with details about the file and code metrics. Double clicking “indexPOST” will take you directly to the actual code. It is so easy to navigate to problem locations with this.

Because there are so many rules checked, it is also valuable to just take a look at the violations to learn from best practices. Besides the build-in rules, also custom queries over code are possible. All queries use LINQ style called CQLinq to retrieve information. All code metrics are written using the LINQ queries so it is easy to add your own (or take advantage of queries written by others).

 

Before NDepend I would have no idea how to find out the number of method in my code with more than 6 parameters, more than 10 declared variables or more than 50 lines of code. Or a combination of that. With this LINQ syntax it is a piece of cake.

For example a query to find all methods where the number of variables > 40(!) and are public.

from m in Methods where m.NbVariables > 40 && m.IsPublic select m
It is amazing to see what’s possible by just trying, assisted by intellisense!
Another really (and I mean really really) awsome feature is the Metric View, which is a visual representation of the code by module and size.

The size of every rectangle indicates the size of the method.

A second view uses LINQ queries again to visualize in this case the top 50 methods by number of lines of code. By visualizing this in the Metric View it becomes immediately clear where problems are located. Of course other metrics can be made visible in this way.

I’d like to end with another nice feature, the dependency graph and dependency matrix. The matrix shows an overview of the dependencies modules have on each other. Not only the dependencies between project components, but also dependencies on .NET system libraries are shown, which gives you insight into what assemblies actually are used in your project.

This view definitely will give you a better understanding of your code and might raise an eye brow if you find out you’re depending on an assembly that you’re not supposed to depend on. Especially if you’re responsible for a clean architecture in a large development team you need to verify the code doesn’t violate your architecture.

This tool is so comprehensive that I couldn’t possibly cover all features, but I’ve touched the ones that I’m most interested in. I’m really impressed by NDepend and I’m sure I’ll use it in upcoming projects. Being able to query the quality of your code is just awesome!

 

Didago IT Consultancy