Code Contract Elements

The Code Contracts Library created by Microsoft contains a tool (ccdocgen) that can be ran after a build to insert contract XML documentation elements into the XML comments file for an assembly.

  Important

The Code Contracts Library project appears to have been abandoned. As such the Sandcastle Help File Builder no longer provides any support for these elements. Support could be added through a plug-in to add handlers for them if necessary.

Below is a list of the elements that the tool may insert into each member. Refer to the Code Contracts user manual for more information (section 8 at the time this topic was written).

Element

Description

ensures

May appear under method elements, property getters, and property setters. The element body is the string of the original postcondition.

ensuresOnThrow

May appear under method elements, property getters, and property setters. The element body is the string of the original exceptional postcondition.

invariant

May appear under classes. The element body is the string of the original invariant.

pure

May appear under methods marking them as pure. No additional information is present.

requires

May appear under method elements, property getters, and property setters. The element body is the string of the original precondition.

See Also

Other Resources