Contract reference assemblies

Published Wed, Nov 19 2008 22:29

If you look closely at your bin folder, you’ll see that besides getting your project’s assembly, you’ll also have another assembly with the your_Assembly_name.Contracts.dll name. This assembly is known as the contract reference assembly and it only has the public “interface” of the types defined on your assembly and their respective contracts.

Why do we need this assembly? It is used during the rewriting process to inherit contracts across assemblies. According to the docs, they’re also used for static analyses to discover contracts on methods from other referenced assemblies when you’re performing static validation on a project.

So, this kind of assembly is really important and you should generate them and redistribute them with your assemblies. If you’re using VS, then don’t worry because they will be automatically generated for you. If you’re not using VS or the code contract msbuild task to build your project, then you’ll need to use the command line asmmeta.exe to generate it.

And I guess that this means that the intro series on code contracts is over. It’s time to pick another subject…suggestions?

Filed under: ,

Leave a Comment

(required) 
(required) 
(optional)
(required)