Fakes and CodeContracts ContractInvariantMethod gives CS1056, CS1518, CS1519, CS1001 - by Kevin Fletcher

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


15
0
Sign in
to vote
ID 776183 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 1/9/2013 4:50:24 PM
Access Restriction Public

Description

There seems to be an incompatibility between Fakes and CodeContracts when using the "Perform Runtime Contract Checking" option.
Sign in to post a comment.
Posted by Deon [MSFT] on 6/6/2014 at 9:53 AM
Thank you for using Visual Studio and for reporting this bug. We are happy to let you know that this issue has been fixed in Visual Studio 2013 Update 2. If you already have Visual Studio 2013, you can upgrade to Update 2 for free or you can install a trial version from: http://go.microsoft.com/?linkid=9832436
Posted by Oleg [MSFT] on 10/11/2013 at 3:05 PM
Thanks for reporting the problem. We have made changes in Visual Studio 2013 Update 1 to ignore properties, methods and events marked with the CompilerGeneratedAttribute when generating Stubs and Shims. The $InvariantMethod$ emitted by CodeContracts is marked with this attribute and will be ignored by the fakes code generator.

Thanks,
Oleg Sych
Posted by Oleg [MSFT] on 10/11/2013 at 3:04 PM
Thanks for reporting the problem. We have made changes in Visual Studio 2013 Update 1 to ignore properties, methods and events marked with the CompilerGeneratedAttribute when generating Stubs and Shims. The $InvariantMethod$ emitted by CodeContracts is marked with this attribute and will be ignored by the fakes code generator.

Thanks,
Oleg Sych
Posted by flipchart on 7/10/2013 at 11:07 PM
Hi!

This issue has been around for a while and is a real pain when trying to unit test code with Contracts using Fakes. Would it be possible to give a status update so that we know that it is being addressed. The workarounds aren't really viable for the long term, and this issue forces us to use other mocking frameworks in some situations. We really love Fakes and Contracts and want to use them, but this issue is stopping us.

Thanks for the hard work!
Posted by Microsoft on 1/14/2013 at 2:59 AM
Hi Kevin, thanks for your response, we have received your project. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Kevin Fletcher on 1/10/2013 at 1:46 AM
Find attached a (fairly) minimal project to reproduce. Please forgive the whimsy.

The project won't build as attached, but if you remove the comments on the #if directive, to prevent compilation of the Contracts Invariant check, it will.
Posted by Microsoft on 1/9/2013 at 11:23 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting a demo project. Please submit this information to us within 4 business days. We look forward to hearing from you with this information.
Posted by Macy [MSFT] on 1/9/2013 at 5:52 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)