Skip to content

Commit

Permalink
fix: commented out UnsafeAccessor for EventCallback<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
Denny09310 committed Oct 26, 2024
1 parent 92c94d3 commit 67660ed
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/BlazorBindings.Core/NativeControlComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(EventCallback<T> e1, object e2)
=> e2 is EventCallback<T> other
&& ReferenceEquals(GetReceiver(e1), GetReceiver(other))
&& Equals(GetDelegate(e1), GetDelegate(other));
//protected static bool Equals<T>(EventCallback<T> e1, object e2)
// => e2 is EventCallback<T> other
// && ReferenceEquals(GetReceiver(ref e1), GetReceiver(ref other))
// && Equals(GetDelegate(ref e1), GetDelegate(ref other));

protected virtual void BuildRenderTree(RenderTreeBuilder builder)
{
Expand Down Expand Up @@ -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<T> 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<T> 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<T> _this);

//[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Delegate")]
//extern static ref MulticastDelegate GetDelegate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(ref EventCallback<T> _this);
}

0 comments on commit 67660ed

Please sign in to comment.