Possibile multiple enumeration of an IEnumeration object

Hi.

I get a lot of warnings that perhaps I execute a IEnumeration multiple times when I do a check if the IEnumeration object is null.
I have a method which contains the test code itself.

Is there some way to annotate this method so that I do not get a wanring for a possible multiple enumeration?

DebuggerStepThrough]
[AssertionMethod]
public static void NotNull<T>([AssertionCondition(AssertionConditionType.IsNotNull)]T value, [LocalizationRequired(false), InvokerParameterName] string parameterName) where T : class {
  if (value == null) {
    throw new ArgumentNullException(parameterName);
  }
}

public void SomeMethode(IEnumerable<String> someStrings) {
  NotNull(someStrings, "someStrings"); <- warning here
  ...
}


Kind regards,
Sven

2 comments

Hello Sven,

At the moment there's no way to tell ReSharper that a method doesn't enumerate
the IEnumerable. You're welcome to vote for the following feature request:
http://youtrack.jetbrains.net/issue/RSRP-273689. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi.

I get a lot of warnings that perhaps I execute a IEnumeration multiple
times when I do a check if the IEnumeration object if it is null.

I have a method which cointains the test code itself.

Is there some way to annotate this method so that I do not get a
wanring for a possible multiple enumeration?

 [AssertionMethod]
> public static void
> NotNull([AssertionCondition(AssertionConditionType.IsNotNull)]T
> value, [LocalizationRequired(false), InvokerParameterName] string
> parameterName) where T : class {
> if (value == null) {
> throw new ArgumentNullException(parameterName);
> }
> }
> public void SomeMethode(IEnumerable someStrings) {
> NotNull(someStrings, "someStrings");  ...
> }
> ]]>


Kind regards,
Sven
---
Original message URL:
http://devnet.jetbrains.net/message/5320382#5320382



0

Please sign in to leave a comment.