C# Events

Topics: User Forum
Feb 14, 2014 at 1:55 PM
Is there anyway to avoid event fields appearing twice in the built help file.

In my class I declare a public event :
public event MyEventDelegate MyEventField;
The first occurrence is in the Fields section, where it gets a Red Summary entry saying [Missing <summary> documentation for "F:xxxxxxxx.MyEventField"]. I wouldn't expect an entry here, as the XML file contains an entry for "E:xxxxxxxx.MyEventField" identifying it as an event, although it is also a field in the class.

The second entry is in the Events section - where it is displayed correctly. This is the only entry in the help file I would expect.
best regards
Feb 14, 2014 at 3:15 PM
It sounds like you've got the Document Private Members and/or Document Private Fields options turned on in the Visibility category of project properties. Turn those off to hide the backing fields. If you really want them, you'll need to use the API filter to exclude the things you don't want to see.

Feb 26, 2014 at 10:49 AM
Thanks for the reply, sorry about the delay in getting back to you.

As the documentation being produced is for internal use only by our development team, then I do have the Private Members & Fields options turned on.

Is there a way to exclude the field from the Fields section, but keep it in the Events section - when I tried the API filter it was excluded from both sections.
Feb 26, 2014 at 7:38 PM
I'll have to check. It should be working as I described.

Feb 27, 2014 at 1:39 AM
The removal of the field and the event is a quirk caused by the way the API filter works. It works by removing members by name without regard to type or in the case of methods, their parameter list. Since your event and the backing field are named the same, it's removing both. You can see this as only one, not both, show up in the API filter editor dialog. If you follow convention and change the name of the delegate to MyEventHandler rather than MyEventDelegate, MRefBuilder will automatically remove the backing event field. It removes any field that has a type with a name ending in "EventHandler" to cover that case.

Feb 27, 2014 at 8:43 AM
Thanks Eric,
that resolved the problem.