JetBrains annotations now includes a NoEnumerationAttribute:
Indicates that IEnumerable passed as a parameter is not enumerated. Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.
At a minimum I would like to add this to the MustNotBeNull and MustNotBeNullReference checks, as those check strictly against nulls.
I evaluated other methods as follows:
| Method name |
Safe? |
Reason |
MustNotBeNull |
✅ |
Does identity check against null |
MustNotBeNullReference |
✅ |
Does identity check against null |
IsSameAs |
✅ |
Does identity check against two values |
MustNotBeSameAs |
✅ |
Does identity check against two values |
MustNotBeDefault |
❌ |
Calls Equals which can be overridden and in theory enumerate. |
MustHaveValue |
✅ |
HasValue, Value cannot be overridden and do not enumerate |
MustBe |
❌ |
Calls Equals which can be overridden and in theory enumerate. |
MustNotBe |
❌ |
Calls Equals which can be overridden and in theory enumerate. |
Everything else either operates on a strictly non-enumerable type (e.g, MustBeEmpty(Guid)), on a "well-known" enumerable type that is not streaming (e.g. string), or an enumerable that may be streaming.
I have a branch I intend to submit as a PR if you are comfortable with these changes.
Thanks for making a great library!
# Chris
JetBrains annotations now includes a NoEnumerationAttribute:
At a minimum I would like to add this to the
MustNotBeNullandMustNotBeNullReferencechecks, as those check strictly against nulls.I evaluated other methods as follows:
MustNotBeNullMustNotBeNullReferenceIsSameAsMustNotBeSameAsMustNotBeDefaultMustHaveValueMustBeMustNotBeEverything else either operates on a strictly non-enumerable type (e.g,
MustBeEmpty(Guid)), on a "well-known" enumerable type that is not streaming (e.g.string), or an enumerable that may be streaming.I have a branch I intend to submit as a PR if you are comfortable with these changes.
Thanks for making a great library!
# Chris