I have an API project that uses .Net's XML documentation. This results in MyApp.dll
getting a MyApp.xml
file with all the code comments, which looks something like this:
<?xml version="1.0"?>
<doc>
<assembly>
<name>MyApp</name>
</assembly>
<members>
<member name="T:MyApp.MyNamespace.MyClass">
<summary>Description of class</summary>
</member>
<member name="M:MyApp.MyNamespace.MyClass.MyGenericMethod``1(``0)">
<summary>Description of method</summary>
<typeparam name="T">Description of generic type</typeparam>
<param name="paramName">Description of parameter.</param>
<returns>Description of what this returns.</returns>
</member>
...
</members>
</doc>
I have typeof(MyClass)
and from that I want to extract all this documentation. I know that I can use SandCastle to build an external .CHM help, but this needs to be part of the application that uses the API.
I want to be able to use XPath $"//member[@name='key']"
to get the relevant XmlNode
in the documentation file.
It's fairly easy to look up typeof(MyClass)
or even use typeof(MyClass).GetMembers()
to get the members, but there doesn't appear to be an easy way to get the name used in the XML documentation. For a type I can use $"T:{typeof(MyClass).FullName}"
, but for MemberInfo
this is a great deal more complicated, especially for generics.
I can read the MemberInfo.MemberType
and parse all the generic and regular parameters, but that seems like a lot of work for something .Net must already be doing to build the XML file in the first place.
So, I have the MemberInfo
for MyGenericMethod
- how do I get "M:MyApp.MyNamespace.MyClass.MyGenericMethod``1(``0)"
from that?
Aucun commentaire:
Enregistrer un commentaire