XML comments on delegate declared events
- by Matt Whitfield
I am visiting some old code, and there are quite a few events declared with delegates manually rather than using EventHandler<T>, like this:
/// <summary>
/// Delegate for event Added
/// </summary>
/// <param name="index">Index of the item</param>
/// <param name="item">The item itself</param>
public delegate void ItemAdded(int index, T item);
/// <summary>
/// Added is raised whenever an item is added to the collection
/// </summary>
public event ItemAdded Added;
All well and good, until I come to use sandcastle to document the library, because it then can't find any XML comments for the private Added field that is generated by the event declaration. I want to try and sort that out, but what I would like to do is either:
Get sandcastle to ignore the auto-generated private field without telling it to ignore all private fields entirely
or
Get XML comments generated for the private field
Is there any way of achieving this without re-factoring the code to look like this:
/// <summary>
/// Delegate for event <see cref="Added"/>
/// </summary>
/// <param name="index">Index of the item</param>
/// <param name="item">The item itself</param>
public delegate void ItemAdded(int index, T item);
/// <summary>
/// Private storage for the event firing delegate for the <see cref="Added"/> event
/// </summary>
private ItemAdded _added;
/// <summary>
/// Added is raised whenever an item is added to the collection
/// </summary>
public event ItemAdded Added
{
add
{
_added += value;
}
remove
{
_added -= value;
}
}