microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 675 forks source link

Report better errors when a library doesn't support AoT #9999

Open dotMorten opened 4 hours ago

dotMorten commented 4 hours ago

Describe the bug

This is a follow up to https://github.com/microsoft/microsoft-ui-xaml/issues/9980 If you reference a library that hasn't done the work to upgrade to WinAppSDK 1.6, upgraded CSWinRT and generated the new projections, what you're met with is this obscure error on launch: image

There's no way to identify what is causing this crash. If we could have a build error/warning when PublishAoT is enabled, or a better exception at runtime that lets us identify which dependency doesn't support AoT, so that we can contact the library authors and have them address it.

Steps to reproduce the bug

  1. Create a new WinUI3 project and enabled it for AoT
  2. Reference WinUIEx v2.4.0
  3. Run the app.
  4. Boom!

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

Sergio0694 commented 4 hours ago

@manodasanw I reckon I can just reuse the logic we have in the RCW fallback generator, check that IsAotCompatible or PublishAot is set, and if so then just emit a whole bunch of warnings for all of those old types? Or perhaps one per assembly. Does that make sense? I can take this one if you think that approach makes sense 🙂

ghost1372 commented 51 minutes ago

i think this issue is related to this https://github.com/microsoft/WindowsAppSDK/issues/4730 refrencing any class library which contains resources dictionary (added in app.xaml) will be crashed Even if the dictionary is empty