AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.24k stars 2.19k forks source link

.Net Trim Feature Removes Accessbility from Testautomation #11767

Open Nepitwin opened 1 year ago

Nepitwin commented 1 year ago

Describe the bug When publishing a .Net Core desktop application, I noticed that the elements in the User Automation Interface Tree are no longer accessible when the Trim function is active.

Config_Trimmed TrimmedPublish

If you build the GUI application without the trim function, the elements are accessible as expected.

Config_No_Trimmed NoTrimmed

It seems that .Net removes the test automation interfaces.

To Reproduce Steps to reproduce the behavior:

  1. Clone example from https://github.com/Nepitwin/AvaloniaTestautomation
  2. Publish a trimmed application
  3. Start gui
  4. Investigate by any automation interface tool like FlaUIInspect or Accessibility Insights For Windows that elements are not accessible

Expected behavior Automation interface should be still accessible by trimmed application.

Desktop (please complete the following information):

maxkatz6 commented 1 year ago

Not sure if it is a bug or not, but definitely expected behavior as for now. Since .NET COM interop doesn't support any kind of trimming or AOT. It can be somewhat avoided by using <BuiltInComInteropSupport>true</BuiltInComInteropSupport> to the csproj.

But proper solution would be either wait until .NET 8/9 better support for COM or until we migrate current COM bindings to the our custom interop solution - MicroCOM.

hez2010 commented 1 year ago

.NET 8 previews is already shipping COM generators, I think we can make use of those generated code for the COM interop code.

Nepitwin commented 1 year ago

Thanks for the information when I build the example with the parameter 'true' and then try to analyze them with an Inspector tool the sample application crashes.

I thought it could be that it's not published as net6.0-windows but it's asweel crash.

However, it sounds good that for .Net 8 there might be a possibility.