Browse Source

convert elements with no value to empty elements

pull/234/merge
Siegfried Pammer 14 years ago
parent
commit
17f8c8f1ef
  1. 16
      ILSpy.BamlDecompiler/BamlResourceEntryNode.cs
  2. 3
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

16
ILSpy.BamlDecompiler/BamlResourceEntryNode.cs

@ -3,11 +3,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.ILSpy.TextView; using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes; using ICSharpCode.ILSpy.TreeNodes;
@ -54,8 +55,21 @@ namespace ILSpy.BamlDecompiler
using (XmlBamlReader reader = new XmlBamlReader(bamlStream, new CecilTypeResolver(asm))) using (XmlBamlReader reader = new XmlBamlReader(bamlStream, new CecilTypeResolver(asm)))
xamlDocument = XDocument.Load(reader); xamlDocument = XDocument.Load(reader);
ConvertToEmptyElements(xamlDocument.Root);
output.Write(xamlDocument.ToString()); output.Write(xamlDocument.ToString());
return true; return true;
} }
void ConvertToEmptyElements(XElement element)
{
foreach (var el in element.Elements()) {
if (!el.IsEmpty && !el.HasElements && el.Value == "") {
el.RemoveNodes();
continue;
}
ConvertToEmptyElements(el);
}
}
} }
} }

3
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

@ -1057,9 +1057,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
private void ReadPropertyComplexEnd() private void ReadPropertyComplexEnd()
{ {
if (!(elements.Peek() is XmlBamlPropertyElement))
throw new InvalidCastException();
XmlBamlPropertyElement propertyElement = (XmlBamlPropertyElement) elements.Peek(); XmlBamlPropertyElement propertyElement = (XmlBamlPropertyElement) elements.Peek();
CloseElement(); CloseElement();

Loading…
Cancel
Save