Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio add-in for validating string.Format method

string.Format is a very risky method. There are a lot of thing that could go wrong, without any compilation errors:

string.Format("{0{", text);
string.Format("{1}", text);
string.Format("(0)", text);
string.Format("{0}", text1, text2);

I'm looking for a way to find this problems in compilation time. If I remember correctly, Resharper find some of those errors, but it's too rich for my blood.

like image 234
HuBeZa Avatar asked Jan 12 '11 14:01

HuBeZa


1 Answers

Resharper does that for you -- even at edit time :-).

However be aware that things like

String.Format("{0} blabla", foo, bar);

Do not generate an error (after all, deciding to hide a value is perfectly fine).

like image 98
Sklivvz Avatar answered Oct 08 '22 22:10

Sklivvz