views:

72

answers:

1

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;
    }
}
A: 

Although sub-optimal, I found a way around this, which was to manually put the XML comments into the file that contains namespace-level documentation for the project, along these lines:

<member name="F:myCompany.Common.Collections.Generic.EventableCollection`1.Added">
  <summary>
    Auto-generated backing field for the <see cref="E:myCompany.Common.Collections.Generic.EventableSortedList`1.Added">Added</see> event
  </summary>
</member>

This then gives roughly what I needed.

Matt Whitfield