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

Code before:
        }

        [Fact]
        public void TestBadNestedInnerClassVisibility()
        {
            var source = @"
public class A { internal class B { } }
public class C : A.B { }";

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (3,14): error CS0060: Inconsistent accessibility: base class 'A.B' is less accessible than class 'C'
                //     public class C : A.B { }
                Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("C", "A.B").WithLocation(3, 14));
        }

        [Fact]
        public void TestBadNestedOuterClassVisibility()
        {
            var source = @"
class A { public class B { } }
public class C : A.B { }";

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (3,14): error CS9335: Inconsistent accessibility: type 'A' is less accessible than class 'C'
                //     public class C : A.B { }
                Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(3, 14));
        }
    }
}


Review comment (suggestion):
It might be interesting to also test a case where the containing type with bad accessibility, is not explicitly referenced in the base type. e.g.

```cs
using static A;

static class A
{
    public class B { }
}

public class C : B { }
```

I don't think I'm worried about the diagnostic being unclear in that case, personally, but I do think it is worth recording


Code after:
        }

        [Fact]
        public void TestBadContainedTypeVisibility()
        {
            var source = @"
public class A { internal class B { } }
public class C : A.B { }";

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (3,14): error CS0060: Inconsistent accessibility: base class 'A.B' is less accessible than class 'C'
                //     public class C : A.B { }
                Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("C", "A.B").WithLocation(3, 14));
        }

        [Fact]
        public void TestBadContainingTypeVisibility()
        {
            var source = @"
class A { public class B { } }
public class C : A.B { }";

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (3,14): error CS9338: Inconsistent accessibility: type 'A' is less accessible than class 'C'
                //     public class C : A.B { }
                Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(3, 14));
        }

        [Fact]
        public void TestBadContainingTypeVisibilityWithoutExplicitReference()
        {
            var source = @"
using static A;

static class A
{
    public class B { }
}

public class C : B { }";

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (9,14): error CS9338: Inconsistent accessibility: type 'A' is less accessible than class 'C' 
                //     public class C : B { }
                Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(9, 14));
        }
    }
}