How to suppress the StyleCop warning "SA1201: all methods should be placed after all properties".?

Possible duplicate:
How to suppress a StyleCop warning?

I am writing a group of methods that are a combination of private / public access and should be placed in the same region (using #region). I used the method mentioned in here , but I cannot get this warning suppressed. Please, help.

[Edit] I only need to suppress this specific warning, not the entire project / solution. But I want to know how to do it ^ _ ^

+2
c # stylecop visual-studio-2010
Jul 20 '10 at 7:49
source share
3 answers

Are you happy to disable the rule for the entire project? If so, see if this works for you: Enabling or disabling StyleCop rules

+1
Jul 20 '10 at 7:53
source share

An alternative to suppressing stylish style warnings is to use them better. There is a rule that will insist that you do not use regions (disabled by default). Without doing this, your question goes away.

Instead of using regions, use partial classes. Take your region to a new partial class.

This way you get style matching and functional separation of the code. The best of both worlds.

+1
Jul 29 '10 at 22:18
source share

In your case, the correct SuppressMessage attribute should look like this:

 [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess")] private void SomeMethod() { } 

Please note that you can put it on any other element (for example, on a class - then all such violations in the whole class will be suppressed).

I also agree that it is completely unclear what to write in these fields.

Actually, the first should be the full class name of the StyleCop analyzer and can be found from the source code (for example, from here ), the second should start with the rule code, then with a colon and the rule enumeration name (fortunately, it always looks like the rule name displayed in the parameter editor, but without spaces).

+1
Sep 19 '11 at 18:53
source share



All Articles