Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use ReSharper to enforce commenting standards?

Tags:

c#

resharper

Been playing a lot recently with ReSharper and one thing I'd love to setup for my team are notifications if a C# class or C# file doesn't have a set code commenting standard. Unfortunately I have not yet been able to find much on the topic.

For example, I'd like to ensure all methods or functions have a comment description above them:

/// <summary>
/// Description of MyMethod here.
/// </summary>
public void MyMethod();

I would like to also see that a basic check for whether (Number of lines of code) / (Number of lines of comments) is around some magic happy-medium, and create a notification or warning if not.

like image 690
S.Richmond Avatar asked Aug 06 '13 06:08

S.Richmond


2 Answers

One simple option to start with (which doesn't even need R#) is to turn on the generation of an XML documentation file, and then treat warnings as errors. That will ensure that every public member has documentation.

It won't ensure that the comments are good, of course... but it will ensure they exist.

EDIT: R# does have a setting for this - under Code Inspection, Inspection Severity, C#, Compiler Warnings, look for CS1591: Missing XML comment for publicly visible type or member (and related warnings near it). Change the severity of that to Error and it might help you - but it's hard to say as you're in an unusual environment.

like image 164
Jon Skeet Avatar answered Sep 28 '22 17:09

Jon Skeet


Not to compete with Jon but GhostDoc does what you're describing.

enter image description here

like image 24
Jeremy Thompson Avatar answered Sep 28 '22 15:09

Jeremy Thompson