49 lines
965 B
Plaintext
49 lines
965 B
Plaintext
== Why is this an issue?
|
|
|
|
Events that are not invoked anywhere are dead code, and there's no good reason to keep them in the source.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
class UninvokedEventSample
|
|
{
|
|
private event Action<object, EventArgs> Happened; // Noncompliant
|
|
|
|
public void RegisterEventHandler(Action<object, EventArgs> handler)
|
|
{
|
|
Happened += handler; // we register some event handlers
|
|
}
|
|
|
|
public void RaiseEvent()
|
|
{
|
|
if (Happened != null)
|
|
{
|
|
// Happened(this, null); // the event is never triggered, because this line is commented out.
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove this unused event or invoke it.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 20 Jul 2015, 11:59:43 Tamas Vajk wrote:
|
|
\[~ann.campbell.2] looks good
|
|
|
|
endif::env-github,rspecator-view[]
|