Closed cdonnellytx closed 1 year ago
Hey Chris,
your sugesstions sound reasonable to me. I'm currently preparing for a trip - is it OK for you if I a take a deeper look in the upcoming days? Will get back to you on Monday at the latest.
Hey Chris,
I found some time early in the morning to take a closer look. I totally agree with everything you presented and I would add the following methods.
Method name | Safe? | Reason |
---|---|---|
MustBeOfType |
✅ | Only performs an explicit cast with the as operator which cannot cause enumeration |
IsSameAs |
✅ | Calls ReferenceEquals which cannot result in enumeration |
MustNotBeSameAs |
✅ | See IsSameAs |
I had a look at your branch, looks good to me. What's your opinion on these three additional methods? Would you be so kind and add the NoEnumerationAttribute
to these methods, too, if you agree with me? Could you then please create a pull request that would merge with the dev
branch? Thanks so much for your efforts in advance!
The new version 10.1.0 is now released and contains your changes! https://www.nuget.org/packages/Light.GuardClauses/10.1.0
JetBrains annotations now includes a NoEnumerationAttribute:
At a minimum I would like to add this to the
MustNotBeNull
andMustNotBeNullReference
checks, as those check strictly against nulls.I evaluated other methods as follows:
MustNotBeNull
MustNotBeNullReference
IsSameAs
MustNotBeSameAs
MustNotBeDefault
MustHaveValue
MustBe
MustNotBe
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