Feature Request: Comment controls

It would be great if we could hide comments.
I like putting a lot of comments in my code, but I frequently work with people who don't like comments. 

It would be great if I could add tags to comments ('#walkthough' at the end of the comment, or in a line afterwards) That tag list would be hidden, but expandable to edit. The IDE would track comments based on type (TODO, inline, block, XML), tags, author, and location and allow users to create rules to hide comments.

There should be an option to hide a specific comment unless it get changed. If a comment changes you might re assess weather you want to see it generally. 

there should be a show hidden comments toggle somewhere and some sort of minimal icon that denotes there is a hidden comment at  a point.

This feature would not just be great in Rider, but also Intelij and other editors.

1
5 comments

Hello,

You can configure IDE to fold comments by default:

  • Settings | Editor | General | Code Folding | Fold by default: General | Documentation comments;
  • Settings | Editor | General | Code Folding | Fold by default: .Net | Line and block comments;

Doesn't it cover your needs?

0

Not really. What i am looking for is the power to add more categories to those settings. For example, i frequently leave comments designed for someone who doesn't know C# because I remember what it was like trying to learn the language from context. I wanted someone to explain each line and what it actually. I find these helpful for remembering what the code does a year down the line which I haven't touched it in ages. But i am working with people who find them distracting. It would be great if i could say // test if the list is empty #tutorial and then tell rider to wrap comments with #tutorial.

0

So, you are talking about line-level comments where you comment some lines inside a method (every line?), right? 

And you want Rider to be able to hide and show such comments depending on user preferences, for e.g.:

public int SamplePow()
{
	// First, it prints user a message to enter a number #tutorial
	Console.WriteLine("Enter a number to power");
	// Then it takes user input to a string #tutorial
	int number = Convert.ToInt32(Console.ReadLine());
	// Finally it returns the resulting number #tutorial
	return number;
}

So, the developer that would configure “#tutorial” as an ‘ignore’ pattern would see:

public int SamplePow()
{
	Console.WriteLine("Enter a number to power");
	int number = Convert.ToInt32(Console.ReadLine());
	return number;
}

Do I understand your request correctly?

Did you consider using method-level XML comments instead? It can be the same as a simple high-level explanation of the method, the same as a detailed instruction describing what and how the method does. It is very flexible and is widely used for any commenting purpose. For e.g.:

            /// <summary><b> This method is necessary</b>
            /// A sample method which demonstrates how to use the screen footer. <br/>
            /// Tutorial version 1:
            /// <list type="bullet">
            /// <item><c>Console.WriteLine("Enter a number to power");</c> - Print an informing message to a user:</item>
            /// <item>Read a number from the user</item>
            /// <item>Return the result to the caller</item>
            /// </list>
            /// Tutorial version 2:
            /// <code>
            /// Console.WriteLine("Enter a number to power"); // request user input
            /// int number = Convert.ToInt32(Console.ReadLine()); // read user input
            /// return number; // return result </code>
            /// </summary>
            /// <returns>returns number</returns>
            public int SamplePow()
            {
                Console.WriteLine("Enter a number to power");
                int number = Convert.ToInt32(Console.ReadLine());
                return number;
            }

Also, it can be folded by default. It should be enough to explain what the method does, isn't it. It is supported in most IDE's which is an extra advantage. Because, even if the feature you describe is implemented in Rider, any other code editors will have no idea what the uncommon comment with custom #whatever is there in your code. It will be rendered in the editor just like a common comment.

0

first of yes you are understanding the request. Maybe a little logo next to the line number indicating there is a hidden comment here, but maybe not.

I do use XML comments to document my functions, i am very happy with the functionality there, and this is sufficient for a short function, but if i have a function longer than about 20 lines that makes several decision, I don't want to put all that documentation in the XML. When i write the XML I focus on the people who will use this function and want to know what it does. 

0

You might consider using preprocessor directives for compilation with the #region feature for writing a tutorial for a piece of code. Look at such an example:

            public int SamplePow()
            {
                #region TUTORIAL

#if TUTORIAL
// First it says user to enter a number
Console.WriteLine("Enter a number to power");
// Then it reads the user input
int number = Convert.ToInt32(Console.ReadLine());
// Finally it returns the result
return number;
#endif

                #endregion

                Console.WriteLine("Enter a number to power");
                int number = Convert.ToInt32(Console.ReadLine());
                return number;
            }

Such regions can be folded by default in most code editors, and you could use it as a place for writing tutorials to specific code snippets. There is what it can look like:

Does it help? If not, please tell me more, why it doesn't address your needs.

Have a nice day!

0

Please sign in to leave a comment.