-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with PluralLocalizationFormatter.TryEvaluateFormat in v3.2.0 #329
Comments
Hi, could you provide sample data that allows for figuring out the types that are included in the anonymous type for |
It's all Strings, except for the Count, which is an int. But it's really just the category part that causes troubles, so this is all it takes to trigger the exception: Smart.Format("{Category: [{}]|}", new { Category = "test" }); |
I see, that's fine. The format string is not wrong, but it (unintentionally) turned to be ambiguous with a fix to The automatic formatter discovery is really nice and convenient, but there are edge cases where another formatter is selected than expected. We have 2 recommendations:
3 simple options to resolve your issue:
|
Also, we'll improve auto-detection in |
Current behavior, introduced in v3.2.0: When PluralLocalizationFormatter.CanAutoDetect == true, values not convertible to decimal will throw then trying to IConvertible.ToDecimal(...) New behavior: When PluralLocalizationFormatter.CanAutoDetect == true, for values not convertible to decimal, IFormatter.TryEvaluateFormat(...) will return false
Maybe you'd like to evaluate the build of the latest PR |
… values not convertible to decimal (#330) * Resolves #329 Current behavior, introduced in v3.2.0: When PluralLocalizationFormatter.CanAutoDetect == true, values not convertible to decimal will throw then trying to IConvertible.ToDecimal(...) New behavior: When PluralLocalizationFormatter.CanAutoDetect == true, for values not convertible to decimal, IFormatter.TryEvaluateFormat(...) will return false * Make PluralLocalizationFormatter.TryGetDecimalValue static
Seems like I was a bit late. |
Not at all, thanks a lot for your hint 👍 |
Given the following format string:
{Game}{Category: [{}]|} by {Players} - {Hashtag}
Used like this:
This works perfectly fine with SmartFormat 3.1.0, but after upgrading to 3.2.0, it raises the following exception:
I'm not seeing anything in the 3.2.0 changelog that'd indicate a change like this, so this seems like a regression to me.
(Or the format string is wrong? It looks correct to me though, and worked fine for a really long time now.)
The text was updated successfully, but these errors were encountered: