Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheriting XML comments from interfaces in C#

I was wondering if anyone knows how to link an interface xml comment to an implementation. The problem is that I want the base comments to come from my interface first. Example:

interface myinterface {         /// <summary>        /// Does something.        /// </summary>        void method1(string foo);  } 

and then the implementation is:

public class myclass : myinterface {          public void method1(string foo) {              //do something...        } } 

So now if I hover over the method with my mouse after instantiating the object:

myclass foo = new myclass(); foo.method1("do something"); 

how can I make the comments appear in the hover popup? Is there some way I can link the interface comments to the implementation? I know there's a way in Java, but can't find the solution for C#.

Thanks

like image 718
u84six Avatar asked Sep 22 '10 19:09

u84six


2 Answers

Updated Answer:

Use the <inheritdoc />-Tag.

Old Answer:
Linking XML Comments is IMHO not possible, but you could use a tool like GhostDoc to copy the XML Comment from your Interface/Baseclass to the implementation/derived class.

like image 189
Noffls Avatar answered Sep 22 '22 16:09

Noffls


XMLDoc defines a tag <include /> for including comments from another file which has been around since Visual Studio 2003. The largest caveat is the referenced file should be a file containing only XMLDoc documentation, not another source file.

See the MSDN page for more details.

like image 42
psaxton Avatar answered Sep 20 '22 16:09

psaxton