I've just tried to use Code Contracts in my application. As soon as I've enabled that feature of c# 4.0 I got a big window with message:
nCrunch.TaskRunner40.x86.exe - Assert Failure
Description: Must use the rewriter when using Contract.Ensures
Stack Trace:
at System.Diagnostics.Contracts.Contract.AssertMustUseRewriter(ContractFailureKind kind, String contractKind)
at System.Diagnostics.Contracts.Contract.Ensures(Boolean condition)
at ClassLibrary2.Class1.Dodawanie(Int32 a, Int32 b)
at ClassLibrary2.Class1.TestName()
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Gallio.Common.Diagnostics.ExceptionUtils.InvokeMethodWithoutTargetInvocationException(MethodBase method, Object obj, Object[] args)
at Gallio.Framework.Pattern.PatternTestInstanceState.InvokeTestMethod()
at MbUnit.Framework.TestAttribute.Execute(PatternTestInstanceState state)
at Gallio.Framework.Pattern.PatternTestExecutor.ExecuteTestInstanceAction.Run()
at Gallio.Common.Concurrency.ThreadAbortScope.Run(Action action)
at Gallio.Framework.Sandbox.Run(MarkupDocumentWriter markupDocumentWriter, Action action, String description)
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestInstanceAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestDataItemAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestInstanceAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestDataItemAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestInstanceAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestDataItemAction.Run()
at Gallio.Framework.Pattern.PatternTestExecutor.RunTestAction.Run()
at Gallio.Framework.Pattern.PatternTestController.RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
at Gallio.Model.Helpers.DelegatingTestController.RunTest(ITestCommand testCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
at Gallio.Model.Helpers.DelegatingTestController.RunTest(ITestCommand testCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
at Gallio.Model.Helpers.DelegatingTestController.RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
at Gallio.Model.Helpers.SimpleTestDriver.RunTestCommandsAction.Run()
at Gallio.Model.Helpers.SimpleTestDriver.RunAssembly(Assembly assembly, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.DotNetTestDriver.ExploreOrRunTask.ExploreOrRun(Type driverType, Object[] driverArguments, String assemblyPath, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor, Boolean useSynchronousMessaging)
at Gallio.Model.DotNetTestDriver.ExploreOrRunTask.RunImpl(Object[] args)
at Gallio.Model.Isolation.IsolatedTask.Run(Object[] args)
at nCrunch.GallioIntegration.NCrunchTestIsolationContext.InvokeTask[TIsolatedTask](IHost host, TIsolatedTask isolatedTask, Object[] args)
at Gallio.Model.Isolation.HostedTestIsolationContext.RunIsolatedTaskInHost[TIsolatedTask](HostSetup hostSetup, StatusReporter statusReporter, Object[] args)
at Gallio.Model.Isolation.HostedTestIsolationContext.RunIsolatedTaskImpl[TIsolatedTask](HostSetup hostSetup, StatusReporter statusReporter, Object[] args)
at Gallio.Model.Isolation.BaseTestIsolationContext.RunIsolatedTask[TIsolatedTask](HostSetup hostSetup, StatusReporter statusReporter, Object[] args)
at Gallio.Model.DotNetTestDriver.ExploreOrRunAssembly(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, RemoteMessageSink remoteMessageSink, IProgressMonitor progressMonitor, String taskName, FileInfo file)
at Gallio.Model.DotNetTestDriver.ExploreOrRun(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor, String taskName)
at Gallio.Model.DotNetTestDriver.RunImpl(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Run(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.<>c__DisplayClass1f.<RunImpl>b__1d(ITestDriver driver, IList`1 items, Int32 driverCount)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.ForEachDriver[T](MultiMap`2 testFrameworkPartitions, Func`4 func)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.RunImpl(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Run(ITestIsolationContext testIsolationContext, TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Runner.DefaultTestRunner.Run(TestPackage testPackage, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IProgressMonitor progressMonitor)
at nCrunch.TestExecution.Frameworks.Gallio.GallioTestFramework.#=qP8mqIFwTfEa9WIBfpa5D3qCoKglIKVshOQCFQ$7b7dw=.#=qMvas4948MaQS4aPjrWtf2g==()
at #=qmdEAMK_c0wUkjl8QiR_0B$SqavkVGH8_WBLRdXnGACXX4ij_QGiQi6Yyi3LkqyId.#=qM5vw4cReHtB0oIZAADXisWrKqcIWrMteVT2lL5CSY$Y=(Action #=qQG$$IEqJNd7U57rti2oO0eMOr5L73KqDbcsBxL9FrLo=)
at nCrunch.TestExecution.Frameworks.Gallio.GallioTestFramework.RunTests(TestOutput output, IList`1 testsToRun, MasterExecutionMapSet masterMapSet)
at nCrunch.TestExecution.TestRunnerThread.#=qh9mHFD74qNv_qxnwJeExOA==(IMasterExecutionMap[] #=qk1TQlxFS2PvZulTUk4olrnb6ZWeHHkBAUGvy2pOCQ04=, IList`1 #=q_93JaZI9Uj9vyZ1g2aaI8Q==)
at nCrunch.TestExecution.TestRunnerThread.#=qMatA7O7HNDNftSAGqk$zXwsRyZMSQlaG4AK$V7qYeZE=()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Press RETRY to attach debugger
Regards,
4rchie