Skip to content

False negative error CS9503 "Required member cannot be less visible than the containing type" for member in nested type #61528

@sirduke

Description

@sirduke

Version Used:
features/required-members

Steps to Reproduce:

public class Outer {
    protected class ProtectedClass {
        protected required int ProtectedProperty { get; set; }
    }
}

 class Derived : Outer {
     public void Test() {
         var p = new ProtectedClass() // error "Required member 'Outer.ProtectedClass.ProtectedProperty' must be set
         {
           // ProtectedProperty = 1 // cannot set the property because it is inaccessible
         };
     }
 }

Expected Behavior:
Error CS9503 is shown for ProtectedProperty declaration

Actual Behavior:
No error for ProtectedProperty declaration is shown but it is impossible to create instance of ProtectedClass in derived class

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions