Open devsko opened 1 month ago
CsWinRT does not yet support collection expressions in AOT mode. As for the reference type array, it works with unsafe code because CsWinRT needs that to generate AOT shims.
The value-type-array error does look to be an oversight though. cc @manodasanW
We didn't initially support boxing arrays using IReferenceArray
due to we couldn't make it work with non-blittable scenarios on AOT. But I am working on a change to enable it for blittable scenarios such as this one.
In the meantime, you should be able to use a list rather than an array or collection expression and it should work.
I tried new Geopath(new List<BasicGeoposition>() { new(0, 0, 0) });
which gives the exact same exception as the one with collection expression.
On WinUI3 all of them work perfectly.
Can you confirm the version of the .NET 9 SDK you are using? And to confirm, do you have AllowUnsafeBlocks
enabled?
It is 9.0.100-rc.2.24474.11 I uploaded the repro https://github.com/devsko/App10
https://github.com/microsoft/CsWinRT/issues/1846
Are the internal anomalous causes of the two issues consistent?
这俩个问题的内部异常原因是一致的吗?
Describe the bug Calling WinRT with parameters of type
IEnumerable<T>
in modern UWP fails with various exceptions depending onT
and parameter type.To Reproduce
<WindowsSDKPackageVersion>10.0.26100.54</WindowsSDKPackageVersion>
and<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
to .csprojAdd a
Page_Loaded
handler to MainPage with this code:Expected behavior
No exceptions
Version Info
net9.0 rc2, Windows SDK 26100
Additional context
Creating a
Geopath
in WinUI3 works as expected. (MapStyleSheet is not available in WinUI3)