[Filed on behalf of a customer]
Most of the the time the comments apply to the class implementing the interface, so it makes sense to just copy the comments over.
VS Feedback 456983
Do we really want to always do this? Maybe just under an option?
Can we instead show the first discovered inherited doc comments in QuickInfo/IntelliSense?
For example, quick info on D
in this code:
``` C#
///
interface B1
{
}
///
interface B2 : B1
{
}
class D : B2
{
}
might look something like:
class D
From interface B2: Hello from B2!
```
/cc: @CyrusNajmabadi
Can we re-triage this to decide whether duplicating the comments is really what we want, instead of the above suggestion or support for inheritdoc
?
We agree that duplicating _isn't_ what we want. We think the ideal solution here is for the compiler to support inheritdoc
. Barring that, it would be reasonable for the IDE to find the overridden/implemented member and use its doc implicitly.
Hi,
I鈥檓 thinking of grabbing this item, is it still up for grabs? It could save me some time implementing an internal API that uses a lot of IoC and has the compiler generating xml documentation files.
I have made some tests and think it could be implemented like this.
inheritdoc
as a recommended tag to get completion when writing comments.bool Inheritdoc
to the DocumentationComment
Type.ISymbolExtensions.GetDocumentationComment
check if the symbol has a <inheritdoc />
tag and find the overridden/implemented symbol and merge the DocumentationComment
of the parent symbol and the symbol.CodeGenerateOptions.GenerateDocumentationComments
is true there could be a check in TryGetDocumentationComment
to see if inheritdoc
is applicable but that feels like a hack and maybe there needs to be another flag in CodeGenerateOptions
.Alternative approaches:
inheritdoc
. It will only solve the problem with intellisens in VS. But another problem is that the compiler will generate a warning (CS1591) if the option XML documentation file is used. Happy for feedback
Yes, it's still up for grabs, and we'd love it if you are interested in taking it on. @DustinCampbell, @dpoeschl, and I had a quick chat about how we think it might work this morning.
I'm going to assign the issue to @dpoeschl to work with you on the design. It's too late to include this in VS 2015 Update 2, but if things come together, we'd love to include it in the next VS Update after that!
I personally don't think we need something like "inheritdoc".
I think that the IDE should just have a good experience around symbols that don't have doc comments on them. In that case, we simply go look and see if there's a doc comment on higher symbol. We then present this in the UI in a nice way. i.e. we say 'here's some doc comments. but they actually came from this other symbol."
@CyrusNajmabadi We discussed the tooling ecosystem that makes a Roslyn implementation of inheritdoc
useful offline earlier. We can _also_ create a great IDE experience for both cases with inheritdoc (which we would honor) and without (using a heuristic). inheritdoc
would take precedence over the heuristic in the IDE. Does that dual approach to handle both existing tooling and improving IDE experiences with/without inheritdoc
sound good to you?
@dpoeschl Yup. That sounds good.
Great, so what鈥檚 the next step? Did your quick chat about how it might work differ a lot from my suggestion? Otherwise I could continue to work from my tests. I guess there will be a lot of details to discuss.
@dpoeschl I have expanded my tests and have implemented the most common cases. I have some thoughts that would be good to get some feedback on.
Inherit documentation from all base classes working backwards up the inheritance chain.
@dpoeschl What's the status of this?
I think it would be good to treat this as blocked on dotnet/csharplang#313.
https://developercommunity.visualstudio.com/content/idea/412325/.html was marked a duplicate of this.
Closing this issue as complete. Starting in Visual Studio 2019 Update 16.4 methods that have no XML documentation can now automatically inherit XML documentation from the method it is overriding. Place your cursor over the undocumented method that implements a documented interface method. Quick Info will then display the XML documentation from the interface method. Release notes
@kendrahavens you added a link to the release notes, but purely from reading them I wouldn't know that this issue was solved. Is there another "full" list of changes in a release?
@TobiasKnauss Apologies for the delay. I should have mentioned in the comment and in the release notes that this does apply to classes and interfaces as well as overridden methods. You can find a sample on an interface using inheritdoc in our docs: https://docs.microsoft.com/en-us/dotnet/csharp/codedoc#inheritdoc
Is that what you were looking for?
Yes, but I already found that. I just wanted to know whether the notification about inheritdoc
was forgotten in the release notes or there were other, more detailed release notes.
No, there were not other detailed release notes other than the overridden methods mentioned and the doc updates. I can update the release notes to include the inheritdoc tag example.
The release notes have been archived meanwhile.
Most helpful comment
We agree that duplicating _isn't_ what we want. We think the ideal solution here is for the compiler to support
inheritdoc
. Barring that, it would be reasonable for the IDE to find the overridden/implemented member and use its doc implicitly.