From 565f726ccdecf7027878b0458c42f459736b20a6 Mon Sep 17 00:00:00 2001 From: Vaughan Woodzell Date: Tue, 30 Apr 2013 15:26:33 -0600 Subject: [PATCH] Correct node ordering when reading markup extensions. --- .../XmlBamlReader.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 675d7c653..672d1a198 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1106,7 +1106,16 @@ namespace Ricciolo.StylesExplorer.MarkupReflection XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Complex, propertyElement.PropertyDeclaration); property.Value = sb.ToString(); - nodes.Add(property); + + // insert the replacement property after the last attribute of the parent element + int elementIndex = nodes.IndexOf(propertyElement.Parent); + int attributeIndex; + for (attributeIndex = elementIndex + 1; attributeIndex < nodes.Count; attributeIndex++) + { + if (!(nodes[attributeIndex] is XmlBamlProperty) && !(nodes[attributeIndex] is XmlBamlSimpleProperty)) + break; + } + nodes.Insert(attributeIndex, property); } }