Adding XML comments to .NET elements in UML models

You can add XML comments in two locations in the Properties view: on the Documentation page, or on the XML Comments page.

Before you begin

Either the UML-to-C# transformation or .NET WCF profile must be applied to the model.

In the Preferences window, expand Modeling > Miscellaneous and verify that the Display rich text in diagrams and documentation check box is cleared.

About this task

When you run the UML-to-C# Transformation, XML comments in the model are generated in the source code as XML tags and as text in special comment fields that directly precede the code block to which they refer to. When you run a C#-to-UML transformation, XML tags in the source code are generated as comments on the Documentation and the XML Comments pages in the Properties view.
Note: If XML comments appear in a code source file before a preprocessor directive, the XML comments are not generated in the model, because these areas are interpreted as user code sections.

To add XML comments to .NET elements by using the XML Comments page:

Procedure

  1. Create a model that includes .NET elements that support XML comments.
  2. In the model, select a .NET element.
  3. Position the cursor in the XML Comments page editor; then click a button to add the opening and closing tag of the corresponding XML tag. The attributes that are associated with the XML tag are also created.

What to do next

In C#, you can create documentation for code by including XML tags in special comment fields in the source code directly before the code block to which they refer to.

When code that contains XML comments is compiled with the /doc option, the compiler searches for all XML tags in the source code and creates an XML documentation file. To create the final documentation based on the compiler-generated file, you can create a custom tool.


Feedback