views:

110

answers:

1

I recently stumbled upon Code Contracts and have started using them in my C# projects. However, I also have a number of projects written in C++/CLI.

For C# and VB, Code Contracts offer a handy configuration panel in the project properties dialog. For a C++/CLI project, there is no such panel.

From the documentation, I got the impression that adding Code Contracts support to a C++/CLI project should be a simple matter of calling some external tools as part of the build process (namely ccrefgen.exe, cccheck.exe, and ccrewrite.exe). However, the number of command line options and restrictions concerning the call sequence have me somewhat intimidated.

Can anybody point me to a simple way to run the Code Contracts tools as an automated part of the build process in Visual Studio?

+1  A: 

I arrived at this stackoverflow page because I am searching for the same answers that the original poster is looking for. So far, my searches seem to indicate that "Code Contracts" per se are not available for C++ native code. However, there is something similar called "VC++ (Visual C++) source annotations".

Try the following links:

http://dotnetslackers.com/articles/net/code-contracts.aspx#visual-c-source-annotations

http://social.msdn.microsoft.com/Forums/en/vstscode/thread/db48da4d-fc93-4e99-99cc-22d47c5838e9

que que
Hi que que, Code Contracts are designed to work only with managed code. They work with C# and VB; they can potentially work with C++/CLI; they cannot work with native C++.My original question was about support for C++/CLI. For native C++, your answer might be a good solution.
Daniel Wolf