Should S2701 apply to bool? datatypes


(Paul Hickman) #1


The following causes rule S2701 to fire:

            bool? x = false;
            Assert.AreEqual(false, x);

However, the suggested change fails to compile:


And I think the following is less clear than using the literal boolean value:

            Assert.IsFalse(x ?? true);

(Valeri Hristov) #2

Hi @paulhickman, I apologize for the late response. Your suggestion makes sense, I created a ticket to track it: