This project is read-only.

[offtopic] Microsoft.Contracts annotations

Topics: Metadata Model
Mar 25, 2010 at 4:39 PM

Hi, sorry to be offtopic but I could not find information about this anywhere.

I noticed the //^ prefixed annotations in the sourcecode which look like Spec# contracts in C# source. Does anyone have information about those contract annotations? How do you process/check them?

I downloaded the CodeContracts package for VS 2008 but it seems to use method calls instead of comments. Google yields no results either, probably because I don't know what keywords to search for. The code contracts coming with C# 4.0 seem to be based on method calls as well.

The reason I'm interested in this is that I'd like to use the static checker without adding a hard dependency to Microsoft.Contracts.

Mar 25, 2010 at 4:58 PM

The CCI code base was originally developed using Spec#, but using the C# compatible comment convention. It turned out that CCI is not a good match for the Spec# methodology. Also the size of CCI overwhelms Spec#. So now the comments are just comments.

Eventually, I hope that the code base will be annotated with Code Contracts, but that is quite a big job and my time is very limited, so it won't be done by me.

Mar 25, 2010 at 6:04 PM
Edited Mar 25, 2010 at 6:07 PM
Ah, too bad, but thanks a lot for the reply!

[random idea]
Maybe it would be interesting to write a tool (MSBuild task?) to preprocess C# source files with those kinds of comments and replace them by actual CodeContracts statements. Though with C# 4.0 around the corner it may not be worth the effort, if CodeContracts are part of the standard DotNet installation a hard dependency would be no problem anymore. I guess I'll wait and see.