Skip to content

[ComImport] Interfaces should have unused methods replaced with placeholders, not removed #936

@Zhentar

Description

@Zhentar

When the linker detects that a ComImport method is not being used, it removes them from the interface. This is not correct: all ComImport interface methods are implicitly used, because they are used to determine the native vtable layout.

When Roslyn embeds interface definitions from interop dlls, it replaces unused member with void () placeholders: https://github.com/dotnet/roslyn/blob/e704ca635bd6de70a0250e34c4567c7a28fa9f6d/src/Compilers/Core/Portable/MetadataReader/ModuleExtensions.cs#L193

Using a placeholder like that can unroot types used by the parameters/return values, so it can still help with further size reductions; but the methods cannot be removed entirely.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions