Manuel Fahndrich and Peli de Halleux - The Synergy of Code Contracts and Pex

Play Manuel Fahndrich and Peli de Halleux - The Synergy of Code Contracts and Pex

The Discussion

  • User profile image
    I'm having problems downloading this (in that I cannot at the moment).

     Anyone else have any joy?
  • User profile image

    thats really cool Smiley
    ive been using pex for a while and its really quite amazing how complex tests it can create  Smiley

  • User profile image
    Hi Vesuvius, there were some little errors in the URLs. Do you still have this problem?
  • User profile image
    No, the problem is fixed now.

    Thank you.
  • User profile image
    It's quite nice to see this for .Net, especially with the smart code injection.

    The embedded contract language is not as clean as in Eiffel, obviously
         put (x: ELEMENT; key: STRING) is
                         -- Insert x so that it will be retrievable through key.
                         count <= capacity
                         not key.empty
                         ... Some insertion algorithm ...
                         has (x)
                         item (key) = x
                         count = old count + 1
    Also.  I don't quite agree that ensurances should come first (contrary to Eiffel), but granted, using the embedded technique where ther contracts are blended in with the rest of the code, it may be a better technique for readability. Maybe.
    It's also striking how much use of contracts can be devoted to the type constraint for reference types that nullness not be part of the domain. How nice it would be with a simple language extension, even if only interpreted as a contract
         add (Point! x)
    It's again the annoying wrong-default situation; as with of nullness over non-nullness there's also the variance over invariance (well, im/mutability if you will).
    That Code contracts actually implements the old- and result-semantics is very nice. 
    Can we now expect .Net to be littered with Code Contracts all over for increased code correctness?
    (oops, there goes the beautiful formatting heh)
  • User profile image
    Sure, language syntax would be nice, but that's the language designers job. We've been there (Spec#), done that. We can only influence main stream languages so much. What we are doing now is providing mechanisms and tools without being language designers. Languages can then opt-in and provide whatever syntax they want.

    The advantage to the programmer of course is that in the meantime, until language designers make up their mind, they can already work with this technology.
  • User profile image
    Does it work with the code contracts feature in .net 4.0?
  • User profile image

    Yes - Code Contracts is the contract feature of .net 4.0 and Pex can already handle .net 4.0 processes. Since the Contracts API is still evolving there might be a difference between the .net 4.0 CTP release and the latest Code Contracts download (which Pex supports).

    If you face any issues, don't hesitate to shoot emails in our forums at

  • User profile image

    It makes sense, in the context of .NET, that this tooling is designed to be language independent (just like .NET...). Why should every managed language have to provide the same internal semantics and language-appropriate syntax when a single shared library and IDE toolset gives all CLS compliant languages the same functionality for free? I think you guys are doing the right thing here.

    Keep on pushing the envelope (independent of language design).

Add Your 2 Cents