From Java and Eclipse I'm used to @inheritDoc
that allows to use the same documentation as in the base class/method.
How can I accomplish something similar in C# and Visual Studio 2010?
From Java and Eclipse I'm used to @inheritDoc
that allows to use the same documentation as in the base class/method.
How can I accomplish something similar in C# and Visual Studio 2010?
Even this question is a few years old and it was specifically for Visual Studio 2010. For all those that land here by Google, I would like to add an answer that I found and that holds true for Visual Studio 2015 in combination with Sandcastle Help File Builder (SHFB):
/// <inheritdoc/>
can be used to inherit the docs from a base class or an interface.
Here a link to the Sandcastle Help File Builder (SHFB) documentation: Using the <inheritdoc /> Tag
Edit: it didn't at the time; this other answer here explains that it was added, and how to use it.
It doesn't exist in vanilla VS. Your best bet is ghostdoc or similar. This is available in the Extension Manager, or here
Support for <inheritdoc/>
was implemented in Visual Studio 2019 Update 16.4
Documentation for it is here.
<inheritdoc [cref=""] [path=""]/>
Inherit XML comments from base classes, interfaces, and similar methods. Using inheritdoc eliminates unwanted copying and pasting of duplicate XML comments and automatically keeps XML comments synchronized. Note that when you add the tag to a type, all members will inherit the comments as well.
- cref: Specify the member to inherit documentation from. Already defined tags on the current member are not overridden by the inherited ones.
- path: The XPath expression query that will result in a node set to show. You can use this attribute to filter the tags to include or exclude from the inherited documentation. Add your XML comments in base classes or interfaces and let inheritdoc copy the comments to implementing classes.
Add your XML comments to your synchronous methods and let inheritdoc copy the comments to your asynchronous versions of the same methods. If you want to copy the comments from a specific member, you use the cref attribute to specify the member.
ReSharper not only provides shortcut keys to copy base class comments, but it actually includes <inheritdoc>
comments in its custom IntelliSense the way you want. This only works if your whole team is using ReSharper of course.
Usage of <inheritdoc>
is explained well here.
I ended up creating a tool to add support for replacing the <inheritdoc/> tag by post-processing the XML documentation files. Available at www.inheritdoc.io (free version available).
NDoc3 is based on NDoc, and is a code documentation generation tool for .NET developers. The goal is to make a fast, extensible, multi-platform .NET documentation tool which supports all of the .NET languages specifications including but not only, C#
My addin, AtomineerUtils will duplicate documentation from overrides of base class and interface methods/properties, from overloads in the same class, and for parameters it will also look for same-named parameters used elsewhere in the same class.
You may also be able to use extension XML commands like <inheritdoc> or <include> if you want to duplicate the text in external documentation (Sandcastle, Doxygen, etc), but I'm not aware of any way of "dynamically" inheriting documentation for "internal" use (intellisense etc)
ReSharper provides shortcuts to copy the XML documentation from base classes.