Trying out Code Contracts from Microsoft Research

Published 28 December 08 06:35 AM | llangit 

There are two sections that get added to VS 2008 after you install the add-in from MSR to test Code Contracts.  The first one is simply called 'Contracts'.

Contracts configuration in VS 2008

The second tab is named 'Code Contracts'. 

Code Contracts configuration in VS 2008

The MSR team did a presentation at PDC08 about Code Contracts and the Pex automated-testing tool.

In the area of contract-based coding at Microsoft, there is also Spec#.  Sample shown below.

using System;
using Microsoft.Contracts;

public class Program
{
  static void Main(string![]! args) 
  {
    Console.WriteLine("Spec# says hello!");
  }
  
  public int Add(int i, int j)
  
    requires i > 5;
    requires j < 3; 
    {
        int r = i + j;
        return r;
    }
    
}

Have you had time to look at contract-based coding?  What do you think about it?

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Trying out Code Contracts from Microsoft Research | Coded Style said on December 28, 2008 1:41 AM:

PingBack from http://www.codedstyle.com/trying-out-code-contracts-from-microsoft-research/

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker