-
If the value of a string is a number, i.e. 1234, the parsing will take it as null or empty. When adding any extra letter(s) i.e. 1234extra, the parsing is done correctly. Smart.Format version: 3.2.0 (throws exception) and 3.2.1 Framework version: net 6.0, net 7.0
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Are you using the |
Beta Was this translation helpful? Give feedback.
-
The issue as described does not go back to the The format string in the example will auto-select the formatter (implicitly). In order to distinguish null, string.Empty, or a another value, the best way is: // Explicitly let the ChooseFormatter do the job
Smart.Format("{0:choose(null|):null|empty|{}}", 1234);
// Result: "1234"
Smart.Format("{0:choose(null|):null|empty|{}}", "1234");
// Result: "1234"
Smart.Format("{0:choose(null|):null|empty|{}}", "");
// Result: "empty"
Smart.Format("{0:choose(null|):null|empty|{}}", default(object?));
// Result: "null" If it is only about different output for "null or empty" and other values, the Smart.Format("{0:cond:{} |is null or empty}", "");
// Result: "is null or empty" |
Beta Was this translation helpful? Give feedback.
-
The link to the dotnetfiddle answers the question. The change introduced in v3.2.0 was not intentional. |
Beta Was this translation helpful? Give feedback.
The issue as described does not go back to the
Parser
, but to theIFormatter
s.The format string in the example will auto-select the formatter (implicitly).
So the answer the question above is still relevant.
In your case, it looks like the
PluralLocalizationFormatter
kicks in, which leads to the results as described.If anything in the output is not as expected, it's always recommended to to use a named formatter.
In order to distinguish null, string.Empty, or a another value, the best way is: