Does Sandcastle support code contracts?

My library uses code contracts.

Is there a way to include these contracts in the documentation generated by sandcastle?

+4
source share
3 answers

Edit: It turns out this method is deprecated; just install Sandcastle Styles .

Sandcastle does not support it, but Code Contracts comes with the necessary files.

First, make sure that you create documentation for your assembly, and then in the "Code Contract" settings for your project, set the "Contract Link Assembly" to "Build" and check the box "Emit Contracts to XML Document File".

Then open C:\Program Files (x86)\Microsoft\Contracts\Sandcastle\Sandcastle.zip (or just C:\Program Files\... on a 32-bit installation - and the same for the instructions below).

What you need to extract depends on whether Sandcastle is installed with MSI or from the source (they are actually different versions):

  • if from MSI, extract everything under msi\vs2005\ to C:\Program Files (x86)\Sandcastle\Presentation\vs2005\ and overwrite any conflicts.
  • if from the source, extract everything under source\vs2005\ to C:\Program Files (x86)\Sandcastle\Presentation\vs2005\ and overwrite any conflicts.

Finally, you need to create a new Sandcastle project. You can import your themes and settings from the old one in the wizard.

Then you should be able to run Sandcastle and have contracts in the documentation.

+7
source

It works with Sandcastle, although there are some settings necessary for their full integration. See Section 8.3 in the Code Contract User Guide dated 2/4/2011 (or later), available at http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf

+1
source

The answers are now out of date.

Sandcastlestyles now seems deprecated, and if you try to apply the patch that came with the latest Code Contracts distribution (as of September 13, 2013) to the latest Sandcastle distribution, it will probably break Sandcastle because the patch will no longer be in sync with Sandcastle release.

0
source

All Articles