Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

CodeContracts not working in VS2017 #476

Open
RealDotNetDave opened this issue Jan 5, 2017 · 28 comments
Open

CodeContracts not working in VS2017 #476

RealDotNetDave opened this issue Jan 5, 2017 · 28 comments

Comments

@RealDotNetDave
Copy link

This extension does not work in VS2017 RC. Most of my projects will not compile since I use this for all of my DLL assemblies.

@SergeyTeplyakov
Copy link
Contributor

Unfortunately, Roslyn compiler changed a lot of codegen and to add support for VS2017 reasonable amount of changes is required for all 3 projects: CCI, ccrewrite and cccheck.

@RealDotNetDave
Copy link
Author

Does that mean CC is dead in 2017?

@SergeyTeplyakov
Copy link
Contributor

Hopefully not, but significant amount of work is required to keep it alive.

@RealDotNetDave
Copy link
Author

Do you know a timeline? None of my DLL projects will compile.

@chrisaut
Copy link

chrisaut commented Jan 6, 2017

I have the same issue, I bet on CC for some largish projects.

As much as I love it and will miss it, I think everyone should seriously consider getting them out of their code base sooner rather than later. There is just not enough commitment there from either MS or the volunteers here (I don't blame them, it was always made clear that it's a non supported technology).

I can only hope that the idea of CC will live on, there are proposals to bake contracts into C# and the runtime proper.

@ContentsMayVary
Copy link

It seems that some people have got it sort of working; see #451

@tom-englert
Copy link
Contributor

It worked for me, but I have tried only with VS2015 compatible sources; from the comments above it seems to break as soon as you use any new VS2017 compiler feature.

@manison
Copy link

manison commented Jan 10, 2017

It is my understanding that one of the issues is support for the new PDB format. I believe this can be worked around by switching back to the old format (setting Debug Type from Portable to Full or PdbOnly).

Is there a list of tasks that needs to be done to support VS2017? Anything up for grabs? We're also relying on CC heavily.

@wischi-chr
Copy link

wischi-chr commented Feb 25, 2017

Very sad that such a great concept will die this way. Removed CC from most of my projects today and switched back to if throw guards. Will miss Interface Contracts though...

@ContentsMayVary
Copy link

Well we've just gone through the process of converting all our code contracts to use a simple contracts replacement class that we wrote. No support for interface contracts, of course. Such a shame.

@RealDotNetDave
Copy link
Author

I agree! Lots of code quality missing from .NET Core.

@lesonkorenac
Copy link

Would it be possible to create release of version, that is working on Visual Studio 2017? From what I've learned here, there is sort of working version available (#451).

Or at least post somewhere compiled binaries.

I have problems compiling it myself, since I could not find any detailed tutorial. There seems to be a lot of prerequisites, that are not mentioned anywhere.

@yaakov-h
Copy link
Contributor

You can get the base functionality by building from master. Just run buildcc as outlined in the readme, from the Developer Command Prompt for VS2013.

@lesonkorenac
Copy link

I managed to build Code Contracts from master few month ago, after figuring out some error messages (like that I need to install tools for building C++ in Visual Studio) and adding some references to projects in solution.

Sadly, version that I managed to build does not work on new machine and now I've used Visual Studio 2017 instead of Visual Studio 2015 for building Code Contracts and I have another set of errors. And after few hours of solving the errors I've got stuck on this:

