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) { }
Originally posted by @krwq in #75452 (comment)
This makes migration from string to ReadOnlySpan a bit tricky.
Repro:
//Parse with null