This is my code:
public class RegularPolygon
{
public int VertexCount;
public double SideLength;
public RegularPolygon(int vertexCount, double sideL
First thing to check - have you actually got contract checking turned on? If not, none of your contracts will do anything. That would explain the R# warning, too. Look under "Code Contracts" in the build properties, and see what it says under "Runtime Checking".
As per comments, ensure you have CONTRACTS_FULL
defined as a compilation symbol - that appears to be what R# requires.
Second point: you've got public mutable fields, which means your invariant can be violated at any moment by someone writing
polygon.VertexCount = 0;
Please don't use public fields, particularly not writable ones. :)