Browse Source

Add XmlException handling to AddXmlDocumentationTransform

pull/850/head
Siegfried Pammer 8 years ago
parent
commit
ae01bfabb4
  1. 8
      ICSharpCode.Decompiler/CSharp/Transforms/AddXmlDocumentationTransform.cs

8
ICSharpCode.Decompiler/CSharp/Transforms/AddXmlDocumentationTransform.cs

@ -19,6 +19,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml;
using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Documentation; using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -34,6 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{ {
if (!context.Settings.ShowXmlDocumentation) if (!context.Settings.ShowXmlDocumentation)
return; return;
try {
var xmldoc = XmlDocLoader.LoadDocumentation(context.TypeSystem.ModuleDefinition); var xmldoc = XmlDocLoader.LoadDocumentation(context.TypeSystem.ModuleDefinition);
if (xmldoc == null) if (xmldoc == null)
return; return;
@ -55,6 +57,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
InsertXmlDocumentation(entity, new StringReader(doc)); InsertXmlDocumentation(entity, new StringReader(doc));
} }
} }
} catch (XmlException ex) {
string[] msg = (" Exception while reading XmlDoc: " + ex.ToString()).Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var insertionPoint = rootNode.FirstChild;
for (int i = 0; i < msg.Length; i++)
rootNode.InsertChildBefore(insertionPoint, new Comment(msg[i], CommentType.Documentation), Roles.Comment);
}
} }
static void InsertXmlDocumentation(AstNode node, StringReader r) static void InsertXmlDocumentation(AstNode node, StringReader r)

Loading…
Cancel
Save