views:

49

answers:

2

Suppose in Visual Studio I have a new project which contains some of the same APIs from an older project, 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? Thanks!

+1  A: 

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.

Zor
+2  A: 

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.

Steve Guidi
Works beautifully. Thanks. Great project!
Dan7