7

I have a class that i am inheriting from and the methods i override should have the same comments as the base. Does resharper have an option to copy them?

Ryan Burnham
  • 2,619
  • 3
  • 27
  • 43

6 Answers6

19

In addition to the above mentioned context action, which I find fairly tedious to apply for each inherited member, you can also configure ReSharper to "pull down" comments by default when implementing a base class or interface.

To do this, from the ReSharper main menu go to Options | Code Editing | Member Generation | Other Options inside here you will see an option to Copy XML documentation from overridden members, if you check this option ReSharper will automatically copy all inherited documentation for you.

enter image description here

Richard
  • 1,602
  • 1
  • 15
  • 16
9

Since version 3.0 of ReSharper, you should have a context action available to do this, Copy comments from base. If it doesn't appear to be available, make sure it's checked in ReSharper | Options | Languages | C# | Context Actions.

AakashM
  • 62,551
  • 17
  • 151
  • 186
2

Let your overridden methods uncommented. So R# short help (Ctrl+Shift+F1) will automatically show the help of base class member.

brgerner
  • 4,287
  • 4
  • 23
  • 38
1

This is a duplicate of Can I propagate XML documentation from an interface to its implementation?

Answer: press Alt+Ins from each method name, choose "Copy comments from base". As accepted answer indicates, you must have this option enabled.

Community
  • 1
  • 1
drzaus
  • 24,171
  • 16
  • 142
  • 201
1

This is an older question, but I thought I'll add the point that resharper has support for the tag

     /// <inheritdoc />

With this it the comment of the interface is also shown in the tooltip in intellisense.

NPadrutt
  • 3,619
  • 5
  • 24
  • 60
  • Intellisense does not recognize this tag for me in Visual Studio Community 2017. – Didii Jun 29 '17 at 12:43
  • You need to have Resharper installed for this to work. – NPadrutt Jun 29 '17 at 12:47
  • I have it installed! – Didii Jun 29 '17 at 14:00
  • Which version and what VS? – NPadrutt Jun 29 '17 at 14:12
  • I just updated to the latest Resharper version (2017.1.3), it previously was 2017.1.2. I can't seem to find any related options except for adding the value. Visual Studios is Community 2017. And it seems very hard to Google... – Didii Jun 29 '17 at 15:59
  • It seems like it does not always show up. When hovering over the item, it does not show up, when going through the auto-complete it is however shown. It is however always shown here even if you do not include the `` tag. – Didii Jun 29 '17 at 16:03
  • I see. Maybe I just use the use cases who are supported. – NPadrutt Jun 29 '17 at 16:13
0

I built a tool to post-process the XML documentation files adding support for the <inheritdoc/> tag.

While it doesn't help with Intellisense in source code, it does allow the modified XML documentation files to be included in a NuGet package and therefore works with Intellisense in referenced NuGet packages.

Go to www.inheritdoc.io for more info (free version available).

K Johnson
  • 478
  • 5
  • 14