Search code examples
.netstringinternationalizationlow-level

Getting all static (interned) strings from a .NET assembly (dll)


I wish to get a list of all strings that are used in a .NET assembly including the “static” values that local variables are set to, parameters passed to methods, fields at set to, etc.

I recall from something I read a long time ago that a .NET assembly contains a tables of all strings it uses (or they can be "interned")– or am I just dreaming?

Using .NET Reflector is a good ideal (thanks thijs), I will also have a look at its API if no one comes up with an already written tool.

(This is so I can write a tool to check we have not missed any strings that should be translated. I could process the C# source code, however I will then have to cope with Strings that are split over many lines, etc.)

I have just thought, I wish to exclude strings passed into CodeFlowException(), etc., so this is already getting more complex.

PS: if you can think of a better set of tags, please retag this question.


Solution

  • In the end I wrote a very simple C# parser that found the strings in the source code. This solved the problem I had and let me add “comments” to the strings to help the translators.

    The comments were just read from C# comments in a “magic format”

    (Sorry the parser is not good enough to allow anyone else to use it, it only just about works on my C# code base)