SA1305 - Rule changed/Feature request?

Jan 21, 2014 at 9:07 AM
We've upgraded a while ago from 4.3 to 4.7 and have been using it absolutely fine no problems!

We've had a new starter though recently and seen that he's been using variables like VB6 conventions of Hungarian notation 'strUsername' but StyleCop hasn't picked this up. I was "fairly" sure that it use to pick it up in 4.3 as we had to change a lot of our existing code to pick this up.

Has this rule changed to something else? I was wondering if we were missing something after the upgrade, or if this has always been the case with the rule. If it has always been the case, I wonder what we have changed that it's not picking these up any more :(
Jan 26, 2014 at 3:09 PM
From what I can see in the version history here on CodePlex, it looks like that rule has always only checked for 2-character hungarian notation.

I think the reason is the way that invalid prefixes are identified. There is a list of allowable prefixes, and any two-character prefixes that aren't in that list are rejected. It's fairly easy to identify allowable two-character prefixes ("is", "to", etc.), but gets a lot more difficult when dealing with three-character prefixes.

I think it'd be a good suggestion to also add a list of known hungarian notation prefixes ("str" is the only one I remember seeing in C# code).
Feb 4, 2014 at 9:49 AM
I must admit, I also wasn't able to find anything in the changelog to suggest it use to do three character prefixes either, it just became somewhat strange when a couple others in my organisation were under the impression that it use to pick those up.

I think having that prefix inclusion list (up to three characters) would be quite useful so we could mark things in. Coming from a VB6 application in house, a lot of our developers now doing C# run into bad habits and use Hungarian notation still and we don't pick it up till it's already committed and code reviewed. I'll give my vote if that's something that could be added please :)