Frage

This is part of a contract class for an interface.

[Pure]
public bool IsDirty() {
    throw new NotImplementedException();
}

public void Save() {
    Contract.Ensures(!this.IsDirty()); //WARNING
    throw new NotImplementedException();
}

It's producing this warning:

warning CC1036: CodeContracts: Detected call to method 'IEntityObject.IsDirty' without [Pure] in contracts of method 'EntityObjectContract.Save'.

...even though the Pure attribute is present. I've tried rebuilding, re-opening Visual Studio, but every time the same results. Any idea how to get rid of this warning? Am I missing something?

War es hilfreich?

Lösung

Looks like it's looking for the attribute in the IEntityObject.IsDirty() method.

It would seem to me that you need to add this attribute to the method declaration in the interface?

public interface IEntityObject
{
    [Pure]
    bool IsDirty();

    //...
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top