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

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user