3

We have been asked to provide all of the possible error messages in our code for support purposes.

Unfortunately they are not all located in resource files so I figure that if we can get a list of all of the strings in the app we can then filter out the error messages from there.

Is there anything that would let me do this in a C# app?

Cheers

0

4 Answers 4

7

How about using the find function like such alt text

You can also use regular expressions if you have pattern and be detailed in your search by changing the "Use" to "Regular Expressions"

Sign up to request clarification or add additional context in comments.

2 Comments

won't work if the string contains escaped double quotes : "foo\"bar"
@Thomas Levesque: I would say it doesn't matter because the pattern will find all lines containing a string literal (unless you want to do an automatic replace, which I would rather not want to happen).
3

If you have ReSharper 5 you can use their localization feature to help you do this.

Enable localization for your project, then right click the project and select Find Code Issues. It will list all instances of a string hardcoded into the application. (Unless you have Localizable(false) set)

Comments

1

If you can think of a consistent string that you use on each message line (eg "throw new exception(" or "MessageBox.Show(", it may be as simple as hitting Ctrl+Shift+F in Visual Studio (find in files), typing it in, then copying the results to a file.

Before you jump into Regex land, check this out: Regex to parse C# source code to find all strings

Comments

1

I'm sure there are some RegEx expressions or some such you could run on your code base and maybe catch all strings. Seeing as how this is a business requirement and you're likely to be repeating this in the future, I'd refactor to get all my error messages in a structured format first. Then, automate the analysis of the structured format. Resource files might be appropriate.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.