CA2109 ReviewVisibleEventHandlers conflicts with Framework Design Guidelines?

In Framework Design Guidelines, Section 5.4 Event Design (p. 135), it states:

DO use a protected virtual method to raise each event.

...

protected virtual void OnAlarmRaised(AlarmRaisedEventArgs e) {

...

When I follow this guideline, FxCop 1.35 RC1 detects CA2109 ReviewVisibleEventHandlers. Is this guideline no longer valid?

Michael

[459 byte] By [MichaelGoldberg] at [2007-12-20]
# 1

This Framework Guideline is still valid.

Can you post the code that raises this violation? In the given example above, we won't fire on OnAlarmRaised. However, if it was declared like the following sample, then we would fire, as it appears to be an event handler:



protected virtual void OnAlarmRaised(object sender, AlarmRaisedEventArgs e)
{
}

DavidM.Kean-MSFT at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 2

You are correct - it is defined as in your sample.

Issue comes up when Component C listens to Component B which listens to Component C .B registers an event handler for events raised by A, and B converts the events and raises a new event to which C is listening. I was trying to preserve the original sender information so I passes the original sender along.

Michael

MichaelGoldberg at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...

Visual Studio Team System

Site Classified