"Convert to string.format" quick-fix and internationalization

One of the most common warnings that comes from running Code Analysis is
that string.Format() should specify a format provider.

Right now, if you have the following in your code, and place your cursor
anywhere in the string, you get a pop-up quick fix that suggests converting
the statement to, among other things, a 'string.format' version:

string foo = "Some literal string: " + value;

Selecting that quick-fix will result in this:

string foo = string.Format("Some literal string: ", value); Of course, that code will immediately generate a new Code Analysis warning. It would be nice if there were some ReSharper option to specify that such transformations be made "international-correct" ... in other words, it should result in this: string foo = string.Format(CultureInfo.CurrentCulture, "Some literal string: ", value);

Even better would be after the transformation, having the "CurrentCulture"
be highlighted, so it's easy to specify "InvariantCulture" or any of the
other common or less-than-common options... since the correct one is
something that only the developer may know.

Given ReSharper 5.0's new internationalization features, this would be a
nice option to have.

If that's too much, at least have another quick fix pop up on string.Format
(when the cursor is on the Format, or just inside the opening paren) to
convert to CultureInfo.CurrentCulture, CultureInfo.InvariantCulture, etc...
and if that is present, I guess the quick fix could be to remove the culture
info (though I can't imagine why anyone would want to do that).

Comments?



Please sign in to leave a comment.