Search code examples
c#resharperienumerable

Is this a bug in resharper?


I have me some Resharper squiggles here.

enter image description here

and they tell me that I have a possible multiple enumeration of IEnumerable going on. However you can see that this is not true. final is explicitly declared as a list ( List<Point2D> ) and pointTangents is declared previously as List<PointVector2D>

Any idea on why Resharper might be telling me this?

Edit Experiments To See If I can replicate with simpler code

As you can see below there are no squiggles and no warnings even though Bar is declared to take IEnumerable as arg.

enter image description here


Solution

  • Looks a lot like RSRP-429474 False-positive warning for possible multiple enumeration :

    I have this code:

    List<string> duplicateLabelsList = allResourcesLookup.SelectMany(x => x).Select(x => x.LoaderOptions.Label).Duplicates<string, string>().ToList(); ; 
    if (duplicateLabelsList.Any()) 
    throw new DuplicateResourceLoaderLabelsException(duplicateLabelsList);
    

    For both usages of duplicateLabelsList, I'm being warned about possible multiple enumeration, despite the fact I've called ToList and therefore there should be no multiple enumeration.

    which (currently) has a Fix Version of 9.2, which (currently) isn't yet released.