I have a MessageBox in C# like so:
MessageBox.Show("Message Here", "Title Here", MessageBoxButtons.OK, MessageBoxIcon.Error);
Under my Message and Title I have the option in ReSharper to Move to Resource and it wants to move these values to the Resources.resx file and then just refer to them in my MessageBox.
Is this overkill, not what this feature is really for or a good idea?
Thanks
I would say it is not overkill. Even if you are 100% certain (can you really be?) that you never need to provide your application in a different language, it makes the code much more readable, if it is not “littered” with strings/messages.
Personally, I found out that I started writing much better (error) messages, once I moved all of them to resources. Before that I was trying too hard to make them “look nice” in the code, than to provide a really meaningful message.
Of course, there are also drawbacks. While navigation usually doesn’t suffer (ReSharper’s “Go To Definition” works equally well with string resources), you don’t get checking of
string.Formatparameters. Again, for me that was worth the price of having (arguably cleaner code and better messages). YMMV.