Repository navigation
Add format methods - #13
LowieDelneste wants to merge 4 commits into
Conversation
|
We use this together with #15 in a local build, and it works well for us. There are two cases where the generated code doesn't fit the text. A fix with tests is on Dresel/ResXGenerator 1. A placeholder with a format, such as 2. A text whose placeholders skip an index gets a method that throws. public string Moved(object arg1, object arg2) => stringLocalizer["Moved", arg1, arg2];
The fix also ignores escaped braces: One more thing: the README says the option generates "both the existing property-style accessor and a parameterized overload". It generates only the method, since a property and a method can't share a name. |
Summary
This PR adds support for generating format-aware overloads for localizer members when a resource contains placeholders such as {0} or {1}.
Changes
GenerateFormatMethodsis enabled.GenerateFormatMethodsoption through the build props so it can be configured from project metadata.Why
This makes generated localizers more useful for string formatting scenarios and avoids generating redundant members for format-based resources.
Notes
The behavior is opt-in and controlled by the
GenerateFormatMethodssetting.