Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,14 @@ namespace System
{
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public abstract class MulticastDelegate : Delegate
public abstract partial class MulticastDelegate : Delegate
{
// This is set under 2 circumstances
// 1. Multicast delegate
// 2. Wrapper delegate
private object? _invocationList; // Initialized by VM as needed
private nint _invocationCount;

// This constructor is called from the class generated by the
// compiler generated code (This must match the constructor
// in Delegate
[RequiresUnreferencedCode("The target method might be removed")]
protected MulticastDelegate(object target, string method) : base(target, method)
{
}

// This constructor is called from a class to generate a
// delegate based upon a static method name and the Type object
// for the class defining the method.
protected MulticastDelegate([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target, string method) : base(target, method)
{
}

internal bool IsUnmanagedFunctionPtr()
{
return _invocationCount == -1;
Expand Down Expand Up @@ -448,34 +433,6 @@ public sealed override Delegate[] GetInvocationList()
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(MulticastDelegate? d1, MulticastDelegate? d2)
{
// Test d2 first to allow branch elimination when inlined for null checks (== null)
// so it can become a simple test
if (d2 is null)
{
return d1 is null;
}

return ReferenceEquals(d2, d1) ? true : d2.Equals((object?)d1);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(MulticastDelegate? d1, MulticastDelegate? d2)
{
// Can't call the == operator as it will call object==

// Test d2 first to allow branch elimination when inlined for not null checks (!= null)
// so it can become a simple test
if (d2 is null)
{
return d1 is not null;
}

return ReferenceEquals(d2, d1) ? false : !d2.Equals(d1);
}

public sealed override int GetHashCode()
{
if (IsUnmanagedFunctionPtr())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
<Compile Include="System\GC.NativeAot.cs" />
<Compile Include="System\Math.NativeAot.cs" />
<Compile Include="System\MathF.NativeAot.cs" />
<Compile Include="System\MulticastDelegate.cs" />
<Compile Include="System\Object.NativeAot.cs" />
<Compile Include="System\Resources\ManifestBasedResourceGroveler.NativeAot.cs" />
<Compile Include="System\RuntimeArgumentHandle.cs" />
Expand Down
Loading