diff --git a/src/BlazorBindings.Core/NativeControlComponentBase.cs b/src/BlazorBindings.Core/NativeControlComponentBase.cs index 5bc541d2..b6946c7c 100644 --- a/src/BlazorBindings.Core/NativeControlComponentBase.cs +++ b/src/BlazorBindings.Core/NativeControlComponentBase.cs @@ -35,13 +35,13 @@ public virtual Task SetParametersAsync(ParameterView parameters) protected static bool Equals(EventCallback e1, object e2) => e2 is EventCallback other - && ReferenceEquals(GetReceiver(e1), GetReceiver(other)) - && Equals(GetDelegate(e1), GetDelegate(other)); + && ReferenceEquals(GetReceiver(ref e1), GetReceiver(ref other)) + && Equals(GetDelegate(ref e1), GetDelegate(ref other)); - protected static bool Equals(EventCallback e1, object e2) - => e2 is EventCallback other - && ReferenceEquals(GetReceiver(e1), GetReceiver(other)) - && Equals(GetDelegate(e1), GetDelegate(other)); + //protected static bool Equals(EventCallback e1, object e2) + // => e2 is EventCallback other + // && ReferenceEquals(GetReceiver(ref e1), GetReceiver(ref other)) + // && Equals(GetDelegate(ref e1), GetDelegate(ref other)); protected virtual void BuildRenderTree(RenderTreeBuilder builder) { @@ -181,14 +181,16 @@ void IComponent.Attach(RenderHandle renderHandle) [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Receiver")] - extern static ref IHandleEvent GetReceiver(EventCallback callback); - - [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Receiver")] - extern static IHandleEvent GetReceiver<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(EventCallback e1); + extern static ref IHandleEvent GetReceiver(ref EventCallback _this); [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Delegate")] - extern static ref MulticastDelegate GetDelegate(EventCallback callback); + extern static ref MulticastDelegate GetDelegate(ref EventCallback _this); - [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Delegate")] - extern static MulticastDelegate GetDelegate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(EventCallback e1); + // Unfortunately can't use with generics https://github.com/dotnet/runtime/issues/89439 + + //[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Receiver")] + //extern static ref IHandleEvent GetReceiver<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(ref EventCallback _this); + + //[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Delegate")] + //extern static ref MulticastDelegate GetDelegate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(ref EventCallback _this); }