2

False warning in that code:

return (Patient as IHrsHolder) ?? (Course as IHrsHolder) ?? Appointment;

I want to suppress warning, so I need error number. But there isn't any number in Error list or Output, only:

CodeContracts: warning: The Boolean condition this.Patient == null always evaluates to a constant value. If it (or its negation) appear in the source code, you may have some dead code or redundant check

How do I suppress that (without rewriting code)?

smg
  • 1,096
  • 2
  • 11
  • 27
  • possible duplicate of [CodeContracts: Boolean condition evaluates to a constant value, why?](http://stackoverflow.com/questions/28452850/codecontracts-boolean-condition-evaluates-to-a-constant-value-why) – Jcl May 20 '15 at 08:29
  • 1
    @Jcl the question you linked to asks for the reason behind the warning. The OP just wants to know how to surpress it. – dcastro May 20 '15 at 08:35
  • @dcastro if you read both the related question and the answer (which is accepted) throughoutly, it's basically the same question (the warning appearing where it shouldn't) and expected answer (how to avoid it showing the warning). Also the comments would be helpful for this question – Jcl May 20 '15 at 08:37
  • 2
    @Jcl the accepted answer suggests suppressing the warning. The OP knows that - he just doesn't know what error code to suppress. The question/answer you linked to do not provide the error number. You could say this is a follow-up question, but definitely not an equivalent question. – dcastro May 20 '15 at 08:41

1 Answers1

0

In this case the "ErrorNumber" is actually a String:

[SuppressMessage("Microsoft.Contracts", "TestAlwaysEvaluatingToAConstant")]