Skip to content

VB DIM: An attempt to use non virtual method with implementation declared in an interface from code targeting desktop framework should cause runtime capability error #35885

@AlekseyTs

Description

@AlekseyTs
        <Fact>
        Public Sub MethodImplementation_31()

            Dim csSource =
"
public interface I1
{
    sealed string M1() => ""I1.M1"";
}
"
            Dim csCompiation = GetCSharpCompiation(csSource).EmitToImageReference()

            Dim source1 =
<compilation>
    <file name="c.vb"><![CDATA[
Public Class C
    Shared Sub Main()
        Dim i1 as I1 = New Test()
        i1.M1()
    End Sub
End Class

Class Test
    Implements I1
End Class
]]></file>
</compilation>

            Dim comp1 = CreateCompilation(source1, options:=TestOptions.DebugExe, targetFramework:=TargetFramework.DesktopLatestExtended, references:={csCompiation})
            ' Expect an error similar to - error CS8501: Target runtime doesn't support default interface implementation.
            comp1.AssertTheseDiagnostics()
        End Sub

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