Possible Duplicate:
Resharper string.format shortcut
In our large code base, unfortunately there are a lot of statements like this:
MessageBox.Show("Hello, " + userName + "!");
Obviously, this would be better to facilitate String externalisation:
MessageBox.Show(String.Format("Hello, {0}!", userName));
Is there any tool that can automate this job (convert string concatenations to String.Format)?
If not, I figure it would be necessary to find a parser that constructs a syntax tree for a given C# source file, find expressions that do string concatenations in this tree (does not seem easy) and convert the found occurences?
EDIT: DevExpress CodeRush does exactly what I want – pretty cool. But unfortunately it only works on the current source file and I have to click every occurence (or so it seems). I would like to do the operation on all of my source files (like with ‘Replace all’).
Have a look at DevExpress CodeRush. It allows to easily find and refactor these issues. Though I don’t know if you can automate the refactoring. ReSharper has a similar feature.