Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Code Contracts in a C++/CLI project?

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?

like image 629
Daniel Wolf Avatar asked Nov 20 '09 11:11

Daniel Wolf


1 Answers

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

like image 156
pestophagous Avatar answered Sep 18 '22 12:09

pestophagous