Visual Studio-custom tool

Source: Internet
Author: User

What is custom tool? People familiar with Visual Studio may have noticed that since vs2002, the properties of the files in Solution Explorer have a custom tool attribute.

For example, in Vs, we create a dataset1.xsd file through the menu project> Add new item> DATA> dataset. At this time, we find that the custom tool attribute in the properties file of dataset1.xsd is msdatasetgenerator.

When we change the dataset1.xsd file, we find that the corresponding dataset1.designer. CS file will also generate corresponding updates.
If we delete this file and save dataset1.xsd again, we can see that dataset1.designer. CS appears again.
Then, we will delete the dataset1.designer. CS file again, remove the custom tool attribute in the properties file of dataset1.xsd, and save it again, but dataset1.designer. CS does not appear.

Similarly, * dbml files with custom tool attributes have the same features.

Therefore, we have reason to believe that the appearance of the *. Designer. CS file has a great relationship with the custom tool attribute of the corresponding file.

In fact, the custom tool attribute is used to process a file when it is saved. for example, generate the corresponding dataset1.designer according to the dataset1.xsd file. CS file. another common example is to generate a WebService proxy class based on WSDL.

Maybe, if we use this interface reasonably, we can leave a lot of time for our work.

 

The following are msdn information about this interface.

Implementing Single file generators:
Http://msdn2.microsoft.com/en-us/library/s686w8yb (vs.80). aspx

A custom tool-sometimes referred to as a single file generator-can be used to extend the Visual Basic, Visual C #, and Visual J # project systems in Visual Studio. A custom tool is a COM component that implements the ivssinglefilegenerator interface. using this interface, a custom tool transforms a single input file into a single output file. the result of the transformation may be source code, or any other output that is useful. two examples of custom tool-generated code files are code generated in response to changes in a visual designer and files generated using Web Services Description Language (WSDL ).

When a custom tool is loaded, or the input file is saved, the project system CILS the generate method, and passes a reference to a ivsgeneratorprogress callback interface, whereby the tool can report its progress to the user.

The output file that the custom tool generates is added to the project with a dependency on the input file. the project system automatically determines the name of the output file, based on the string returned by the custom tool's implementation of defaultextension.

A custom tool must implement the ivssinglefilegenerator interface. optionally, custom tools support the iobjectwithsite interface to retrieve information from sources other than the input file. in any case, before you can use a custom tool, you must register it with the system or in the Visual Studio local registry. for more information on registering custom tools, see registering single file generators.

 

Assembly: Microsoft. visualstudio. Shell. InterOP (in Microsoft. visualstudio. Shell. InterOP. dll)

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.