Feature Request - R# comment syntax that doesn't suck

So I have a peice of code that via static analysis cannot determine the enumeration of this will only occur multiple times on an array. Since it doesn't understand it can only be an array, R# correctly suggests "warning this could be multiple enumeration". Seeing as I fully intend this, i use the comment to disable this once, resulting in:

// ReSharper disable once PossibleMultipleEnumeration

And this just really sucks. This would be substantially more useful if the comment generated was more like

// Multiple Enumeration of this contains no side effects. R#

another alternative:

// R# Multiple Enumeration of this contains no side effects.

with this being a keyword to signfy "once". There is no reason the syntax "disable" needs to be included. Your comment doesn't add value to my code. However if the comment was more along the lines I raised, it would provide semantic value AND value to resharper.

Given the range one:


// ReSharper disable PossibleMultipleEnumeration
// ReSharper restore PossibleMultipleEnumeration

This could be amended to such:

// Multiple Enumerations contains no side effects. R#

// End  Multiple Enumerations contains no side effects. R#

5 comments
Comment actions Permalink

ReSharper 9 (and I think later versions of ReSharper 8) added the following syntax:

// ReSharper disable once PossibleMultipleEnumeration

and this affects only the next following statement, which usually corresponds to a single line of code (if statement, method call, method declaration, etc). You can add this via the alt-enter menu on a highlight, which allows you to disable once, for a region and (for ReSharper 9) for a whole file.

0
Comment actions Permalink

Right but my qualms is with the actual text it uses, it's obnoxious. By slightly modifying the text it could create a very helpful comment for developers AND tell resharper what it needs.

0
Comment actions Permalink

The comment is really intended for ReSharper, which is why it's regular and parseable. It's also obvious that it's for ReSharper. By making it a free text string, it's no longer obvious that it's a ReSharper command, and instead looks like a comment for the user, but if the user edits it at all, the warning would return. This makes it a non-obvious magic string, which I think would be frustrating. I'd rather have it obvious that the comment is controlling ReSharper's analysis.

That said, it's possible to implement, and you could create a plugin to do this, if you wish, or you can also log a feature request at https://youtrack.jetbrains.com.

0
Comment actions Permalink

Hello,

Right but my qualms is with the actual text it uses, it's obnoxious.


Currently it just mimics the C# syntax for disabling messages (which also
works for R#):

#pragma warning disable PossibleMultipleEnumeration

"once" is the newly-introduced modifier for disabling just one occurence,
as opposed to the disable/restore pair.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Please sign in to leave a comment.