Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Semantic/Semantics/ConditionalOperatorTests.cs (C#)

Code before:
        /// </summary>
        /// <remarks>
        /// Cases where both conversions are possible and neither is preferred as the
        /// wider of the two are possible only in the presence of user-defined implicit
        /// conversions.  Such cases are tested separately.  
        /// See SemanticErrorTests.CS0172ERR_AmbigQM.
        /// </remarks>
        [Fact]
        public void TestAmbiguousPreferWider()
        {
            TestConditional("true ? 1 : (short)2", expectedType: "System.Int32");
            TestConditional("false ? (float)2 : 1", expectedType: "System.Single");
            TestConditional("true ? 1.5d : (double)2", expectedType: "System.Double");
        }

        /// <summary>
        /// Both branches have types but neither expression is convertible to the type
        /// of the other.
        /// </summary>
        [Fact]
        public void TestNoConversion()
        {
            TestConditional("true ? T : U", null, parseOptions: TestOptions.Regular8,
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "U").WithArguments("U", "type"),
                Diagnostic(ErrorCode.ERR_InvalidQM, "true ? T : U").WithArguments("T", "U"));
            TestConditional("true ? T : U", null, parseOptions: TestOptions.Regular8.WithLanguageVersion(MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion()),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "U").WithArguments("U", "type"),
                Diagnostic(ErrorCode.ERR_InvalidQM, "true ? T : U").WithArguments("T", "U"));
            TestConditional("false ? T : 1", null, parseOptions: TestOptions.Regular8,
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_InvalidQM, "false ? T : 1").WithArguments("T", "int"));
            TestConditional("false ? T : 1", null, parseOptions: TestOptions.Regular8.WithLanguageVersion(MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion()),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_InvalidQM, "false ? T : 1").WithArguments("T", "int"));
            TestConditional("true ? GetUserGeneric<char>() : GetUserNonGeneric()", null,
                Diagnostic(ErrorCode.ERR_InvalidQM, "true ? GetUserGeneric<char>() : GetUserNonGeneric()").WithArguments("D<char>", "C"));
        }

        /// <summary>
        /// Exactly one branch has a type and the other expression is convertible to that type.
        /// </summary>
        [Fact]
        public void TestOneUntypedSuccess()
        {
            TestConditional("true ? GetObject() : null", expectedType: "System.Object"); //null literal
            TestConditional("false ? GetString : (System.Func<string>)null", expectedType: "System.Func<System.String>"); //method group
            TestConditional("true ? (System.Func<int, int>)null : x => x", expectedType: "System.Func<System.Int32, System.Int32>"); //lambda
        }


Review comment (suggestion):
>Diagnostic(ErrorCode.ERR_InvalidQM, "true ? T : U").WithArguments("T", "U")) [](http://example.com/codeflow?start=16&length=76)

It is hard to tell what this error is about. Since the base-line is changing, please switch to the "modern" format with the error message and the source line in a comment preceding a `Diagnostic` instance.  #Closed

Code after:
        /// </summary>
        /// <remarks>
        /// Cases where both conversions are possible and neither is preferred as the
        /// wider of the two are possible only in the presence of user-defined implicit
        /// conversions.  Such cases are tested separately.  
        /// See SemanticErrorTests.CS0172ERR_AmbigQM.
        /// </remarks>
        [Fact]
        public void TestAmbiguousPreferWider()
        {
            TestConditional("true ? 1 : (short)2", expectedType: "System.Int32");
            TestConditional("false ? (float)2 : 1", expectedType: "System.Single");
            TestConditional("true ? 1.5d : (double)2", expectedType: "System.Double");
        }

        /// <summary>
        /// Both branches have types but neither expression is convertible to the type
        /// of the other.
        /// </summary>
        [Fact]
        public void TestNoConversion()
        {
            TestConditional("true ? T : U", null, parseOptions: TestOptions.Regular8,
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "U").WithArguments("U", "type"));
            TestConditional("true ? T : U", null, parseOptions: TestOptions.Regular8.WithLanguageVersion(MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion()),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "U").WithArguments("U", "type"));
            TestConditional("false ? T : 1", null, parseOptions: TestOptions.Regular8,
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"));
            TestConditional("false ? T : 1", null, parseOptions: TestOptions.Regular8.WithLanguageVersion(MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion()),
                Diagnostic(ErrorCode.ERR_BadSKunknown, "T").WithArguments("T", "type"));
            TestConditional("true ? GetUserGeneric<char>() : GetUserNonGeneric()", null,
                Diagnostic(ErrorCode.ERR_InvalidQM, "true ? GetUserGeneric<char>() : GetUserNonGeneric()").WithArguments("D<char>", "C"));
        }

        /// <summary>
        /// Exactly one branch has a type and the other expression is convertible to that type.
        /// </summary>
        [Fact]
        public void TestOneUntypedSuccess()
        {
            TestConditional("true ? GetObject() : null", expectedType: "System.Object"); //null literal
            TestConditional("false ? GetString : (System.Func<string>)null", expectedType: "System.Func<System.String>"); //method group
            TestConditional("true ? (System.Func<int, int>)null : x => x", expectedType: "System.Func<System.Int32, System.Int32>"); //lambda
        }

        /// <summary>
        /// Exactly one branch has a type but the other expression is not convertible to that type.
        /// </summary>
        [Fact]