Code Contracts
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Code Contracts

  1. #1
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Code Contracts

    I've read an article "Code Contracts in .NET" by cilu recently, but I'dont understood all, so I'd ask few more question:

    1. What is the difference between code contracts and assertions (e.g. Debug.Assert)?

    2. Are they enforced by compiler in some way, or work only in run-time?

    3. What is the main benefit?
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Code Contracts

    No, they are not enforced by the compiler. There are tools that compile the contracts separately and can modify the MSIL code to assert at runtime, if you have the runtime check enabled. If you have these tools it's like you don't even have the contracts in your code.

    You can read more about it here: http://research.microsoft.com/en-us/projects/contracts/.

    As for the difference between Debug.Assert, the Contracts.Assert is that the later is recognized by these tools, while the former isn't.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center