views:

338

answers:

5

I need to move all the hard coded strings in my source code in .resx files. There is a tool that could help me find all the hardcoded strings within C# code?

+2  A: 

You could always do a search for the " sign in all the .cs files. That should get you to most of them, without too much noise.

David Hedlund
Well, this is a bit of brute force becase of comments for example. Still I would recommend pairing it with assignment operator to narrow the searches - or use additional filtering - thank got there's linq:) . Use some powershell script or write a simple cs program to make is for you.Generally making a reg expression to find all
luckyluke
+1  A: 

Resharper 5.0 (Beta) allows you to move strings to resources (it has built in Localization feature). Give it a try. Beta works fine, i use it every day and have no problems. Best of all it's free until out of beta. I even recommend using night builds as they seem to be stable.

Software localization and globalization have always been tough and at times unwanted tasks for developers. ReSharper 5 greatly simplifies working with resources by providing a full stack of features for resx files and resource usages in C# and VB.NET code, as well as in ASP.NET and XAML markup.

Dedicated features include Move string to resource, Find usages of resource and other navigation actions. Combined with refactoring support, inspections and fixes, you get a convenient localization environment.

MadBoy
Good heads-up, but I don't think it helps you find them in the first place, which is what the question is mainly asking.
rohancragg
Correct rohancragg
Cornel
A: 

Some are found by FxCop. Not sure what its limits are, I think it depends on parameter and property names (eg: a property called "Text" is considered to be localized).

Stefan Steinegger
+3  A: 

ReSharper 5 is obvious a choice, but many tips must be set so as to achieve your goals,

  1. turn on solution wide analysis.
  2. go to ReSharper|Options|Inspection Severity and make Element is localizable rule "Show as error".
  3. go back to Solution Explorer and click on the project (csproj).
  4. in Properties panel under ReSharper category, set Localizable to Yes, Localizable Inspector to Pessimistic.

Then you can find almost all you need in Errors in Solution panel.

Hope this helps.

Lex Li