Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Remove the EventArgs type parameter constraint from WeakEventManager #13540

Closed
AlexanderMelchers opened this issue Jan 26, 2021 · 2 comments

Comments

@AlexanderMelchers
Copy link

Summary

With XF 5.0 the WeakEventManager has been made public. I highly laud this development, as this is a step in the right direction to expire my custom implementation. However, in all cases where I'm using my own WeakEventManager, I'm using events with handlers that pass object-values rather than EventArgs. The constraint where TEventArgs: EventArgs in Forms' implementation of the WeakEventManager therefore requires me encapsulate the values I wish to pass in an EventArgs-object. It would be great if this would not be necessary.

API Changes

Either A) change the following signatures

public void AddEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null) where TEventArgs : EventArgs;
public void RemoveEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null) where TEventArgs : EventArgs;

into

public void AddEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null);
public void RemoveEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null);

or B) add overrides to the extent of the above.

Intended Use Case

The default language implementation of EventHandler<TEventArgs> doesn't place any constraints on the object-type
for TEventArgs. Therefore, events may be created that do not pass EventArgs-type objects. Such events can now not be used in combination with the WeakEventManager and thus still require custom implementations - especially when event signatures cannot be changed, e.g. when consuming a dependency-library.

@AlexanderMelchers
Copy link
Author

Although this issue has merit on its own, I think it gains when seen together with #13545.

@hartez hartez self-assigned this Jan 26, 2021
@hartez hartez removed their assignment Jul 28, 2022
@jfversluis
Copy link
Member

Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.

If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

3 participants