Skip to content

Bug: "Could not find property getter interface" error #1941

Open
@PDeets

Description

@PDeets

Description

I'm using C#/WinRT on a type where the IDL looks something like this:

    interface IDataSource : IInspectable
    {
        [propget] HRESULT MyProperty([out, retval] IItem** value);
    }
 
    interface IDataSink : IInspectable
    {
        [propput] HRESULT MyProperty([in] IItem* value);
    }
 
    runtimeclass DataSource
    {
        [default] interface IDataSink;
        interface IDataSource;
    }

(I've shared the exact code with the C#/WinRT team in private, but I'm not putting it here due to it being internal Microsoft code.)

I'm getting an error like this:
error: 'Could not find property getter interface' when processing MyNamespace.IDataSink

When cswinrt.exe sees IDataSink, it notices there is a setter without a getter, so it calls find_property_interface to find the interface that the getter is implemented on.

        auto [getter, setter] = get_property_methods(prop);
        // "new" required if overriding a getter in a base interface
        auto new_keyword = (!getter && setter && find_property_interface(w, type, prop.Name()).second) ? "new " : "";

However, in find_property_interface, it doesn’t find the getter interface for this case. The InterfaceImpl method returns an empty collection for the setter interface and the get_attribute block is not entered, so find_property_interface reaches its throw statement.

Steps To Reproduce

Use the pattern I shared above and try to generate interop code using cswinrt.exe. I have shared the winmds and a repro command line with the C#/WinRT devs through email.

Expected Behavior

cswinrt.exe should successfully generate interop code for this runtime class and its interfaces.

Version Info

This reproduces with the latest version of C#/WinRT. I tested with 2.1.1 and a newer version as well.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions