0

I found a strange behavior in contract code tool in VS.

The image above shows no error after building the project: enter image description here

but when I add some code on, it shows the error: enter image description here

What am I missing?

MuriloKunze
  • 15,195
  • 17
  • 54
  • 82
  • Please show us your code so we have something to work with. – ionutioio Oct 14 '14 at 16:06
  • @ionutioio my code is in the images. – MuriloKunze Oct 14 '14 at 16:20
  • I'm sorry but no image is visible on my end. – ionutioio Oct 14 '14 at 16:27
  • Image1: http://i.stack.imgur.com/WVgkX.png Image2: http://i.stack.imgur.com/fpVev.png – MuriloKunze Oct 14 '14 at 16:41
  • I can't explain this weird behavior but I do recommend you rethink your use of contracts in the Sum method. You're expecting Contract.Ensures to validate _invocations_ of the method, but that's not its job so I'm not surprised that it's acting flaky. You should instead be relying on Contract.Requires to validate invocations (but of course keep Contract.Ensures to validate the result). – Keith Oct 15 '14 at 15:39

0 Answers0