Update:
Looks like I was wrong again. (You know what they say about assuming?) Reflector is an even greater tool than I first realized: not only does it show the classes in an assembly, it also shows the resources for the assembly; something my eye does not see and brain does not look for, because I just haven’t been in the situation to really use them. Anyway, it shows them and every assembly in the framework that I looked at (um, two of them) have resources that are filled with? Exception messages. Interestingly, I found a way around the FxCop violation, but you shouldn’t use it unless you really, really intend to fix it later. Do you? Ok, here it is:
… = new MyException( String.Format( System.Globalization.CultureInfo.CurrentCulture, “my exception message“ ) );
End Update
I’ve been using FxCop a lot lately to fix up some of the templates in CodeSmith and some of my code at work. I get this violation a lot:
Most of the cases, all if I’m not mistaken, are for messages in Exception constructors. This got me wondering:
If I install the .NET framework in French (or German, or Italian, or Thai, or Chinese, or Brazilian Portuguese or …) do I get stack traces from thrown exceptions in that language?
If the answer is no (that’s what I think it is; especially after inspecting the framework with Reflector), FxCop should check to see to which method the literal is being passed, shouldn’t it? And if it should, I should just ignore those violations when I pass a string to an Exception constructor.
This is a tough one: 30 jk.ca points to whomever gets it. I’ll update this post once the answer is found. Good luck. 🙂