Giter Site home page Giter Site logo

Comments (4)

RxDave avatar RxDave commented on May 20, 2024

Adding a post-condition shouldn't be a problem. Did you try adding it? If you're getting another warning or an error then it may be a bug in Code Contracts.

The rule is: You can't add preconditions to inherited members, but you can add post-conditions. See Liskov Substitution Principle.

from codecontracts.

aarondandy avatar aarondandy commented on May 20, 2024

While you can add post conditions I have found in my experience that CC seems to ignore them. Not sure if this is a bug or not.

from codecontracts.

aarondandy avatar aarondandy commented on May 20, 2024

When I make contract classes (sorry if my assumption is wrong) for interfaces I get around these issues by using abstract override or abstract to signal that I don't want to add a contract for that method or property.

In this case you could probably just do abstract bool ICollection.IsSynchronized { get; } and leave it out of your contract class.

from codecontracts.

tom-englert avatar tom-englert commented on May 20, 2024

You're right, adding a post condition works in this case. I expected to get the "x is implementing y, thus can't add contracts" warning - so I didn't try.

from codecontracts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.