-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XmlWriter respects NewLineOnAttributes when writing xmlns (#81822)
* XmlWriter respects NewLineOnAttributes when writing xmlns * formatting
- Loading branch information
Showing
8 changed files
with
154 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/libraries/System.Private.Xml/tests/XmlWriter/WriteWithXmlnsNewLine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace System.Xml.XmlWriterTests | ||
{ | ||
public class XmlWriterTests_XmlnsNewLine | ||
{ | ||
[Fact] | ||
public static void WriteWithXmlnsNewLine() | ||
{ | ||
XmlDocument xml = new(); | ||
xml.LoadXml("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" height=\"10\"><g /></svg>"); | ||
|
||
XmlWriterSettings settings = new(); | ||
settings.NewLineOnAttributes = true; | ||
settings.NewLineChars = "\n"; | ||
settings.Indent = true; | ||
settings.IndentChars = " "; | ||
|
||
StringBuilder output = new(); | ||
using (XmlWriter writer = XmlWriter.Create(output, settings)) | ||
{ | ||
xml.Save(writer); | ||
} | ||
|
||
Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"10\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n height=\"10\">\n <g />\n</svg>", output.ToString()); | ||
} | ||
} | ||
} |