Storing CLR metadata in an "Oslo" Repository
Populating over 30 assemblies, 16,600 types and 162,000 methods from .NET Framework 2.0 assemblies into your repository !!
[Prep time]: 5 minutes [Ingredients]: Oslo SDK, CLR instances (.NET 2.0), SQL Server Reporting Services
Another interesting application that we have developed on top of “Oslo” Repository is ‘BuildLoader’.
BuildLoader is the application which has been developed for the purpose of facilitating the process of analyzing the metadata within and across assemblies. It shreds the metadata in an assembly and then loads them into a repository.
Currently, in our team, we are using BuildLoader to shred some main assemblies that are produced from the nightly build process. For each build, we shred the test assemblies and product assemblies into different folders in our repository. This is so that we can perform the analysis across between the test and product assemblies easier.
BuildLoader consists of the 3 main components – CLR Schema, CLR Loader and CLR Reports.
- CLR Schema: The Repository schema which contains a set of tables and views for storing the assembly metadata. This schema also contains a set of helper functions that are useful for text formatting (e.g. [Clr].[MethodToText] returns the full-qualified method name). Click here for more details on the Repository schemas.
- CLR Loader: This component is responsible for shredding the assemblies and then loading the assembly metadata into a repository. The dependent assemblies are also determined during the shredding process and are also loaded into the repository for the assembly referencing purpose.
- CLR Reports: A set of SQL Server Reporting Services (SSRS) reports which provide user-friendly interfaces for a user to browse through the assembly metadata in the repository. CLR Reports that we have developed consists of the following six reports.
- FolderContentReport: This report basically displays a list of the assemblies that are in the selected folder.
- AssemblyReport: The report which provides the high-level details of the assembly content. For example, the namespaces that are used within the selected assembly and the types in the assembly.
- SearchByNamespaceOrType: This report allows a user to search for a type using a type or namespace or keyword.
- CSharpTypeReport: This report provides the details of the selected type using the C# style.
- MethodReport: This report displays the methods and the number of times that they call or receive a call from the selected method.
- CalledMethodStatisticsReport: This report provides the bar graphs that display the number of calls made to and made by each method in the selected type.
BuildLoader has brought a number of benefits into our team. Having BuildLoader shredding and loading real data into a repository has helped us find and fix problems that customers will face. It also helped us discover holes in our documentation and guidance. Moreover, the test and product assembly metadata available allows us to perform the analysis such as the build content comparison. The called method statistics available from CLR Loader can be used to determine the areas in the product code that are still lack of testing. We use CLR Reports to get an overview of the build and the items within each assembly. For example, the CalledMethodStatisticsReport can provide us a rough estimation of the dependencies on the selected type in the selected assembly. This information is useful when there’s a need to re-design/ or refactor a component. The MethodReport and CSharpTypeReport are also particularly useful for debugging purpose. Using these two reports, a user can drill down to the method that is at the beginning and the end of a chain.
To get a similar experience to BuildLoader, install Oslo SDK and then install CLR instances (.NET 2.0) on top of “Oslo” Repository (comes with Oslo SDK). Then take a look at the CLR Reports under C:\Program Files\Microsoft Oslo SDK 1.0\Samples\Reports\. To give you some idea, this will populate over 30 assemblies, 16,600 types and 162,000 methods into your repository. This should be enough to keep you busy for a while :) Note that CLR schema is already comes with the default installation of an “Oslo” Repository.