Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run code-contracts analysis manually?

When I rebuild my C# app I often don't get the results of my code-contracts analysis. This is caused by the following error message

CodeContracts: MyApp.Client.Model: Analysis method MyApp.Client.Model.MyClass.CreateCalculatedElements(System.Collections.Generic.List1<System.Collections.Generic.KeyValuePair2<System.String,MyCompany.Scripting.ICompiledFunction1<System.Object>>>,System.Collections.Generic.Dictionary2<System.String,MyCompany.Scripting.ICompiledFunction1<System.Decimal>>,System.Collections.Generic.Dictionary2<System.String,MyCompany.Scripting.ICompiledFunction1<System.Decimal>>) timed out

Here is the definition of the method

internal void CreateCalculatedElements(
List<KeyValuePair<string, ICompiledFunction<object>>> preFinalCalculationScripts,
Dictionary<string, ICompiledFunction<decimal>> factorCalculators,
Dictionary<string, ICompiledFunction<decimal>> elementCalculators)

This doesn't always time out. Is there a way I can manually run contract checking just for one project rather than all of them via a rebuild-solution?

like image 981
Peter Morris Avatar asked Mar 23 '26 18:03

Peter Morris


1 Answers

You can increase the timeout for that project by adding an extra option to the static checking options in the property pane as follows: -timeout

The default is 180, which is per method.

As to your original question, yes you can run the tools manually as follows:

Say your project P is in directory D, then go to D\obj\Debug\Decl. In there you'll find a convenient file called Pcccheck.rsp which contains the parameters which were passed to cccheck during the build. To run the analysis again, you simply issue: cccheck @Pcccheck.rsp

Right now, there isn't an option to trigger a re-analysis of just one project without a rebuild.

like image 146
Manuel Fahndrich Avatar answered Mar 25 '26 06:03

Manuel Fahndrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!