Resharper no longer suggests things?

Answered

I have Dark theme in use. I've noticed that Resharper fails to suggest changing `.Count > 0` to `.Any()` and similar changes are no longer suggested.

I've looked into Inspection Severity, found this part and configured it to Error. Still does nothing to indicate any highlight.

Same issue persists in Visual Studio 2017 as well as Visual Studio 2019 projects.

What can I do to fix it?

10 comments
Comment actions Permalink

I just reset Reshaper options completely. Still doesn't highlight these improvement places the way it should.

0
Comment actions Permalink

Mikael Palmujoki, thank you for your question. Does the problem happen for a newly created solution or it's solution specific problem? What does a marker bar look like - https://i.imgur.com/lKFOibg.png? Could you please attach a screenshot of the VS window where the scrollbar would be visible? Thank you!

0
Comment actions Permalink

Hi Maria Pleskunina

I tried a newly created solution, and did the bad code there.

Here's a marker bar along with the `if (foo.Count > 0)` case and the marker bar.

0
Comment actions Permalink

So no suggestions for changing to `.Any()`.

0
Comment actions Permalink

Mikael Palmujoki, thanks for the reply. Sorry, I tried to reproduce the problem with .Count() instead of .Count.
In your case, it is preferable to use .Count instead of .Any(), since List knows its size and Count doesn't need to be calculated. At the same time, .Any() will create redundant entities (enumerator), creating an extra job for the Garbage Collector.

0
Comment actions Permalink

Well, alright, I kind of understand your logic there, why .Any() is perhaps not preferable.

But, still, why does it not highlight it in the editor, when I have in the settings that it should be highlighted as Error and suggested upon?

I'd expect Resharper to highlight according to the Inspection Severity rules. Feels broken still, despite your logic about this specific case. My issue is that Resharper does not really highlight much at all, feels like basic Visual Studio highlights. So whilst .Any() is a single case, I'm quite much more concerned about why the editor doesn't highlight according to Inspection Severity settings.

0
Comment actions Permalink

Does the highlighting appear if you change the code to the following (Count() instead of Count)?

if (foo.Count() > 0)
{
Console.Write(bar);
}
0
Comment actions Permalink

Inspections's descriptions explicitly states that it works on "Count()" method and not "Count" property

0
Comment actions Permalink

Ohh true.

Thanks for bringing up the distinction here!

I guess we can close this issue.

0
Comment actions Permalink

I thought I already answered, but yes, Maria, adding the parenthesises did bring up the red underline. So highlighting works, I'm just being paranoid.

0

Please sign in to leave a comment.