A way to copy xml comments from a set of APIs to another similar set of APIs?
Suppose in Visual Studio I have a new project which contains some of the same APIs from an older proje开发者_如何学运维ct, and I would like to copy the xml documentation over to the new one. Is there a way I can do this without manually copy-pasting them one by one?
I maintain an open-source project that implements a feature supporting programatic access to XML document comments. See Jolt.NET for more information about the project, and specifically, "Querying XML Doc Comments" for the documentation for this feature.
Here is an example of how to use the library to implement what you are looking for.
using Jolt;
using System.Xml.Linq;
void CopyXmlDocComments(Assembly sourceAssembly)
{
XDocument newDocComments = new XDocument();
XmlDocCommentReader reader = new XmlDocCommentReader(sourceAssembly);
foreach(Type t in sourceAssembly.GetTypes()) // implement type filter here
{
newDocComments.Add(reader.GetComments(t));
}
newDocComments.Save("newAssemblyName.dll.xml");
}
In this example, I am assuming that you want to copy the doc comments of the similar types in two assemblies. If you need to constrain the copying further to specific members, you can also accomplish that with the library, though you will need to implement the method-filtering logic yourself.
I haven't heard of any such tool. The only thing I know of that's remotely similar is ReSharper's ability to copy xmldoc comments from base classes to derived classes.
精彩评论