Bug in latest release (1.7.109088.11) RRS feed

  • Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace ConsoleApplication1
        class Program
            public string Foo(object value)
                if (value == null)
                    return null;
                var c = (string)value;
                switch (c)
                    case "Bar":
                        return "Baz";
                        return "Wobbly";
            static void Main(string[] args)

    Turn on static checking with the above code.

    "CodeContracts: warning: The Boolean condition value != 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"

    If the warning was on the line where I check "if (value == null)" it would be one thing (still a bug, but easier to understand), but the line it's complaining about is the switch statement.

    This code may look contrived, but it was only meant to be a simple repro. This is actually causing me problems throughout my code base with some IValueConverter classes.

    You can uncheck "Check redundant conditionals" in the project settings to shut it up, but that's a sledge hammer solution and means you don't get the benefit of those checks anywhere else.

    Thursday, September 11, 2014 3:08 PM

All replies

  • I'm having similar issues. Is there a link so that I can download an older version?
    Friday, September 12, 2014 2:06 PM
  • Same problem here. Can anyone on the CC team advise?
    Friday, September 26, 2014 1:36 PM
  • I'm having similar issues.

    CC Version 1.9.10714.2

    Wednesday, December 9, 2015 1:26 PM