SA1213 - Visual-Stylecop/Visual-StyleCop GitHub Wiki
<title>SA1213: EventAccessorsMustFollowOrder</title>
<script src="script/helpstudio.js" type="text/javascript"></script>
<script src="script/StandardText.js" type="text/jscript"></script>
<script type="text/jscript">WritePageTop(document.title);</script>
TypeName |
EventAccessorsMustFollowOrder |
CheckId |
SA1213 |
Category |
Ordering Rules |
An add accessor appears after a remove accessor within an event.
A violation of this rule occurs when an add accessor is placed after a remove accessor within an event. To comply with this rule, the add accessor should appear before the remove accessor.
For example, the following code would raise an instance of this violation:
publicevent EventHandlerNameChanged
{
remove { this.nameChanged -= value; }
add { this.nameChanged += value; }}
The code below would not raise this violation:
publicevent EventHandlerNameChanged
{
add { this.nameChanged += value; }
remove { this.nameChanged -= value; }
}
To fix an instance of this violation, place the add accessor before the remove accessor.
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1213:EventAccessorsMustFollowOrder", Justification = "Reviewed.")]