CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

C# projection does not build if WinRT method is named as `ToString()`

Open RobsonPontin opened this issue 3 years ago • 0 comments

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

  1. In a IDL runtimeclass declare a new method called ToString that returns a String. Example: runtimeclass MyClass { MyClass(); String ToString(Windows.Foundation.IReference<Windows.Foundation.TimeSpan> duration); };
  2. Once I attempt to build it will generate a projection error complaining about an extra new keyword 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

RobsonPontin avatar Jan 20 '23 20:01 RobsonPontin