Skip to content

Cleanup double parsing and formatting code in System.Private.Xml - #54103

Closed
huoyaoyuan wants to merge 8 commits into
dotnet:mainfrom
huoyaoyuan:xpath-double
Closed

huoyaoyuan wants to merge 8 commits into
dotnet:mainfrom
huoyaoyuan:xpath-double

Conversation

@huoyaoyuan

Copy link
Copy Markdown
Member

Size of Release build: 3078KB -> 3063KB

@ghost ghost added the area-System.Xml label Jun 12, 2021
@ghost

ghost commented Jun 12, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @buyaa-n, @krwq
See info in area-owners.md if you want to be subscribed.

Issue Details

Size of Release build: 3078KB -> 3063KB

Author: huoyaoyuan
Assignees: -
Labels:

area-System.Xml

Milestone: -


Converts a floating point number to a string according to XPath rules.
*/
public static string DoubleToString(double dbl)

@krwq krwq Jun 24, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to see some test cases making sure we return the same as we did before for all edge cases here. I do not feel confident double.ToString(CultureInfo.InvarianCulture) returns the same as this method (not without some kind of test cases reasurrance).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked deeply into the code yet, but the behavior looks to be changed. The old code doesn't seem to output e notations. But I'm also not sure what's the desired behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I prefer to split this change. We should document the changes in the issue and see what the spec says vs what is happening right now. If current behavior is not matching the spec and new one is then we can change it but let's have the issue first so we can see clearly what's happening and document why the change happens

// the error; if it does not signal the error, it must recover by converting the number to a string as if
// by a call to the 'string' function and inserting the resulting string into the result tree.
return XPathConvert.DoubleToString(dblVal);
return dblVal.ToString(CultureInfo.InvariantCulture);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest split this change into removing method by method. I.e. Remove just DoubleToString and add relevant test cases. And do so for all methods you're replacing here. If we regress here we'll need to revert entire changeset here as I doubt anyone will be willing to spend time investigating what went wrong otherwise.

@krwq krwq Jun 24, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for dead code you can just go ahead and remove it though)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm going to split this.

@huoyaoyuan huoyaoyuan closed this Jul 17, 2021
@huoyaoyuan
huoyaoyuan deleted the xpath-double branch July 17, 2021 13:46
@ghost ghost locked as resolved and limited conversation to collaborators Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants