12

If I use the Resharper code cleanup function, I'm finding my code ...

var personInfos = persons.Select(Mapper.Map<PersonInfo>).ToList();

is changed to ...

var personInfos = Enumerable.ToList(persons.Select(Mapper.Map<PersonInfo>));

But then Resharper makes a suggestion "To extension method invocation" for the Enumerable.ToList so the code goes back to ...

var personInfos = persons.Select(Mapper.Map<PersonInfo>).ToList();

I've checked in the Resharper code editing options, but I can't see where/how I can stop this toggling behaviour

Vlad274
  • 6,514
  • 2
  • 32
  • 44
SteveC
  • 15,808
  • 23
  • 102
  • 173

3 Answers3

3

I think @Matthias may be correct

I've updated to current Resharper, i.e. 2016.1.2 and tried the code ...

var personInfos = persons.Select(Mapper.Map<PersonInfo>).ToList();

Resharper no longer offers a suggestion

And @Vlad274 this is with my code cleanup Optimise 'using' directives and Shorten qualified references both still checked

SteveC
  • 15,808
  • 23
  • 102
  • 173
0

To fix this you'll need to create a custom cleanup profile. The two settings that need to be turned off are highlighted below.

Settings

By default, the full cleanup has both settings turned on. If either setting is turned on, the cleanup will make this switch.

Vlad274
  • 6,514
  • 2
  • 32
  • 44
  • 4
    If this is really the case, it sounds like a bug to me and you should report it to https://youtrack.jetbrains.com. Those two options are clearly not responsible for swapping between static and extension invocation. I have both options enabled, and the usual instance-like invocation is kept. – Matthias Aug 05 '16 at 00:12
0

As an alternative to upgrading and perhaps a more general solution:

Under the code inspection menu you should have inspection 'Convert static method invocation ... ' there is an option called 'configure inspection severity'. Here you should be able to select: do not show.

Works best of course if you save these preferences into a shared settings file so that all working on this solution share this setting automatically.

Arwin
  • 973
  • 1
  • 10
  • 21