From c8a3f4c1d011fb8897a7889aaf67331165d2644b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 8 Oct 2019 15:35:35 +0200 Subject: [PATCH] Add basic support for inheritdoc --- ICSharpCode.Decompiler/NRExtensions.cs | 9 +++++++++ ICSharpCode.Decompiler/Xml/DocumentationElement.cs | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ICSharpCode.Decompiler/NRExtensions.cs b/ICSharpCode.Decompiler/NRExtensions.cs index 30ca90951..927af49cf 100644 --- a/ICSharpCode.Decompiler/NRExtensions.cs +++ b/ICSharpCode.Decompiler/NRExtensions.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; using System.Collections.Generic; +using ICSharpCode.Decompiler.Documentation; using ICSharpCode.Decompiler.TypeSystem; namespace ICSharpCode.Decompiler @@ -86,5 +87,13 @@ namespace ICSharpCode.Decompiler return base.VisitTypeDefinition(type); } } + + internal static string GetDocumentation(this IEntity entity) + { + var docProvider = XmlDocLoader.LoadDocumentation(entity.ParentModule.PEFile); + if (docProvider == null) + return null; + return docProvider.GetDocumentation(entity); + } } } diff --git a/ICSharpCode.Decompiler/Xml/DocumentationElement.cs b/ICSharpCode.Decompiler/Xml/DocumentationElement.cs index 454989cd2..c6637dbb8 100644 --- a/ICSharpCode.Decompiler/Xml/DocumentationElement.cs +++ b/ICSharpCode.Decompiler/Xml/DocumentationElement.cs @@ -185,7 +185,7 @@ namespace ICSharpCode.Decompiler.Xml foreach (var text in childTag.Children.OfType()) list.Add(new XmlDocumentationElement(text.Value, declaringEntity)); } else if (childElement != null) { - /*if (nestingLevel < 5 && childElement.Name == "inheritdoc") { + if (nestingLevel < 5 && childElement.Name == "inheritdoc") { string cref = childElement.GetAttributeValue("cref"); IEntity inheritedFrom = null; string inheritedDocumentation = null; @@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Xml } if (inheritedDocumentation != null) { - var doc = new AXmlParser().Parse(inheritedDocumentation); + var doc = new AXmlParser().Parse(new StringTextSource(inheritedDocumentation)); // XPath filter not yet implemented if (childElement.Parent is AXmlDocument && childElement.GetAttributeValue("select") == null) { @@ -220,12 +220,12 @@ namespace ICSharpCode.Decompiler.Xml return !(inheritedElement != null && doNotInherit.Contains(inheritedElement.Name)); }); - list.AddRange(CreateElements(inheritedChildren, inheritedFrom, inheritedDocumentation.ResolveCref, nestingLevel + 1)); + list.AddRange(CreateElements(inheritedChildren, inheritedFrom, crefResolver, nestingLevel + 1)); } } - } else {*/ + } else { list.Add(new XmlDocumentationElement(childElement, declaringEntity, crefResolver) { nestingLevel = nestingLevel }); - //} + } } } if (list.Count > 0 && list[0].IsTextNode) {