Does Sandcastle support code contracts?

My library uses code contracts.

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


Edit: Turns out this method is outdated; just install Sandcastle Styles.

Sandcastle doesn't support it natively but Code Contracts comes with the required files.

First ensure you are generating documentation for your assembly, then in the Code Contracts settings for your project, set Contract Reference Assembly to 'Build', and check the box for "emit contracts into XML doc file".

Next, open C:Program Files (x86)MicrosoftContractsSandcastleSandcastle.zip (or just C:Program Files... on a 32-bit installation - and the same for the instructions below).

What you have to extract depends on whether you installed Sandcastle with the MSI or from source (they're actually different versions):

  • if from the MSI, extract everything under msivs2005 to C:Program Files (x86)SandcastlePresentationvs2005 , and overwrite any conflicts.
  • if from source, extract everything under sourcevs2005 to C:Program Files (x86)SandcastlePresentationvs2005 , and overwrite any conflicts.
  • Finally, you need to create a new Sandcastle project. You can import your topics & settings from the old one in the wizard.

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


    It does work with Sandcastle though there are some tweaks necessary to integrate them fully. Refer to section 8.3 in the Code Contracts User Manual dated 2/4/2011 (or later) available at http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf


    The answers are now out of date.

    Sandcastlestyles now seems to be deprecated, and if you try to apply the patch supplied with the latest Code Contracts distribution (as of 13 Sep 2013) to the latest Sandcastle distro, then it will break Sandcastle presumably because the patch is no longer in sync with the Sandcastle release.

    链接地址: http://www.djcxy.com/p/59596.html

    上一篇: 有代码合同的条件属性例外

    下一篇: Sandcastle是否支持代码合同?