I am new to codeContracts,I like it because it seems clean.
I dont like the fact that I need to download a library to make it work.Never understood why microsoft didnt make it part of the framework as whole.
I dont want to impose other collegues in the team to download it.
Questions:
Can I download the extensions and add the dlls to the build so that if they get the latest or or work on it they have nothing to do?
Is there anything to know before deploying an app with Codecontracts inside?
thanks
In .NET 4.0, you don't need to download or add any libraries to the project in order to be able to add code contracts to your code. The part that you download are the tools for static analysis and ccrewrite. If you are using an older version of .NET, I suggest you upgrade to 4.0 before starting to use Code Contracts.
As long as you use only the static analysis features (Static Contract Checking), you can use it without directly interfering with the development process of other developers (keep reading though). In this case nothing changes in terms of compilation or deployment.
If you were meaning to enable Perform Runtime Contract Checking, then you should get everyone on the team to use the tools. You should also make sure that your build server is able to produce the same results as your local Visual Studio. This is because as soon as you enable that feature, code contracts start to influence runtime behavior. Obviously, the behavior of the code must be the same for everyone.
Even if you decide to use only static features for now, there is a downside to not having everyone on the team using the tools: they won't be able to properly maintain the code that makes use of code contracts. Refactoring might require changes to the contracts, but without the tools they can inadvertently introduce a lot of warnings that you will have to fix if you're the only one with the tools.
That being said, I've worked with code contracts in specific parts of a shared code base without the rest of the team using them without any significant problems. Of course, you should still talk to your colleagues about it, so they won't run into any surprises when maintaining your code. The only times where my use of code contracts forces them to do some extra work, is when they add a method to an interface I've defined a contract for. The contract is in an abstract class implementing that interface, which means they will have to add a minimal implementation of that new method to the abstract class.