Different rules for private event declaration
Hello, I recently bought rehsarper and now trying to make it work with my own rules. I have for now one issue:
Private event declaration rule. Basically my codding standard looks:
private event CancelEventHandler _onCancel; //event declaration
and then
/// <summary>
/// Adds or removes Cancel event.
/// </summary>
[Category("Action")]
[Description("Cancel")]
public event CancelEventHandler Cancel
{
add { _onCancel += value; }
remove { _onCancel -= value; }
}
/// <summary>
/// Fires cancel event.
/// </summary>
/// <param name="e"></param>
protected virtual void OnCancel(CancelEventArgs e)
{
if (_onCancel != null)
{
_onCancel(this, e);
}
}
Is there any way to create separate rule for private event declaration? Since it should be treated as variable declaration not event.
The additional issue is is that resharper moves such declaration from top declaration section to events one.
Please sign in to leave a comment.
Hello Marcin,
You can add a custom rule for private events under 'Advanced settings...'
on a 'Naming Style' tab. Thank you!
Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Thank you.