-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.RuntimequestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Description
please file an issue on that with repro, that sounds like a bug
Originally posted by @krwq in #75452 (comment)
This makes migration from string to ReadOnlySpan a bit tricky.
Repro:
//Parse with null
string test = null;
ReadOnlySpan<char> ros = test.AsSpan().Trim();
try
{
double dVal = double.Parse(ros, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo);
}
catch (FormatException){}
try
{
double dVal = double.Parse(test, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo);
}
catch (ArgumentNullException) { }
//Parse with empty
string testEmpty = "";
ReadOnlySpan<char> rosEmpty = testEmpty.AsSpan().Trim();
try
{
double dVal = double.Parse(rosEmpty, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo);
}
catch (FormatException) { }
try
{
double dVal = double.Parse(testEmpty, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo);
}
catch (FormatException) { }
Metadata
Metadata
Assignees
Labels
area-System.RuntimequestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.