"c:\PathTo\CodeContracts\Microsoft.Research\ManagedContract.Setup\buildMSI10.xml" (All target) (1) -> "c:\PathTo\CodeContracts\CodeContracts.sln" (Clean;Rebuild target) (2) -> "c:\PathTo\CodeContracts\Microsoft.Research\ManagedContract.Setup\CCRefGenAttributes\CCRefGenAttributes.csproj" (Rebuild target) (70:2) -> (ContractDeclarativeAssemblyCS target) -> C:\Program Files (x86)\Microsoft\Contracts\Languages\CSharp\ContractDeclarativeAssemblyAttribute.cs(14,6): error CS0246: The type or namespace name 'ContractVerificationAttribute' could not be found (are you missing a using directive or an assembly reference?) [c:\Users\janpe\Development\C#\CodeContracts\Microsoft.Research\ManagedContract.Setup\CCRefGenAttributes\CCRefGenAttributes.csproj] C:\Program Files (x86)\Microsoft\Contracts\Languages\CSharp\ContractDeclarativeAssemblyAttribute.cs(14,6): error CS0246: The type or namespace name 'ContractVerification' could not be found (are you missing a using directive or an assembly reference?) [c:\Users\janpe\Development\C#\CodeContracts\Microsoft.Research\ManagedContract.Setup\CCRefGenAttributes\CCRefGenAttributes.csproj]

I is very annoying, that there is no release of Code Contracts for Visual Studio 2017. And even more so, that I'm not able to build it on my own.

As I read through issues here and on Stack Overflow, developers are abandoning Code Contracts because there is no version available for Visual Studio 2017 and soon I may be one of them.

I don't want to blame someone, that I'm not able to use it. I just want to say that it would be helpful for me and other developers to have access to compiled binaries of current version.

@yaakov-h
Copy link
Contributor

yaakov-h commented Jul 4, 2017

@lesonkorenac

now I've used Visual Studio 2017 instead of Visual Studio 2015 for building Code Contracts and I have another set of errors

Use Visual Studio 2013. This is the only version that is actually supported as a build environment for Code Contracts.

You can download the AppVeyor build artifacts for master at https://ci.appveyor.com/project/SergeyTeplyakov/codecontracts/build/1.10.10311.145/artifacts

If you'd rather a NuGet package, I've uploaded a copy of the build I use here: https://github.com/WiseTechGlobal/CodeContracts/releases/tag/wtg%2Frel%2Fv1.10.20308.4

@lesonkorenac
Copy link

Thank you. It helped a lot.

I did not know that Visual Studio 2013 is the only supported version (I've added this information on wiki).

I would also recommend to modify README.md, since instructions for building are incomplete (there is no mention about Visual Studio 2013 or Developer Command Prompt)

For working on the project, open CodeContracts.sln and build.

To create the installer and the nuget package, just run buildCC .

Thank you again.

@AbbottWC
Copy link

AbbottWC commented Aug 4, 2017

This is less than ideal. I'd already moved my projects from VS 2015 to VS 2017 when this gem popped up. Again. I'm glad I came upon this, and that VS2015 is still able to open projects that have been modified in VS 2017, because I'm gutting this from my code right now and not looking back...

@MkazemAkhgary
Copy link

MkazemAkhgary commented Nov 23, 2017

Hopefully not, but significant amount of work is required to keep it alive.

will contract team start to rework code contracts to adopt with latest? I started to use code contracts (unaware of this issue) in my UWP projects. now I have to rollback everything :( @SergeyTeplyakov

@yaakov-h
Copy link
Contributor

@MkazemAkhgary as far as I can tell, there is no contracts team any more. Don’t hold your breath.

@MkazemAkhgary
Copy link

thanks for letting me know. I was late to the party but I think it was good feature. @yaakov-h

@MartinEgli
Copy link

Is there any version for Win10

@yaakov-h
Copy link
Contributor

OS version is irrelevant... this does work on Win10.

@MartinEgli
Copy link

Does the msi install the tool on VS2017?

@Mzangwe
Copy link

Mzangwe commented Apr 24, 2018

Team, hi

This works out of the box in Visual Studio 2017. It is part of the: System.Diagnostics.Contract.

See exemple below:
Contract.Requires<ArgumentNullException>(amount > 0, "Amount to deposit must be positive.");

@yaakov-h
Copy link
Contributor

Without the tooling, that will only ever throw an exception saying you must use the rewriter.

@alexagranov7
Copy link

@MkazemAkhgary as far as I can tell, there is no contracts team any more. Don’t hold your breath.

Is this for real?

@adimosh
Copy link

adimosh commented Feb 7, 2019

@MkazemAkhgary as far as I can tell, there is no contracts team any more. Don’t hold your breath.

Is this for real?

Latest commit March 2017. I'd say this is the case.

@yaakov-h
Copy link
Contributor

yaakov-h commented Feb 7, 2019

That's just a merge commit. The most recent commit with content, authored by somebody at Microsoft, was May 2016.

Also, the last lead developer from Contracts left Microsoft Research for Facebook about a week after this repo was published...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests