Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PDeets opened this issue Mar 1, 2025 · 0 comments
Open

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

PDeets opened this issue Mar 1, 2025 · 0 comments

Comments

@PDeets
Copy link
Member

PDeets commented Mar 1, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant