Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Resharper warning "Possible multiple enumeration of IEnumerable" when validating enumerable parameters #3

Closed
TAGC opened this issue Sep 13, 2017 · 3 comments
Assignees

Comments

@TAGC
Copy link

TAGC commented Sep 13, 2017

I've been using this library for my guard clauses for a while, and I quite like it. However, I've recently started using R# and it's causing me to see (and have to suppress) a number of warnings about potential multiple enumerations when I'm using validations like Raise.ArgumentNullException.IfIsNull(someEnumerableParameter);

This is easy to fix - all that's needed is to add [NoEnumeration] from JetBrains.Annotations to any parameters in externally-accessible methods that can accept enumerable parameters, e.g.

public void IfIsNull<TArg>([NoEnumeration] TArg argument)
{
    if (ReferenceEquals(argument, null))
    {
        throw new ArgumentNullException();
    }
}

I'd do this myself and submit a pull request, but for some reason your project literally crashes Visual Studio 2017 every time I try to open it (not sure what's up with that).

@TAGC
Copy link
Author

TAGC commented Sep 13, 2017

For what it's worth, Ensure.That have been doing this if you'd like to see what they've done (link)

@pomma89
Copy link
Owner

pomma89 commented Sep 13, 2017

Hi @TAGC,

I've just published version 4.2.1, which should fix the R# issue. I do not use R#, so could you check that it is really solved?

I adopted Ensure.That solution, with a difference: R# attribute is internal instead of public, in order to avoid conflicts.

About VS crash: could you ensure that you have latest VS17 updates and that you have .NET Core 2.0 SDK?

Thanks!

@TAGC
Copy link
Author

TAGC commented Sep 14, 2017

Works great, thanks!

About VS crash: could you ensure that you have latest VS17 updates and that you have .NET Core 2.0 SDK?

I have all the latest software installed - other people have been able to open it fine. I've submitted a bug report to Microsoft.

@TAGC TAGC closed this as completed Sep 14, 2017
@pomma89 pomma89 self-assigned this Sep 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants