"System.Diagnostics.Contracts" vs "Code Contracts for .NET"(Extension) RRS feed

  • Question

  • I'm a litle confused.

    I'm learning about Code Contracts.

    But it seems that they are included in the .NET Framework 4+, in the "System.Diagnostics.Contracts" namespace.

    I thought they were installed with Visual Studio 2012.

    So whats the difference between the "System.Diagnostics.Contracts" namespace and Visual Studio 2012 and the "Code Contracts for .NET"(Extension) ??

    Whats included in the extension that is not included in the Visual Studio 2012/.NET4+  ??

    Could I still use/deploy Code Contracts without installing the VS extension ??



    Monday, March 25, 2013 7:35 PM


  • "Code Contracts for .Net" is a set of tools for 

    1) Interpretting IL to extract contract declarations

    2) Rewriting IL to insert run-time checks as indicated by contract declarations

    3) Using extracted contract declarations to attempt to prove truths about the code.

    Contract declarations are made using the System.Diagnostics.Contracts.Contract class, which happens to be included in .Net 4.0's BCL. Those declarations are however useless if they are not interpretted by the "Code Contracts for .Net" tools.

    Additionally, there are extensions to Visual Studio to integrate the CC system with it, to provide syntax highlighting etc.

    Monday, March 25, 2013 8:29 PM