HEADLINE: If I use the Entity Framework (Self Tracking Entities or EntityObjects) templates, how can I add XML Comments so that I can use Sandcastle and Sandcastle Help File Builder to generate the documentation for my libraries? Is there a way to modify the T4 templates so that I can access the property documentation? (The answer is yes)
This uses Microsoft Visual Studio 2010 Beta 2, Microsoft ADO.NET Entity Framework (EF) Feature Community Technology Preview 2, Sandcastle, and Sandcastle Help File Builder (SHFB)
Details:
If I turn on XML Documentation:
Then a comment like this:
- /// <summary>
- /// Represents a book in the library.
- /// </summary>
- public partial class Book
Will be output into the .xml file.
I tried putting documentation into the Model. Here is the designer view:
However, these never seem to be output as the publicly visible comments (///) in the generated code.
To do that, add this in the template immediately above the property:
- <#if (!ReferenceEquals(edmProperty.Documentation, null))
- {
- #>
- /// <summary>
- /// <#=edmProperty.Documentation.Summary#> – <#=edmProperty.Documentation.LongDescription#>
- /// </summary>
- <#}#>
After doing this I got the following in my Book.auto.cs class:
- /// <summary>
- /// ISBN – International Standard Book Number
- /// </summary>
- [DataMember]
- public string ISBN
Then my documentation can look like this:
The above was created using Sandcastle and the Sandcastle Help File Builder.
Leave a Reply