Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include XML doc comments when implementing an interface with Shift+Alt+F10 #7862

Closed
kuhlenh opened this issue Jan 8, 2016 · 20 comments
Closed
Assignees
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature Request Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@kuhlenh
Copy link

kuhlenh commented Jan 8, 2016

[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

@kuhlenh kuhlenh added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Area-IDE Feature Request labels Jan 8, 2016
@kuhlenh kuhlenh added this to the Unknown milestone Jan 8, 2016
@dpoeschl
Copy link
Contributor

Do we really want to always do this? Maybe just under an option?

@dpoeschl
Copy link
Contributor

Can we instead show the first discovered inherited doc comments in QuickInfo/IntelliSense?

For example, quick info on D in this code:

/// <summary>B1 says Hello, World</summary>
interface B1
{
}

/// <summary>Hello from B2!</summary>
interface B2 : B1
{
}

class D : B2
{
}

might look something like:

class D
From interface B2: Hello from B2!

/cc: @CyrusNajmabadi

@dpoeschl
Copy link
Contributor

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?

@dpoeschl dpoeschl removed this from the Unknown milestone Jan 20, 2016
@kuhlenh kuhlenh removed their assignment Jan 20, 2016
@Pilchie
Copy link
Member

Pilchie commented Jan 22, 2016

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.

@Pilchie Pilchie added this to the Unknown milestone Jan 22, 2016
@antonssonj
Copy link
Contributor

Hi,
I’m 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.

  • Add inheritdocas a recommended tag to get completion when writing comments.
  • Add a new property bool Inheritdoc to the DocumentationCommentType.
  • In the extension method ISymbolExtensions.GetDocumentationComment check if the symbol has a <inheritdoc /> tag and find the overridden/implemented symbol and merge the DocumentationCommentof the parent symbol and the symbol.
  • Update the Implement interface code action, not sure of the best way to do it. If CodeGenerateOptions.GenerateDocumentationComments is true there could be a check in TryGetDocumentationCommentto see if inheritdocis applicable but that feels like a hack and maybe there needs to be another flag in CodeGenerateOptions.

Alternative approaches:

  • Just Implement bullet 3 above without the check for 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.
  • Instead of adding inheritdoc to the code actions maybe an analyser with a code fix would be enough. It would also help fixing a codebase where lots of comments are copied or empty. Where is the best place for an analyser like that?

Happy for feedback

@Pilchie
Copy link
Member

Pilchie commented Feb 26, 2016

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!

@Pilchie Pilchie modified the milestones: 1.3, Unknown Feb 26, 2016
@Pilchie Pilchie added Community The pull request was submitted by a contributor who is not a Microsoft employee. and removed help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Feb 26, 2016
@CyrusNajmabadi
Copy link
Member

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."

@dpoeschl
Copy link
Contributor

@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?

@CyrusNajmabadi
Copy link
Member

@dpoeschl Yup. That sounds good.

@antonssonj
Copy link
Contributor

Great, so what’s 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.

@antonssonj
Copy link
Contributor

@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.

  • This feature is pretty big, should it be divided in different Pull Requests?
    • Completion for the inheritdoc comment
    • An Analyser that fix CS1591, (Best way that I have found to fix the original issue)
    • Implementation of inheritdoc and heuristic in QuickInfo/IntelliSense.
  • For inheritdoc in QuickInfo, do you think we should implement all features from Sandcastle? Is everything applicable for an implementation in VS like Inherit documentation from all base classes working backwards up the inheritance chain.

@Pilchie Pilchie modified the milestones: 2.0 (RC), 1.3 Apr 12, 2016
@DustinCampbell DustinCampbell changed the title Include comments when implementing an interface with Shift+Alt+F10 Include XML doc comments when implementing an interface with Shift+Alt+F10 Apr 22, 2016
@rchande rchande added this to the Unknown milestone Sep 16, 2016
@rchande rchande removed this from the 2.0 (Preview 5) milestone Sep 16, 2016
@rchande rchande added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Sep 16, 2016
@rchande
Copy link
Contributor

rchande commented Sep 16, 2016

@dpoeschl What's the status of this?

@sharwell
Copy link
Member

I think it would be good to treat this as blocked on dotnet/csharplang#313.

@sharwell sharwell added Blocked and removed 0 - Backlog help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Aug 14, 2017
@jinujoseph jinujoseph added this to Backlog in IDE: InternalPriority via automation Oct 24, 2018
@binki
Copy link

binki commented Jan 17, 2019

https://developercommunity.visualstudio.com/content/idea/412325/.html was marked a duplicate of this.

@kendrahavens kendrahavens added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed Blocked labels Jan 3, 2020
@kendrahavens
Copy link
Contributor

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

image

@TobiasKnauss
Copy link

@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?

@kendrahavens
Copy link
Contributor

@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?

@TobiasKnauss
Copy link

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.

@kendrahavens
Copy link
Contributor

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.

@chm-tm
Copy link

chm-tm commented Jul 7, 2020

The release notes have been archived meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature Request Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
Development

No branches or pull requests