How to improve string resources usability

(cross-posted from NETFx)

Somehow we ended up with a stagnating code generator for .resx built-in VS and we just got used to its shortcomings.

Namely:

  1. No support for formatting arguments: while you can set your resource string value to contain {0} and the like, the generator knows nothing about them. Meaning you have to write the repetitive and boring formatting code on the caller side. For example, for a resource string with Name=”User_InvalidEmail” and Value=”Provided email ‘{0}’ is invalid.”:

    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.User_InvalidEmail, email)); ...

Read full article

No Comments