-
Notifications
You must be signed in to change notification settings - Fork 23
SA1213
ptittof57 edited this page Aug 15, 2015
·
5 revisions
<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.")]
- - SA0102 - Clean Install
- - Download
- - Documentation Rules - Layout Rules - Maintainability Rules - Naming Rules - Ordering Rules - Readability Rules - Spacing Rules - Suppressions
- - Adding a custom StyleCop settings page - Adding custom rule settings - Authoring a custom styleCop rule - Authoring rules metadata - Custom CSharp Language Service - Custom MSBuild Integration - Hosting StyleCop in a Custom Environment - Installing a Custom Rule - Integrating StyleCop Into Build Environments - Integrating StyleCop into MSBuild - Writing Custom Rules for StyleCop