Code contract: warning not shown when using the overload that receives a message RRS feed

  • General discussion

  • Hello guys.

    I've just started using code contract and I've got a question regarding this code: 

    namespace DemoProject {
       class Student {

           public Student(Int32 studentId)
               CodeContract.Requires(studentId > 0, "Student Id must be a
               StudentId = studentId;

           public Int32 StudentId { get; private set; }

       class Program {
           static void Main(string[] args) {
               var st = new Student(-1);

    Ok, I was expecting static analysis to detect the -1 and give me a warning but that didn't happen. WHen I removed the message, I got the warning, so I think that there might be a bug with the overloaded version that uses the message. As expected, everything works out great at runtime.

    btw, I'm running vista x64 and VS 2008 with service pack 1.


    Luis Abreu
    Thursday, November 6, 2008 9:21 AM

All replies

  • Yep, sorry about that. The released version does not yet recognize the two-agument versions of the contract methods for the static checking. We will fix that, but it might not happen in the very next release.

    Thursday, November 6, 2008 9:09 PM
  • Hello Mike.

    No problem. Just wanted to be sure that it's a known bug (I was building a proof of concept with the framework and was porting old code which used the same principles - ok, similar, since it would only perform runtime validation - that passed an error message when the contract was broken).

    One thing you guys need to work  out is the license...come one, academic license? please, please, please give us go live like the other beta platforms do (ex.: ASP.NET MVC).

    keep up the good work and thanks again.

    Luis Abreu
    Thursday, November 6, 2008 9:14 PM
  • Hi Luis,

    The academic license is what we were able to get out fast. A commercial use license is coming in the next months.


    Friday, November 7, 2008 4:05 PM
  • Cool! Can't hardly wait for it!

    Thanks and keep up the good work...

    Luis Abreu
    Friday, November 7, 2008 8:26 PM