Skip to content

Commit

Permalink
Fix #181: XML Processing instructions changed automatically (#215)
Browse files Browse the repository at this point in the history
* Use XmlNode.Name in PI-Processing

relates Issue #181

* Add test case based in Issue #181

Extended bug scenario by using multiple processing instructions at once.

* Update handling of process instructions

* Remove unnecessary whitespace
* Reduce test-files to its minimum

Use interpolation instead of String.Builder
  • Loading branch information
renao authored and grochocki committed Dec 3, 2019
1 parent f0548bd commit eb43352
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Process(XmlReader xmlReader, StringBuilder output, ElementProcessCon
output.Append(Environment.NewLine);
}

output.Append(currentIndentString).Append("<?Mapping ").Append(xmlReader.Value).Append(" ?>");
output.Append($"{currentIndentString}<?{xmlReader.Name} {xmlReader.Value}?>");
}
}
}
8 changes: 7 additions & 1 deletion XamlStyler.UnitTests/FileHandlingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public void TestAttributeOrderRuleGroupsOnSeparateLinesHandling()
this.DoTest(stylerOptions);
}

[Test]
public void TestProcessingInstructionHandling()
{
this.DoTest(this.GetLegacyStylerOptions());
}

[Test]
public void TestXmlnsAliasesHandling()
{
Expand Down Expand Up @@ -459,7 +465,7 @@ private void DoTestCase<T>(
[System.Runtime.CompilerServices.CallerMemberName] string callerMemberName = "")
{
FileHandlingIntegrationTests.DoTest(
stylerOptions,
stylerOptions,
Path.Combine("TestFiles", callerMemberName),
testIdentifier.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true"?>
<?Mapping compile="true"?>
<XmlRoot />
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true"?>
<?Mapping compile="true"?>
<XmlRoot />
6 changes: 6 additions & 0 deletions XamlStyler.UnitTests/XamlStyler.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
<None Include="TestFiles\TestAttributeIndentationHandling_0.expected">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\TestProcessingInstructionHandling.expected">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\TestProcessingInstructionHandling.testxaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\TestSingleLineNestedMarkupExtensions.expected">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down

0 comments on commit eb43352

Please sign in to comment.