Requires unproven in constructor using Regex


hi,

i'm trying ensure id string has specific format, , tries ensure using regular expression. results in 'requires unproven', , fail see why happens? isn't simple matter of evaluating bool?

thanks, rasmus

 

code example:

using system;  using system.collections.generic;  using system.linq;  using system.text;  using system.diagnostics.contracts;  using system.text.regularexpressions;    namespace test  {      class id      {          public static regex re = new regex("^test$");          private string id;            public id(string id)          {              contract.requires(id.re.ismatch(id));              this.id = id;          }            [contractinvariantmethod]          private void invariant()          {              contract.invariant( id.re.ismatch( this.id ) );          }      }  }  

hi,

the static checker doesn't understand how evaluate regular expressions.  believe doesn't reason contents of strings yet either.

http://social.msdn.microsoft.com/forums/en/codecontracts/thread/85bcff4f-fe02-43a2-b887-dfcaab7ba63a

- dave


http://davesexton.com/blog


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