Require non-null arguments by default?


hello,

i think find myself writing "contract.ensures(foo != null)" more want allow null parameters function. there existing way like:

[assembly:contractimplictnonnullarguments /* doesn't exist */]    class foo {      void foo1(string s) {        // implicitly: contract.requires(s != null)        ...    }      void foo2(string s) {      contract.canbenull(s); /* doesn't exist; disables implicit precondition */        ...    }  }
? (and maybe similar return values). if not, worthwhile new feature?

a simpler solution me perform source transformation add various contract.requires(x != null), each parameter x.

then, delete ones can null.

this has advantage of not extending contract api, keep tools are, make evident program text require -- instead of implicit behavior: not core of contracts? i.e., making assumption implicit?

ciao

f



DevLabs  >  Code Contracts



Comments

Popular posts from this blog

SQL Server 2008 - High Memory Usage

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

Problem In Configuring Biztalk 2009 In Creating A ReceivePort.When I Try To Create A Receive POrt I Got This Error