Open ghost1372 opened 1 month ago
@Sergio0694
IsActive
just calls either RegisterAll
or UnregisterAll
, these are not AOT safe, so that's the core issue.
Sergio had mentioned these should probably just end up being another source generator instead, so you don't have to manually register each interface either.
Could be a good, isolated generator issue for someone to pick up?
public partial class MyViewModel : ObservableRecipient, // or ObservableObject, etc...
IRecipient<MyMessage1>,
IRecipient<MyMessage2>
{
}
@Sergio0694 were you thinking it'd work like the DependencyInjection API and would there just be a partial RegisterMessages
method or something added to OO?
public ObservableObject
{
// New generated helper injection points
partial RegisterMesssages();
partial UnregisterMesssages();
}
Maybe these would be on OR, but in OO, the Messenger.RegisterAll method could then just go call RegisterMessages
internally or something, right?
The generator would write these methods:
private void RegisterMessages()
{
Register<MyMessage1>(this);
Register<MyMessage2>(this);
}
private void UnregisterMessages()
{
Unregister<MyMessage1>(this);
Unregister<MyMessage2>(this);
}
Then IsActive
would be:
public bool IsActive
{
get;
set
{
value ? RegisterMessages() : UnregisterMessages();
}
}
It's late, so this is really rough, but it's just an initial thought to get things rolling.
Describe the bug
i always use ObservableRecipient and its IsActive property, now it seems that does not support AOT/Trim.
Solution: i created a new property for this: [ObservableProperty] public bool isProcessActive;
Regression
CommunityToolkit.Mvvm 8.3.2
Steps to reproduce
Expected behavior
Support AOT/Trim
Screenshots
No response
IDE and version
VS 2022
IDE version
No response
Nuget packages
Nuget package version(s)
8.3.2
Additional context
No response
Help us help you
No, just wanted to report this