CsWinRT
CsWinRT copied to clipboard
C# projection does not build if WinRT method is named as `ToString()`
Describe the bug
If a C++/WinRT IDL has a runtimeclass which declares a ToString() method, the cswinrt will not be able to compile it.
To Reproduce
- In a IDL runtimeclass declare a new method called
ToStringthat returns a String. Example:runtimeclass MyClass { MyClass(); String ToString(Windows.Foundation.IReference<Windows.Foundation.TimeSpan> duration); }; - Once I attempt to build it will generate a projection error complaining about an extra
newkeyword added.
warning CS0109: The member 'MyClass.ToString(TimeSpan?)' does not hide an accessible member. The new keyword is not required.
Expected behavior
No keyword should be added and the method should override ToString from object in the C# projection.
Version Info
Additional context
- Microsoft.Windows.CsWinRT: v2.0.1
- Microsoft.Windows.SDK.BuildTools: v10.0.22621.755
- Microsoft.WindowsAppSDK: v1.2.221116.1
- .NET: net6.0-windows10.0.19041.0