Ciphra Ciphra - 7 days ago 5
C# Question

Surpressing CA-rules in Stylecop

I'm working down a list of stylecop-warnings, of which some I simply want to suppress. However, after working down the SA list with the help of StyleCop's own documentation, I found that the CA-warnings are not documented by StyleCop. I'm having a pretty hard time finding a list of CA-warnings and their rule-category/rule-longname, which I need to be able to suppress them (as stated by StyleCop)..

Specifically CA1822 is what I'm trying to find as of now. A "Back-up method", whom's execution is written like

this.MyList = this.MethodReturnsAList() ?? this.BackUpMethod();


is being flagged as 'never used'. I don't want to make the method static, so I figured I'd suppress the message to clear my log. According to the MSDN-page, it shouldn't pose any problems.

Any help as to where I could find CA-ruling descriptions would be much appreciated, though currently I'd settle for an alternative to making the warning disappear..

Answer

CA warnings are not Style Cop warnings. They are nothing but Code Analysis warnings. You can pretty much find the rule descriptions of them in MSDN itself. For this particular warning please refer CA1822: Mark members as static