Browse Source

Add basic support for inheritdoc

pull/1654/head
Siegfried Pammer 6 years ago
parent
commit
c8a3f4c1d0
  1. 9
      ICSharpCode.Decompiler/NRExtensions.cs
  2. 10
      ICSharpCode.Decompiler/Xml/DocumentationElement.cs

9
ICSharpCode.Decompiler/NRExtensions.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler namespace ICSharpCode.Decompiler
@ -86,5 +87,13 @@ namespace ICSharpCode.Decompiler
return base.VisitTypeDefinition(type); 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);
}
} }
} }

10
ICSharpCode.Decompiler/Xml/DocumentationElement.cs

@ -185,7 +185,7 @@ namespace ICSharpCode.Decompiler.Xml
foreach (var text in childTag.Children.OfType<AXmlText>()) foreach (var text in childTag.Children.OfType<AXmlText>())
list.Add(new XmlDocumentationElement(text.Value, declaringEntity)); list.Add(new XmlDocumentationElement(text.Value, declaringEntity));
} else if (childElement != null) { } else if (childElement != null) {
/*if (nestingLevel < 5 && childElement.Name == "inheritdoc") { if (nestingLevel < 5 && childElement.Name == "inheritdoc") {
string cref = childElement.GetAttributeValue("cref"); string cref = childElement.GetAttributeValue("cref");
IEntity inheritedFrom = null; IEntity inheritedFrom = null;
string inheritedDocumentation = null; string inheritedDocumentation = null;
@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Xml
} }
if (inheritedDocumentation != null) { if (inheritedDocumentation != null) {
var doc = new AXmlParser().Parse(inheritedDocumentation); var doc = new AXmlParser().Parse(new StringTextSource(inheritedDocumentation));
// XPath filter not yet implemented // XPath filter not yet implemented
if (childElement.Parent is AXmlDocument && childElement.GetAttributeValue("select") == null) { if (childElement.Parent is AXmlDocument && childElement.GetAttributeValue("select") == null) {
@ -220,12 +220,12 @@ namespace ICSharpCode.Decompiler.Xml
return !(inheritedElement != null && doNotInherit.Contains(inheritedElement.Name)); 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 }); list.Add(new XmlDocumentationElement(childElement, declaringEntity, crefResolver) { nestingLevel = nestingLevel });
//} }
} }
} }
if (list.Count > 0 && list[0].IsTextNode) { if (list.Count > 0 && list[0].IsTextNode) {

Loading…
Cancel
Save