1

I'm using ReSharper and StyleCop to impose some naming conventions. I have a rule for a class name to start with an upper case. In some classes, however, I need to violate the rule (when naming classes that are direct map from my database I want them to have the names of tables, views and so on, and our convention is to start the name with lower case t_ for table, v_ for view).

I'm suppressing the warning using the [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter"] attribute. It works fine in one class. It doesn't in the other. Both classes are partial classes. In both cases I'm using the same attribute and the same message. But in one case I still can see ReSharper complaining.

This suppression works:

[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Reviewed. The name of the class resembles the name of the table in the database.")]
public partial class v_All_w_Status
{
    // ..
}

And this doesn't:

[SuppressMessage("StyleCop.CShrp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Reviewed. The name of the class resembles the name of the table in the database.")]
public partial class t_Programs
{
    // ..
}

I tried removing and adding suppressions again, but with no change in behaviour. Clearly, I'm missing something, but I cannot see what. Any help highly appreciated.

SOLVED:

In the second case there is a spelling error: it says CShrp instead of CSharp.

PiotrWolkowski
  • 8,408
  • 6
  • 48
  • 68
  • Are you sure it's the *same* warning? I can easily see 2-4 rule violations in the name, depending on rule base used. – nvoigt Nov 17 '14 at 14:48
  • Yes, in both cases the warning said: `class names begin with an upper-case letter: t_Programs`. Only in the latter case, after suppression, the warning is still there. – PiotrWolkowski Nov 17 '14 at 15:07
  • What happens if you select "Supress this warning" from the context menu again? Does it add a second supression attribute or does it add a R# style comment? – nvoigt Nov 17 '14 at 16:18
  • Ok, my mistake, I had `StyleCop.CSharp.NamingRules` spelled incorrectly. After suppressing it again R# adds a new, correctly spelled attribute. – PiotrWolkowski Nov 17 '14 at 17:11

0 Answers0