Skip to content

VB DIM: An attempt to embed an interface with non-abstract members should cause an error #35852

@AlekseyTs

Description

@AlekseyTs
        <Fact>
        Public Sub NoPia_02()
            Dim attributesRef = GetCSharpCompiation(NoPiaAttributes).EmitToImageReference()

            Dim csSource =
"
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

[assembly: PrimaryInteropAssemblyAttribute(1,1)]
[assembly: Guid(""f9c2d51d-4f44-45f0-9eda-c9d599b58257"")]

[ComImport()]
[Guid(""f9c2d51d-4f44-45f0-9eda-c9d599b58279"")]
public interface ITest33
{
    void M1(){}
}
" + NoPiaAttributes

            Dim csCompiation = GetCSharpCompiation(csSource, {attributesRef}).EmitToImageReference(embedInteropTypes:=True)

            Dim source1 =
<compilation>
    <file name="c.vb"><![CDATA[
class UsePia 
    Sub Main(x as ITest33)
        x.M1()
    End Sub
End Class
]]></file>
</compilation>

            Dim comp1 = CreateCompilation(source1, targetFramework:=TargetFramework.NetStandardLatest, references:={attributesRef, csCompiation})
            ' Expect an error similar to - CS8711: Type 'ITest33' cannot be embedded because it has a non-abstract member. Consider setting the 'Embed Interop Types' property to false.
            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