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

Two runtimeclass with same property name but different type cause cannot convert argument error #9419

Closed
HO-COOH opened this issue Mar 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@HO-COOH
Copy link

HO-COOH commented Mar 9, 2024

Describe the bug

Same with #8994, but WinUI3 C++ project gives a different error.

Steps to reproduce the bug

  1. Create a C++ WinUI3 project

  2. Update every nuget to latest, I have
    image

  3. Create two runtimeclass

    [bindable]
    [default_interface]
    runtimeclass MyClass1 
    {
        MyClass1();
        Int32 MyProperty;
    }

    [bindable]
    [default_interface]
    runtimeclass MyClass2 
    {
        MyClass2();
        Object MyProperty;
    }
  1. Build project, you get
error C2665: 'winrt::_5_Function_Template_Conflict_WinUI3::implementation::MyClass2::MyProperty': no overloaded function could convert all the argument types
1>(compiling source file '/MyClass2.cpp')
1>C:\Users\Peter\Desktop\WinUI-Bug\5-Function-Template-Conflict\5-Function-Template-Conflict-WinUI3\MyClass2.cpp(14,20):
1>could be 'void winrt::_5_Function_Template_Conflict_WinUI3::implementation::MyClass2::MyProperty(int32_t)'
1>	C:\Users\Peter\Desktop\WinUI-Bug\5-Function-Template-Conflict\5-Function-Template-Conflict-WinUI3\Generated Files\winrt\_5_Function_Template_Conflict_WinUI3.h(94,25):
1>	'void winrt::_5_Function_Template_Conflict_WinUI3::implementation::MyClass2::MyProperty(int32_t)': cannot convert argument 1 from 'const winrt::Windows::Foundation::IInspectable' to 'int32_t'
1>		C:\Users\Peter\Desktop\WinUI-Bug\5-Function-Template-Conflict\5-Function-Template-Conflict-WinUI3\Generated Files\winrt\_5_Function_Template_Conflict_WinUI3.h(94,37):
1>		No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

Repo here

Expected behavior

Builds fine

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.0: 1.5.240227000

Windows version

Windows 10 (1809): Build 17763

Additional context

No response

@HO-COOH HO-COOH added the bug Something isn't working label Mar 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 9, 2024
@codendone
Copy link
Contributor

It looks like your repro specifies Object MyProperty; as the property in the idl file but still specifies int32_t as the type in the .h and .cpp files:

        int32_t MyProperty();
        void MyProperty(int32_t value);

Fixing the code to match the changed property type in the idl should fix the compile issue.

@HO-COOH
Copy link
Author

HO-COOH commented Apr 8, 2024

My bad. I have updated the code, and it seems this issue does get fixed for WinUI3. And UWP's issue remains. Please also take a look at #8994 if possible, thanks!

@HO-COOH HO-COOH closed this as completed Apr 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the needs-triage Issue needs to be triaged by the area owners label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants