Doing a search around I've found this kind of question being asked in the past but not targeted at VS2010 or C# .Net 4. Has anyone come across a way to make interface comments inherit through to the implementation classes for intellisense to use?
A colleague suggested copy and paste into the implementation but there must be a better way. Looking at the previous question rec开发者_开发问答ommendations Sandcastle appears to be a documentation generator which isn't what I need.
Consider the following:
public interface IFoo
{
/// <summary>
/// Comment comment comment
/// </summary>
string Bar { get; set; }
}
public class Foo : IFoo
{
public string Bar { get; set; }
}
public class Test
{
public Test()
{
IFoo foo1 = new Foo();
foo1.Bar = "Intellisense comments work";
Foo foo2 = new Foo();
foo2.Bar = "Intellisense comments don't work";
}
}
Is there a way to make intellisense on foo2 work?
It can't be done automatically without changing the IntelliSense in VS.
A colleague of mine uses ReSharper (http://www.jetbrains.com/resharper/) and I asked him to try out your code - and it does do exactly what you're asking for as it extends the intellisense of VS. You might want to look into that.
However, for me the simplest way to achieve this is the free version of GhostDoc - http://submain.com/products/ghostdoc.aspx which makes bringing in the base documentation of a method/property a single key combination.
The downside being that it's cloning the documentation, therefore if that base documentation changes you have to remember to go and clear it on the derived class/interface and re-generate it.
The ReSharper solution, of course, does not suffer from this problem, so you pays your money (literally, in the case of ReSharper) and takes your choice. There might be other free plugins that achieve this, of course.
精彩评论