How to supress StyleCop warning "SA1201: All methods must be placed after all properties."? [duplicate]
Possible Duplicate:
How to suppress a StyleCop warning?
I'm writing a group of methods which are a mix of private/public and need to put into the same region (using #region). I used method mentioned in开发者_Python百科 here but I can not get this warning supressed. Please help.
[Edit] I need to supress this particular warning only - not for the whole project/solution. But I'm willing to know how to do that ^_^
Are you happy to disable the rule for the whole project? If so, see if this works for you: Enabling or Disabling StyleCop Rules
An alternative to suppressing stylecop warnings is to use them better. There is a rule that will insist that you do not use regions (disabled by default). By not doing so, your issue goes away.
Instead of using regions, use partial classes. Extract your region into a new partial class.
In this way you get stylecop compliance and code functional separation. The best of both worlds.
In your case, correct SuppressMessage
attribute should like like the following:
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess")]
private void SomeMethod()
{
}
Note that you can place it on any other element (e.g, on the class - then all similar violations in the entire class will be supressed).
I also agree that it's quite unobvious what to write in these fields.
Actually, the first one should be the fully qualified name of StyleCop analyser class and could be found from the source code (e.g. from here). The second one should start with rule code, then colon and the name of the rule enumeration (luckily, it always looks like the rule name displayed in the Settings Editor, but with no whitespaces).
精彩评论