如何在 C++/CLI 项目中使用代码契约?
我最近偶然发现了代码契约,并开始在我的 C# 项目中使用它们。不过,我也有一些用 C++/CLI 编写的项目。
对于 C# 和 VB,代码契约在项目属性对话框中提供了一个方便的配置面板。对于 C++/CLI 项目,没有这样的面板。
从文档中,我得到的印象是,向 C++/CLI 项目添加代码契约支持应该是一个简单的事情,只需在构建过程中调用一些外部工具即可(即 ccrefgen.exe、>cccheck.exe
和 ccrewrite.exe
)。然而,命令行选项的数量和有关调用顺序的限制让我有些害怕。
有人可以向我指出一种简单的方法来运行代码契约工具作为 Visual Studio 中构建过程的自动化部分吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我来到这个 stackoverflow 页面是因为我正在寻找与原始发布者正在寻找的答案相同的答案。到目前为止,我的搜索似乎表明“代码契约”本身不适用于 C++ 本机代码。然而,有一个类似的东西叫做“VC++(Visual C++)源注释”。
尝试以下链接:
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
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