XML Note Allows you to add structured documents in your code, and because this is the technique of C # first, Visual Basic programmers have been long. XML comments describe a wide variety of code elements, including classes, field members, methods, and enumerations, etc.
Once you have created an XML annotation that describes the code characteristics, when you continue to type code features in your editor, you will immediately get intelligent awareness of parameters and return values. Suppose you have a function prototype indicating the following signature:
Private function getcustomerdata
ByVal Customercode
AS
String)
AS Dataset
Set the code insertion point on this function declaration and type three small apostropters. Visual Basic will generate an XML annotation that matches the following function declaration, you can fill it like a form that populates a table. According to your function, suppose you fill your comment template into the following:
'' '
'' '
Returns a dataset for a single customer.
'' '
summary>
'' '
Customer Code as string
param>
'' '
DataSet for the support Customercode
.
Returns>
'' '
Resides in the application's data?
remarks> Now you type in this function name, you will get the complete intelligence of information about this function, parameters, and return values, as shown in Figure 5:
Figure 5 When you add an XML annotation for your code element, you can immediately get its intelligent awareness, just as this tool reminder is displayed.
If you are completing development under the collective collaboration, this is a key feature. You can generate a code document by inserting a structured XML comment in a source file. Also, an application's architect or development team leader can design an annotation of the original and give characteristics before implementing the code specific details. When the developer fills in the code according to the prototype, the intelligent perception can guide them to properly use the characteristics of the prototype.
The compiler will treat XML annotations as part of your code. The comment tag value shows the color of the comment, and if you do not have an XML annotation (the author means no design of the full function prototype, for example, the parameter list is given, "only Summary tag value will be displayed Complete XML annotation template (see Figure 6).
Figure 6 XML annotation and compiler, the code window has been integrated. This XML note on the FillDataGrid function returns to its summary line. If you put the function prototype
Customercode parameter name is changed
Customerid, the compiler will be on to get a green wavy line, warn your two parameter names match errors (see
Compiler WARNING Get more information).
When you create a project, Visual Basic automatically generates an XML document file. This file will appear in the application's output directory with assemblyname.xml for the file name (the file name is the name of your application, "注). Because this is an XML file, you can convert it into other output formats as you want. XML annotations greatly reduce the workload of documentation for code, whether you are intelligent in the code, or you create a code document that is generated after the project is created. @ 以下 below is original for users to reference @
XML Comments
XML comments allow you to add structured documentation to your code, and have been the envy of Visual Basic developers because C # got them first. XML comments can describe a variety of code elements including classes, fields, methods, and enumerations.
Once you create an XML comment describing a code feature, you immediately get IntelliSense on parameters and the return type when you type the code feature in the editor Assume you have a function prototype with the following signature.:
Private function getcustomerdata
ByVal Customercode
AS
String)
AS Dataset
Place the code insertion point on the line above the function declaration and type three single-quote characters. Visual Basic generates an XML comment template matching the function declaration that you can tab through and fill out like a form. Assume you fill the comment template for Your Function Like SO:
'' '
'' '
Returns a dataset for a single customer.
'' '
summary>
'' '
Customer Code as string
param>
'' '
DataSet for the support Customercode
.
Returns>
'' '
Resides in the application's data?
remarks>
WHEN You Type this function name elsewhere in your code, You'll Get Full IntelliSense on the function summary, parameters, and return value as shown in Figure 5.
Figure 5. This Tool Tip Shows The Immediate IntelliSense Feedback You get when you add xml comments to your code Elements.
This is a key feature in corporate and team environments. You can generate code documentation from the structured XML comments inserted in your source files. Also, an application architect or developer lead can prototype and comment features before implementation. As developers write code using the prototype Objects, IntelliSense Guides Them in Proper Use of the features.
XML comments are treated as an integral part of your code by the compiler. The comment tag values are colored as comments, and if you collapse outlining on an XML comment, only the summary tag value displays in place of the whole XML comment template (see Figure 6).
Figure 6. XML Comments Are Fully Integrated with The Compiler and Code Window. The XML Comment On The FillDataGrid Function Is Collapsed to ITS Summary Line.
IF you change the name of the
Customercode Parameter in The Function Prototype To
Customerid, The Compiler Adds A Green Squiggly Line Under The Tag As a warning That Two Names Are Mismatch (See Section On
Compiler WARNINGS for more.
Visual Basic automatically generates an XML documentation file when you build the project. This file appears in the application output directory as AssemblyName.xml. Because this file is XML, you can easily transform it into other output formats as needed. XML comments make it much Easier And More Convenient To Generate Documentation For your code, Both As IntelliSense While You're Coding, And as Code Documentation Once You Build your application.