Custom Visual Studio intelliitrace smart tracking

Source: Internet
Author: User

Introduction

We know that Vistual Studio 2010 provides a new intelligent tracking technology for intelliitrace, which helps us quickly view important events that have occurred for a period of time without the need for single-step debugging, for more information about smart tracking, see use intelliitrace to debug applications. But the built-in events are often not enough. We want to extend these events. This article describes how to customize these events.

Requirements

In a developed Web project, an important interaction between the client and the server is to pass the "Change set" Web request, which is a key event in program execution. Although smart tracking provides us with Web Request events, there are too many events, and we cannot apply the key session IDs and xml data for the change set events. Therefore, I want to customize my own "Apply ChangeSet" event.

It seems that the customized effect is as follows:

On the intelliitrace panel of Visual Studio, you can see the custom "Apply ChangeSet" event. In addition, I also want to see the relevant data in the application change set:

My machine installed Vistual Studio 2011 beta, so the screen may be slightly different from Visual Studio 2010.

Custom tracing plan collectionplan. xml

What you need to know is that we do not need to modify the source code to complete the event record. VS uses a collectionplan. xml Description specifies the tracing method. We need to modify this file to complete customization. It usually exists:

C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ intelliitrace \ 11.0.0 \ en

Different Versions of Visual Studio have different paths, so you need to search for collectionplan. xml by yourself. I directly modified this file. I didn't find a method to create another file without interrupting this file. Please reply to me if you know.

After opening the file, we first add the "classification" and "component" data, so that we can change the data first and then look at the effect.

Create your own category in Categories. To be honest, I don't know the difference between id and _ locID.

Add the dll you want to track in ModuleSpecifications and write the file name. You don't need to worry about the version and path.

Then add the event you want to track in DiagnosticEventSpecifications, which defines the method you want to track and the variables you want to record.

I will not describe it in a simple way. I will also draw images from the gourd tree. I will explain how complicated it is.

CatrgoryId and ModuleSpecificationId

CatrgoryId is the category id, and ModuleSpecificationId is the Id corresponding to the dll we filled in earlier. Do not make a mistake. We can also see that a category can contain multiple dll events, or a dll can send events of different categories, which is completely planned by you.

MethodId:

I guess it is the method signature. Anyway, I just fill in according to the rules. Multiple parameters are separated by commas. If you do not return a value, enter System. Void.

Invalid description and LongDescription

As the name suggests, one is short description and long description, and the short description is displayed in the title. You need to click the long description to see it. Therefore, the short description should be simplified and key data should be displayed. He supports variables, just like the {0} above and {1} above. He points to the index of the DataQueries set.

DataQuery

Here you can define the variable you want to record. The first index indicates where you set the value, 0 indicates this, and 1 indicates each parameter.

If the object of the value is a simple type, for example, the session obtained here is a string, the query attribute is null. if the source of the value is an object, you can use query to obtain the field values. For example, in SqlCommand, its long description outputs the connection string associated with the command, as shown in the following code:

Obviously, it can use private variables and continuously access them at a level. In addition, you do not need to be careful when _ connection is null, resulting in expression failure.

As for how to obtain the return value )... I cannot find it.

Obtain value through programming

If you look at other configurations, you may also be able to obtain values in programming, for example:

This Microsoft. VistualStudio. DefaultDataQueries. dll is also a program written in. net. You can see the implementation method after decompiling and implement the IProgrammableDataQuery interface. Of course, the function is more powerful. For example, you can obtain the returned value and format the data yourself.

View results in Visual Studio

Everything is ready. After saving the file, you need to restart Visual Studio. First, Click Tools-> options-> smart tracking. You can see our custom category.

Now, when you debug the code, you can see the intercepted events in InterlliTrace.

Pleasant debugging

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.