[Core] Argument Checking

Skip to first unread message

Fabian Schmied

Nov 30, 2009, 5:22:14 AM11/30/09
to re-motion Developers

Following up on the recent re-motion-users group conversation started by Tilli:

> The extension-methods idea has been under discussion even before we
> went to the mailing list. It was tabled again because spamming the
> Intellisense-list was considered the worse option compared to the
> additional syntactical sugar gained.

Just an idea, but how about:

public void SetName (string first, string last)
ArgCheck.Of ("first", first).NotEmpty();
ArgCheck.Of ("last", last).NotNull().NotEmpty();

// ...

ArgCheck.Of could return an ArgConstraint<T> struct, which we (and
everyone else) would define extension methods on.
(That would also nicely solve our issues with ArgumentUtility having
to support different versions of .NET, by the way.)

Struct means stack-allocated here; extension methods mean static
calls; so performance should be the same as with ordinary static
helpers, I suppose. And we'd be much more flexible.

But well, that's for the future :)


> On Nov 29, 10:06 am, uTILLIty <ti...@weissenberger.at> wrote:
>> Hi,
>> I like your extensive range of argument-checking helpers in the
>> ArgumentUtility. Nature has it that this library is probably never
>> complete, as there are many things one could want to check. These
>> checks then have to reside in another Class.
>> In my opinion there are 2 approaches to this I've used so far:
>> 1. (used in EntLib-CAB) is to NOT make the base-class static - each
>> Assembly creates it's own inheritor and intellisense shows any custom/
>> added and legacy members available (even if the members themselves are
>> static).
>> 2. make all checks extension-methods with a common Prefix - this also
>> allows to seemlessly extend the "library" giving context-sensitive
>> options for the type being checked.
>> Maybe this is something you can consider in a future refactor/
>> extension of this class...
> --
> You received this message because you are subscribed to the Google Groups "re-motion Users" group.
> To post to this group, send email to re-moti...@googlegroups.com.
> To unsubscribe from this group, send email to re-motion-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/re-motion-users?hl=en.
Reply all
Reply to author
0 new messages