-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8b1956
commit 64ffc64
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**API count: 433** | ||
**API count: 434** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// <auto-generated /> | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
#pragma warning disable | ||
|
||
namespace Polyfills; | ||
|
||
using System; | ||
using System.Collections.Concurrent; | ||
|
||
static partial class Polyfill | ||
{ | ||
/// <summary> | ||
/// Gets a value that indicates whether the Delegate has a single invocation target. | ||
/// </summary> | ||
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.delegate.hassingletarget | ||
public static bool HasSingleTarget(this Delegate target) | ||
{ | ||
#if NET9_0_OR_GREATER | ||
return target.HasSingleTarget; | ||
#else | ||
return target.GetInvocationList().Length == 1; | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
partial class PolyfillTests | ||
{ | ||
public static event EventHandler? MyEvent; | ||
|
||
[Test] | ||
public void HasSingleTarget() | ||
{ | ||
MyEvent += Handler; | ||
Assert.IsTrue(MyEvent.HasSingleTarget()); | ||
MyEvent += Handler; | ||
Assert.IsFalse(MyEvent.HasSingleTarget()); | ||
var action = () => | ||
{ | ||
}; | ||
Assert.IsTrue(action.HasSingleTarget()); | ||
action += action; | ||
Assert.IsFalse(action.HasSingleTarget()); | ||
} | ||
|
||
static void Handler(object? sender, EventArgs e) | ||
{ | ||
} | ||
} |