Skip to content

Commit

Permalink
Fix merge conflicts on Delegate and String.resx
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <[email protected]>
  • Loading branch information
safern authored and stephentoub committed Apr 6, 2019
1 parent 6ee20bc commit 6f9663b
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/Common/src/CoreLib/System/Delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
Expand All @@ -16,43 +17,43 @@ private Delegate()

public virtual object Clone() => MemberwiseClone();

public static Delegate Combine(Delegate a, Delegate b)
public static Delegate? Combine(Delegate? a, Delegate? b)
{
if (a is null)
return b;

return a.CombineImpl(b);
}

public static Delegate Combine(params Delegate[] delegates)
public static Delegate? Combine(params Delegate?[]? delegates)
{
if (delegates is null || delegates.Length == 0)
if (delegates == null || delegates.Length == 0)
return null;

Delegate d = delegates [0];
Delegate? d = delegates[0];
for (int i = 1; i < delegates.Length; i++)
d = Combine(d, delegates[i]);

return d;
}

protected virtual Delegate CombineImpl(Delegate d) => throw new MulticastNotSupportedException(SR.Multicast_Combine);
protected virtual Delegate CombineImpl(Delegate? d) => throw new MulticastNotSupportedException(SR.Multicast_Combine);

// V2 api: Creates open or closed delegates to static or instance methods - relaxed signature checking allowed.
public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method) => CreateDelegate(type, firstArgument, method, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, object? firstArgument, MethodInfo method) => CreateDelegate(type, firstArgument, method, throwOnBindFailure: true)!;

// V1 api: Creates open delegates to static or instance methods - relaxed signature checking allowed.
public static Delegate CreateDelegate(Type type, MethodInfo method) => CreateDelegate(type, method, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, MethodInfo method) => CreateDelegate(type, method, throwOnBindFailure: true)!;

// V1 api: Creates closed delegates to instance methods only, relaxed signature checking disallowed.
public static Delegate CreateDelegate(Type type, object target, string method) => CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase) => CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, object target, string method) => CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true)!;
public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase) => CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true)!;

// V1 api: Creates open delegates to static methods only, relaxed signature checking disallowed.
public static Delegate CreateDelegate(Type type, Type target, string method) => CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase) => CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true);
public static Delegate CreateDelegate(Type type, Type target, string method) => CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true)!;
public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase) => CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true)!;

public object DynamicInvoke(params object[] args)
public object? DynamicInvoke(params object?[]? args)
{
return DynamicInvokeImpl(args);
}
Expand All @@ -63,9 +64,9 @@ public object DynamicInvoke(params object[] args)

public MethodInfo Method => GetMethodImpl();

protected virtual Delegate RemoveImpl(Delegate d) => d.Equals(this) ? null : this;
protected virtual Delegate? RemoveImpl(Delegate d) => d.Equals(this) ? null : this;

public static Delegate Remove(Delegate source, Delegate value)
public static Delegate? Remove(Delegate? source, Delegate? value)
{
if (source == null)
return null;
Expand All @@ -79,9 +80,9 @@ public static Delegate Remove(Delegate source, Delegate value)
return source.RemoveImpl(value);
}

public static Delegate RemoveAll(Delegate source, Delegate value)
public static Delegate? RemoveAll(Delegate? source, Delegate? value)
{
Delegate newDelegate = null;
Delegate? newDelegate = null;

do
{
Expand All @@ -95,7 +96,7 @@ public static Delegate RemoveAll(Delegate source, Delegate value)

// Force inline as the true/false ternary takes it above ALWAYS_INLINE size even though the asm ends up smaller
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Delegate d1, Delegate d2)
public static bool operator ==(Delegate? d1, Delegate? d2)
{
// Test d2 first to allow branch elimination when inlined for null checks (== null)
// so it can become a simple test
Expand All @@ -105,12 +106,12 @@ public static Delegate RemoveAll(Delegate source, Delegate value)
return (d1 is null) ? true : false;
}

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

// Force inline as the true/false ternary takes it above ALWAYS_INLINE size even though the asm ends up smaller
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Delegate d1, Delegate d2)
public static bool operator !=(Delegate? d1, Delegate? d2)
{
// Test d2 first to allow branch elimination when inlined for not null checks (!= null)
// so it can become a simple test
Expand All @@ -123,4 +124,4 @@ public static Delegate RemoveAll(Delegate source, Delegate value)
return ReferenceEquals(d2, d1) ? false : !d2.Equals(d1);
}
}
}
}

0 comments on commit 6f9663b

Please sign in to comment.