Closed GoogleCodeExporter closed 9 years ago
MoreLINQ is just extensions to LINQ to Objects and in that spirit, it does null
argument checking on the source(s) just like all standard LINQ operators. It
would be odd and confusing to have code that using MoreLINQ and LINQ in the
same query to have a mix of two policies and the reader having to remember when
it's okay to send null and when not. Even if you can afford to send null
sources to MoreLINQ methods, you would to mask null with an empty sequence
before calling the LINQ methods. The best policy is to write functions that
don't return null sequences. If you have no control over the source of such
functions then the next best course of action is to mask null with an empty
sequence early on (when function returns the result) so that each call site is
not polluted with null-masking. If `source ?? Enumerable.Empty<T>()` looks
wordy, you can have a single extension method, called MaskNull for example,
that hides that and type inference wouldn't even require you to specify the
type for T (which is even better than Enumerable.Empty<T> because you can even
use it for anonymously projected types).
Original comment by azizatif
on 17 Oct 2014 at 6:19
Original issue reported on code.google.com by
mi...@zoltu.net
on 17 Oct 2014 at 12:29