I’ve just spent about 30 minutes checking out the recently announced Microsoft Source Analysis for C#. I definitely love the idea, but I’m not sure I’ll be using it just yet. Here are some of my impressions (again, I haven’t spent a lot of time on it yet)…
All using directives must be placed inside of the namespace
Hmm, but VS itself violates that rule on every class we create…!
The property must not be placed on a single line. The opening and closing curly brackets must each be placed on their own line
Huh? But that an auto-implemented property. What would we want to split that into multiple lines?!
Variable names must not start with ‘m_’
Hmpf, that’s the standard with have here at the company…
A closing curly bracket must not be preceded by a blank line
Ok, this one I like.
Tabs are not allowed. Use spaces instead
Huh? Thanks, but no, thanks. I’ve seen a lot of people complaining online about this one too. What’s the problem with using tabs??
The call … must begin with ‘this.’…
Ah, I like that one. This is something we’ve made as part of our guideline here, but couldn’t use FxCop to trap for that, since the ‘this.’ doesn’t make into the IL.
Now, the problem here is that, again, the code that VS generates violates this rule all over the place, such as on the example below:
I’ll continue to use this tool to see if it’s going to stick with me. I’ve tried it on a very small project, and got 246 violations; the vast majority where produced by code generated by VS. On a big project, I’d probably end up with a LOT more violations, so I’m not sure I can live with that. I believe there is a way to disable some of the rules, but haven’t looked for it just yet…
Anyway, I do appreciate Microsoft releasing tools like this one. Hopefully, more and more developers will start paying more attention to how they write code.




Leave a Reply to neslihanCancel reply