6

I have Resharper and it's a fantastic tool Starting a projects and I need to use CodeContracts. However Resharper ignores them. After checking a few blogs I came across this one:

http://www.infinitec.de/post/2010/11/18/Using-Code-Contracts-Visual-Studio-and-with-Resharper.aspx

However I get an error

Error   2   

The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" 
"@MyProject.Coreccrewrite.rsp"" exited with code 1.

Has anybody managed to have codecontracts and resharper to work together?

Edited

What I am doing is

Trying to use codeContract and resharper gives a Method invocation is skipped etc..

Googled and found lots of people with same problem and no solution.

As you can see I attached a link that should have done the trick but didnt

Create a new project in vs2012 and try to use code contract and resharper will not let you. It will be disabled and if you enable it you get another error

Comment from Resharper team on http://youtrack.jetbrains.com/issue/RSRP-182553#comment=27-200330

ReSharper will not support "Code Contracts" as is in the mid-term future. There are 2 main reasons for this:

  1. CodeContracts are written in the code block, and, moreover, in the separate assembly. ReSharper requires contracts to be at the metadata level
  2. Current contract are too complex and are not supposed to be analyzed in real-time.

During ReSharper development, we analyze CodeContracts and building corresponding ReSharper code annotation marks. We are going to extent our annotations, and always keep them in-sync with contracts.

I am stuffed!!!

StuartLC
  • 104,537
  • 17
  • 209
  • 285
user9969
  • 15,632
  • 39
  • 107
  • 175
  • 3
    You're hardly going to have any luck with that combination, and [here's why](http://youtrack.jetbrains.com/issue/RSRP-182553#comment=27-200330) – Jura Gorohovsky Oct 21 '12 at 12:07
  • mmm. So i am stuck now! I am the only one in my team who uses resharper and I am part of this projects that has to implement codecontracts,Not my decision!.Really stuck now ,Unless I remove resharper for this project – user9969 Oct 21 '12 at 12:35
  • Well, sometimes even ReSharper has to lose. Not sure you'd be able to implement [ReSharper's contract annotations](http://blogs.jetbrains.com/dotnet/2012/08/contract-annotations-in-resharper-7/) instead – Jura Gorohovsky Oct 21 '12 at 17:05
  • I'm not sure that this error has something to do with ReSharper. ReSharper would not analyze codecontracts and may give bogus errors because of that, but still everything is supposed to work. Please give more details of what are you doing. – Dmitry Osinovskiy Oct 21 '12 at 18:41
  • @Dmitry Osinovskiy edited question with more details.Just create a vs2012 project and try to use codecontract with resharper installed and see – user9969 Oct 21 '12 at 19:25
  • 1
    I am using Visual Studio 2012 and Resharper 7.x with Code Contracts. all the time and without problems. You have to add an external Code Annotation file for Resharper to make it really work. Look here: http://stackoverflow.com/questions/929859/resharper-possible-null-assignment-when-using-microsoft-contracts/13915027#13915027 – Michael A. Volz aka Flynn Dec 17 '12 at 13:33

0 Answers0