The Code Index – Part 3 – Code samples for using indexed information

Importer

We have published two samples, on the Code Gallery showing how to get data from the code index.

The first sample, Code Index – How to get statistics about your code, shows how to retrieve some statistical information from the code index, and in particular:

  • The number of indexed assemblies
  • The namespaces defined in indexed assemblies
  • The number of types defined in the indexed assemblies, detailing the number of classes, interfaces, enumerations, structures, delegates (total, and public API only)
  • The number of indexed methods, fields, properties, events
  • The class having the most members
  • The number of assemblies which are referenced but not indexed
  • The test assemblies (the assemblies which defined test methods, using the MSTest attributes)
  • The assembly referencing the most assemblies
  • The assembly which is the most referenced (globally – this is probably mscorlib J, or among the indexed assemblies)
  • The number of inheritance relationships (excluding the inheritance from System.Object, which is not very interesting)
  • The most derived type
  • The most implemented interface
  • The number of method calls
  • The method calling the most methods
  • The method being called the most

Looking at the sample’s source code you will learn a lot on how to query the code index to answer your own questions.

 

The second example is Code Index – How to discover ignored tests. It shows how to write an useful tool (effectively used in my team) : you probably know that when using MSTest to build your suite of unit tests, you can add an attribute [Ignore] to tell the MSTest engine not to run a test (instead of commenting the test method). You may also use the attribute [WorkItem(id)] to link the unit test to a bug database (such as TFS) item, so that you can trace why a particular test has been marked as ignored. It is considered good practice to open a bug when you decide to ignore a test and to link the test to this bug. This way, after fixing the bug, the developer will remember to re-enable the test. This samples shows how to discover the ignored tests, and the ignored tests without work items. It produces an HTML report if the ignored tests

 

I’ll let you discover the samples, play with them, modify them. In my next posts, I’ll provide a bit more details about the query API.

0 comments

Discussion is closed.

Feedback usabilla icon