CsWinRT
CsWinRT copied to clipboard
static .As<>() method hides instance .As<>() extension method
workaround:
using WinRT; ... var obj = ((object)objectWithStaticAs).As<ISomeInstanceInterface();
no longer repros
confirmed no repro - must have been a point in time issue with the C# compiler
Repro with WinUI3:
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Clicked";
// need to cast to System.Object as a workaround
var hwnd = ((Object)this).As<Windows.Interop.IWindowNative>().WindowHandle;
}
}
Static .As() methods should fall back to calling the extension method for interop interface