CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

System.Collections.Specialized.ReadOnlyList not supported by AOT generator

Open FrayxRulez opened this issue 1 year ago • 3 comments

Describe the bug System.Collections.Specialized.ReadOnlyList fails to cast to IList and it makes it impossible to raise INotifyCollectionChanged.CollectionChanged event from user code.

Version Info 2.1.1

Additional context Sorry for opening a lot of tickets, I believe that a lot of this stuff is already being tracked internally, but you never know...

FrayxRulez avatar Aug 27 '24 14:08 FrayxRulez

No worries on the number of issues being opened. It looks like ReadOnlyList is an internal type within the .NET runtime used for CollectionChanged scenarios. Our AOT source generator isn't able to detect those and make them AOT safe. We have plans on having a fallback mechanism that uses the statically known type which is tracked by #1661.

In the meantime, you might be able to workaround that issue by following the guidance here: https://github.com/microsoft/CsWinRT/blob/master/docs/aot-trimming.md#known-issues-when-publishing-for-aot

manodasanW avatar Aug 27 '24 18:08 manodasanW

Describe the bug System.Collections.Specialized.ReadOnlyList fails to cast to IList and it makes it impossible to raise INotifyCollectionChanged.CollectionChanged event from user code.

Version Info 2.1.1

Additional context Sorry for opening a lot of tickets, I believe that a lot of this stuff is already being tracked internally, but you never know...

Isn't readonlylist in the system.collections.generic namespace?

Gaoyifei1011 avatar Aug 28 '24 06:08 Gaoyifei1011

you might be able to workaround that issue by following the guidance here

Yep, managed to workaround the other issues as well.

Isn't readonlylist in the system.collections.generic namespace?

This seems to be a different implementation used only internally 😅

FrayxRulez avatar Aug 28 '24 07:08 FrayxRulez