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

Do not reveal implicit elements through RawXml #1416

Merged

Conversation

rainersigwald
Copy link
Member

The initial implementation caused errors when editing a project in Visual
Studio. The Roslyn Project System uses Project.Xml.RawXml to decide what
to show to the user, and handles edits by saving that file. When RawXml
had _Implicit elements, that made the first save create an invalid project
with a literal _Implicit attribute in its imports (as well as imports from
both the Sdk attribute and the now-present Import elements).

To fix this, do the same transformation for RawXml that was being done for
Save.

The initial implementation caused errors when editing a project in Visual
Studio. The Roslyn Project System uses Project.Xml.RawXml to decide what
to show to the user, and handles edits by saving that file. When RawXml
had _Implicit elements, that made the first save create an invalid project
with a literal _Implicit attribute in its imports (as well as imports from
both the Sdk attribute and the now-present Import elements).

To fix this, do the same transformation for RawXml that was being done for
Save.
@@ -1785,6 +1779,20 @@ public void Save(Encoding saveEncoding)
#endif
}

private XmlDocument RemoveImplicits()
Copy link
Contributor

Choose a reason for hiding this comment

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

If this turns out to be a hot path, then the ProjectRootElement could be made aware if it has implicit elements and skip this call when it doesn't.

This fixes unit test failures that arose because cloning the XmlDocument
caused a spurious `\n` character to be inserted after the XML declaration
tag in the saved output.
@rainersigwald rainersigwald merged commit 36be242 into dotnet:vs15-rc2 Dec 1, 2016
@rainersigwald rainersigwald modified the milestone: MSBuild Sdks Dec 4, 2016
@rainersigwald rainersigwald deleted the sdk-imports-virtual-elements branch July 5, 2017 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants