-
-
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.
Merge branch 'main' of https://github.com/SimonCropp/Polyfill
- Loading branch information
Showing
6 changed files
with
100 additions
and
7 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: 434** | ||
**API count: 435** |
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
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,65 @@ | ||
// <auto-generated /> | ||
|
||
|
||
#pragma warning disable | ||
|
||
namespace Polyfills; | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[ExcludeFromCodeCoverage] | ||
[DebuggerNonUserCode] | ||
#if PolyPublic | ||
public | ||
#endif | ||
static partial class DelegatePolyfill | ||
{ | ||
/// <summary> | ||
/// Gets an enumerator for the invocation targets of this delegate. | ||
/// </summary> | ||
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.delegate.enumerateinvocationlist | ||
#if NET9_0_OR_GREATER | ||
public static Delegate.InvocationListEnumerator<TDelegate> EnumerateInvocationList<TDelegate>(TDelegate? target) where TDelegate : Delegate => | ||
Delegate.EnumerateInvocationList(target); | ||
#else | ||
public static InvocationListEnumerator<TDelegate> EnumerateInvocationList<TDelegate>(TDelegate? target) where TDelegate : Delegate => | ||
new InvocationListEnumerator<TDelegate>(target); | ||
|
||
/// <summary> | ||
/// Provides an enumerator for the invocation list of a delegate. | ||
/// </summary> | ||
/// <typeparam name="TDelegate">Delegate type being enumerated.</typeparam> | ||
public struct InvocationListEnumerator<TDelegate> | ||
where TDelegate : Delegate | ||
{ | ||
Delegate[] delegates; | ||
int index = -1; | ||
|
||
internal InvocationListEnumerator(Delegate target) => | ||
delegates = target.GetInvocationList(); | ||
|
||
public TDelegate Current { get; private set; } | ||
|
||
public bool MoveNext() | ||
{ | ||
int index = this.index + 1; | ||
if (index == delegates.Length) | ||
{ | ||
return false; | ||
} | ||
|
||
Current = (TDelegate) delegates[index]; | ||
this.index = index; | ||
return true; | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public InvocationListEnumerator<TDelegate> GetEnumerator() => this; | ||
} | ||
#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