DevLabs > DevLabs Forums > Code Contracts > Contract class for a static class
Ask a questionAsk a question
 

QuestionContract class for a static class

  • Wednesday, November 04, 2009 12:40 PMAlexey R. Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    How to avoid the warining "Class 'XContract' is annotated as being the contract for the abstract class 'X' but doesn't extend the class"?
    The class X static, static checker works ok with it, just the warining seems wrong:

    [ContractClass(type(XContract))]
    static class X
    {
      [DllImport("some.dll")]
      public static extern void Y(int a);
    }

    [ContractClassFor(typeof(X))]
    static class XContract
    {
      public static void Y(int a)
      {
         Contract.Requires(a >= 0);
      }
    }