VSdocman can document normal .NET properties easily. You just place your XML comments before property code. This works fine for dependency properties too and even when your property is both, a dependency property and an attached property. In all these cases the property is explicitly defined in the code and there is no problem placing the XML comments.
If you however have pure attached property, there is no place in the code you can add the XML comments. There's only attached property identifier field and getter/setter methods. All of them have their own XML comments used in their own documentation topics. VSdocman solves this problem by taking XML comments from external XML files. You need to create these files manually. The mechanism is the same as if <include> tag was used. The external XML file needs to meet the following conditions:
•It must be placed in the same directory as the source code file with the identifier field.
•Its name must be the same as name of the source code file with the identifier field, only the extension should be changed to XML. So if you have MyClass.cs or MyClass.vb source code file, the XML file must be placed in the same directory and must be named MyClass.xml.
•The XML file may contain comments for multiple attached properties defined in the same source code file. Member's name attribute must have value which equals to a full cref identifier of the attached property, as described in <include> tag help.
Let's have the following attached property named AttachedOnly.
In MyClass.vb:
Visual Basic
|
Copy Code
|
''' <summary>
''' Identifier field for <see cref="P:AttachedOnly" /> property.
''' </summary>
Public Shared ReadOnly AttachedOnlyProperty As DependencyProperty = _
DependencyProperty.RegisterAttached("AttachedOnly", _
GetType(String), _
GetType(MyClass), _
New FrameworkPropertyMetadata(Nothing, _
FrameworkPropertyMetadataOptions.AffectsRender Or FrameworkPropertyMetadataOptions.AffectsMeasure _
))
''' <summary>
''' Setter for <see cref="P:AttachedOnly" /> property.
''' </summary>
Public Shared Sub SetAttachedOnly(ByVal element As UIElement, ByVal value As String)
element.SetValue(AttachedOnlyProperty, value)
End Sub
''' <summary>
''' Getter for <see cref="P:AttachedOnly" /> property.
''' </summary>
Public Shared Function GetAttachedOnly(ByVal element As UIElement) As String
Return CType(element.GetValue(AttachedOnlyProperty), String)
End Function
|
In MyClass.cs:
C#
|
Copy Code
|
/// <summary>
/// Identifier field for <see cref="P:AttachedOnly" /> property.
/// </summary>
public static readonly DependencyProperty AttachedOnlyProperty =
DependencyProperty.RegisterAttached ("AttachedOnly",
typeof(string),
typeof(MyClass),
new FrameworkPropertyMetadata(null,
FrameworkPropertyMetadataOptions.AffectsRender |
FrameworkPropertyMetadataOptions.AffectsMeasure));
/// <summary>
/// Setter for <see cref="P:AttachedOnly" /> property.
/// </summary>
public static void SetAttachedOnly(UIElement element, string value)
{
element.SetValue(AttachedOnlyProperty, value);
}
/// <summary>
/// Getter for <see cref="P:AttachedOnly" /> property.
/// </summary>
public static string GetAttachedOnly(UIElement element)
{
return Convert.ToString(element.GetValue(AttachedOnlyProperty));
}
|
The MyClass.xml file contains the following:
Example
|
<?xml version="1.0" encoding="utf-8"?>
<doc>
<members>
<member name="P:MyNamespace.MyClass.AttachedOnly">
<summary>
External summary for attached property.
</summary>
<remarks>
This are external remarks for the property.
</remarks>
</member>
</members>
</doc>
|
|
|