3.1. Setup the Software System

This section describes how the Sonargrah system is setup for the NHibernate project. As a precondition, ensure that NHibernate builds successfully in Visual Studio (or whatever you use for C# development). The tutorial is based on NHibernate master branch, checked out on 2019-02-11.

Sonargraph offers to import Microsoft Visual Studio C# Solution files. Select menu "File""New" and select the wizard "System based on C# Visual Studio Solution file". Specify the name of the directory of the Sonargraph system and where its files will be stored. It is a best practice to store the system close to the actual source code and place it under version control. Using a Quality Model is explained in Section 2.6, “Share Results” ; you can leave this option unchecked for now.

System based on C# Visual Studio Solution File
Figure 3.1. System based on C# Visual Studio Solution File


The next wizard page allows to specify the Microsoft Visual Studio Solution file and then shows the modules that will be imported. Select the configuration and platform combination that you want to apply. A warning will be displayed that one of the projects referenced in the solution file will be excluded from the analysis. This is expected, since it is a Visual Basic project that Sonargraph does not analyze.

Select C# Solution File, Configuration and Platform
Figure 3.2. Select C# Solution File, Configuration and Platform


The system creation works best, if the MSBuild executor is configured on the C# preference page. Sonargraph uses MSBuild to extract information about the referenced assemblies, project references, constants, included source files, etc. from the .csproj files. As MSBuild is executed for each .csproj file, the creation takes a couple of seconds. After the system creation was successful, it's now time to execute "refresh" via the left-most icon in the toolbar or via F5 to start the parsing. The whole "refresh" of the ~740k total lines of code including the parsing of the external assemblies and executing the analyzers to detect cycles and duplicate code blocks takes around 60 seconds on a Intel(R) Core(TM)i0-8950HK CPU @ 2.9 GHz.

The next step is to open the Issues view and examine the detected cycle groups and duplicate code block issues.

Select C# Solution File, Configuration and Platform
Figure 3.3. Select C# Solution File, Configuration and Platform


Related topics: