I've got Code Contracts working fine from inside Visual Studio 2010, but I can't get ccrewrite.exe
to do anything useful from the command line. Here's a sample app:
using System.Diagnostics.Contracts;
public class Dummy
{
public static void Main(string[] args)
{
Contract.Requires(args.Length > 0);
}
}
I then compile the code and run ccrewrite.exe on it:
> csc /debug+ /D:CONTRACTS_FULL Dummy.cs
> ccrewrite /o:RewrittenDummy.exe Dummy.exe
elapsed time: 61ms
There's no RewrittenDummy.exe
file afterwards.
I've tried loads of options, but nothing's making any difference. A few things I've noticed:
- It's definitely loading Dummy.exe, because if I specify a non-existent file, it dies
- Dummy.exe definitely contains references to Contract - if I run it with no arguments, it fails appropriately (but the error message hasn't been filled in as I'd expect if it had been rewritten)
- Using postconditions and invariants makes no difference
I've tried turning warnings and verbosity up, and that doesn't help at all
What am I doing wrong?
(Also asked as a question in the Code Contracts forum. I'll add any relevant answers here myself.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…