Can FxCop check my calls to String.Format etc. for parameter countmatch?

  • Thread starter Thread starter Uri Dor
  • Start date Start date
U

Uri Dor

Hi, everyone,
The question is whether there is (or can be) an FxCop rule that makes
sure I don't do this:
String.Format("{0}-{1}-{2}", 5);
Or similar things.

Some explanations:
1) of course I only mean cases where the format string is a constant
string literal in the code - that's 99% of the cases anyway
2) similar cases are Console.Write(), etc., I know
 
Uri,

I don't think that there is a rule in there for that. However, FXCop is
extensible, and you can easily write your own rules. Check out the
gotdotnet.com workspace for it, located at (watch for line wrap):

http://www.gotdotnet.com/team/fxcop/

Check out the section titled "FxCop User Samples".

Hope this helps.
 
Back
Top