Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore whitespace text nodes when parsing projects #1187

Merged
merged 2 commits into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ public void Equality()
/// Check it will use large element location when it should.
/// Using file as BIZARRELY XmlTextReader+StringReader crops or trims.
/// </summary>
#if RUNTIME_TYPE_NETCORE
[Fact(Skip = "https://github.com/Microsoft/msbuild/issues/270")]
#else
[Fact]
#endif
public void TestLargeElementLocationUsedLargeColumn()
{
string file = null;
Expand Down Expand Up @@ -135,11 +131,7 @@ public void TestLargeElementLocationUsedLargeColumn()
/// Check it will use large element location when it should.
/// Using file as BIZARRELY XmlTextReader+StringReader crops or trims.
/// </summary>
#if RUNTIME_TYPE_NETCORE
[Fact(Skip = "https://github.com/Microsoft/msbuild/issues/270")]
#else
[Fact]
#endif
public void TestLargeElementLocationUsedLargeLine()
{
string file = null;
Expand Down
7 changes: 7 additions & 0 deletions src/XMakeBuildEngine/Xml/ProjectXmlUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ private static List<XmlElementWithLocation> GetChildElements(XmlElementWithLocat
break;

default:
if (child.NodeType == XmlNodeType.Text && String.IsNullOrWhiteSpace(child.InnerText))
{
// If the text is greather than 4k and only contains whitespace, the XML reader will assume it's a text node
// instead of ignoring it. Our call to String.IsNullOrWhiteSpace() can be a little slow if the text is
// large but this should be extremely rare.
break;
}
if (throwForInvalidNodeTypes)
{
ThrowProjectInvalidChildElement(child.Name, element.Name, element.Location);
Expand Down