fix: avoid OverflowException when alignment width is int.MinValue
Parsing a message template whose alignment is "-2147483648" (int.MinValue) threw System.OverflowException from Math.Abs, violating the documented contract that syntactically invalid templates yield text tokens rather than throwing. Treat that alignment as text, matching how other alignment values that cannot form a valid width are already handled.
This commit is contained in:
1 parent
ec7d201361
commit
2125154397
2 files changed
+12
No files matched your search
@@ -379,6 +379,13 @@ public class MessageTemplateParserTests
|
||||
new TextToken("{Hello,10-1}"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AlignmentOfIntMinValueIsParsedAsText()
|
||||
{
|
||||
AssertParsedAs("{Hello,-2147483648}",
|
||||
new TextToken("{Hello,-2147483648}"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyAlignmentIsParsedAsText()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user