Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs (C#)

Code before:

            var tree = comp.SyntaxTrees.Single();
            var model = comp.GetSemanticModel(tree);
            var nest = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(i => i.Identifier.ValueText == "Nest").Single();
            Assert.Null(model.GetAliasInfo(nest));
            Assert.Equal("Base.Nest", model.GetTypeInfo(nest).Type.ToDisplayString());
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void TypeParameter_BaseType_ReturnsNull()
        {
            var source = """
                abstract class Base
                {
                    public abstract void Method();
                }

                class Derived<T> where T : Base
                {
                }
                """;
            var comp = CreateCompilation(source);

            var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("Derived`1").TypeParameters[0].GetPublicSymbol();
            Assert.Null(typeParameter.BaseType);
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void MethodTypeParameter_BaseType_ReturnsNull()
        {
            var source = """
                class C
                {
                    void M<T>() where T : class
                    {
                    }
                }
                """;
            var comp = CreateCompilation(source);

            var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("C").GetMethod("M").TypeParameters[0].GetPublicSymbol();
            Assert.Null(typeParameter.BaseType);
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void ObjectType_BaseType_ReturnsNull()
        {
            var comp = CreateCompilation("");

            var objectType = (INamedTypeSymbol)comp.GetSpecialType(SpecialType.System_Object).GetPublicSymbol();
            Assert.Null(objectType.BaseType);

Review comment (suggestion):
@copilot  please update the copilot-instructions file to mention that tests should strive to avoid unnecessary intermediary asserts, and do the minimal amount of work to validate just the core issue being addressed by the PR.  #Closed

Code after:

            var tree = comp.SyntaxTrees.Single();
            var model = comp.GetSemanticModel(tree);
            var nest = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(i => i.Identifier.ValueText == "Nest").Single();
            Assert.Null(model.GetAliasInfo(nest));
            Assert.Equal("Base.Nest", model.GetTypeInfo(nest).Type.ToDisplayString());
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void TypeParameter_BaseType_ReturnsNull()
        {
            var source = """
                abstract class Base
                {
                    public abstract void Method();
                }

                class Derived<T> where T : Base
                {
                }
                """;
            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics();

            var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("Derived`1").TypeParameters[0].GetPublicSymbol();
            Assert.Null(typeParameter.BaseType);
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void MethodTypeParameter_BaseType_ReturnsNull()
        {
            var source = """
                class C
                {
                    void M<T>() where T : class
                    {
                    }
                }
                """;
            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics();

            var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("C").GetMethod("M").TypeParameters[0].GetPublicSymbol();
            Assert.Null(typeParameter.BaseType);
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41733")]
        public void ObjectType_BaseType_ReturnsNull()
        {
            var comp = CreateCompilation("");
            comp.VerifyDiagnostics();