Skip to content

VB DIM: An attempt to use protected method declared in an interface from code targeting desktop framework doesn't cause runtime capability error #35834

@AlekseyTs

Description

@AlekseyTs
        <Fact>
        Public Sub MethodImplementation_27()

            Dim csSource =
"
public interface I1
{
    protected static string M1()
    {
        return ""I1.M1"";
    }
}
"
            Dim csCompiation = GetCSharpCompiation(csSource).EmitToImageReference()

            Dim source1 =
<compilation>
    <file name="c.vb"><![CDATA[
Public Class C
    Implements I1
    Shared Sub Main()
        System.Console.WriteLine(I1.M1())
    End Sub
End Class
]]></file>
</compilation>

            Dim comp1 = CreateCompilation(source1, options:=TestOptions.DebugExe, targetFramework:=TargetFramework.DesktopLatestExtended, references:={csCompiation})
            comp1.AssertTheseDiagnostics(
<error>
BC30390: 'I1.Function M1() As String' is not accessible in this context because it is 'Protected'.
        System.Console.WriteLine(I1.M1())
                                 ~~~~~
</error>)
        End Sub

Expect to see an error similar to:

error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface.

Observed: Only accessibility error is reported which will go away once #35827 is fixed.

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