Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions src/libraries/System.Private.CoreLib/src/System/Delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ public abstract partial class Delegate : ICloneable, ISerializable
/// <summary>
/// Gets an enumerator for the invocation targets of this delegate.
/// </summary>
/// <typeparam name="TDelegate">Delegate type being enumerated.</typeparam>
/// <param name="d">The delegate being enumerated.</param>
/// <returns>A <see cref="InvocationListEnumerator{TDelegate}" /> that follows the IEnumerable pattern and
/// thus can be used in a C# 'foreach' statement to retrieve the invocation targets of this delegate without allocations.
/// The method returns an empty enumerator for <see langword="null" /> delegate.</returns>
/// <remarks>
/// This returns a <see cref="InvocationListEnumerator{TDelegate}"/>" /> that follows the IEnumerable pattern and
/// thus can be used in a C# 'foreach' statements to retrieve the invocation targets of this delegate without allocations.
/// The order of the delegates returned by the enumerator is the same order in which the current delegate invokes the methods that those delegates represent.
/// The method returns an empty enumerator for null delegate.
/// </remarks>
Expand Down Expand Up @@ -120,6 +123,8 @@ public TDelegate Current
/// <summary>
/// Implements the IEnumerator pattern.
/// </summary>
/// <returns><see langword="true" /> if the enumerator was successfully advanced to the next element;
/// otherwise, <see langword="false" /> if the enumerator has passed the end of the collection. </returns>
public bool MoveNext()
{
int index = _index + 1;
Expand All @@ -132,8 +137,9 @@ public bool MoveNext()
}

/// <summary>
/// Implement IEnumerable.GetEnumerator() to return 'this' as the IEnumerator
/// Implement IEnumerable.GetEnumerator() to return 'this' as the IEnumerator.
/// </summary>
/// <returns>An IEnumerator instance that can be used to iterate through the invocation targets of the delegate.</returns>
[EditorBrowsable(EditorBrowsableState.Never)] // Only here to make foreach work
public System.Delegate.InvocationListEnumerator<TDelegate> GetEnumerator() => this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,7 @@ public static unsafe int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T
/// </summary>
/// <param name="span">The span to search.</param>
/// <param name="values">The set of values to search for.</param>
/// <returns>The first index of any of the specified values, or -1 if none are found.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int IndexOfAny<T>(this ReadOnlySpan<T> span, SearchValues<T> values) where T : IEquatable<T>?
{
Expand All @@ -2109,6 +2110,7 @@ public static int IndexOfAny<T>(this ReadOnlySpan<T> span, SearchValues<T> value
/// </summary>
/// <param name="span">The span to search.</param>
/// <param name="values">The set of values to search for.</param>
/// <returns>The first index of any of the specified values, or -1 if none are found.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int IndexOfAny(this ReadOnlySpan<char> span, SearchValues<string> values)
{
Expand Down Expand Up @@ -2596,6 +2598,8 @@ ref MemoryMarshal.GetReference(value),
/// </summary>
/// <param name="span">The span to search.</param>
/// <param name="value">The value to compare.</param>
/// <typeparam name="T">The type of elements in the span.</typeparam>
/// <returns><see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" />; otherwise, <see langword="false" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool StartsWith<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>? =>
span.Length != 0 && (span[0]?.Equals(value) ?? (object?)value is null);
Expand All @@ -2605,6 +2609,8 @@ public static bool StartsWith<T>(this ReadOnlySpan<T> span, T value) where T : I
/// </summary>
/// <param name="span">The span to search.</param>
/// <param name="value">The value to compare.</param>
/// <typeparam name="T">The type of the elements in the span.</typeparam>
/// <returns><see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" />; otherwise, <see langword="false" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool EndsWith<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>? =>
span.Length != 0 && (span[^1]?.Equals(value) ?? (object?)value is null);
Expand Down Expand Up @@ -4286,6 +4292,7 @@ private static bool TryWrite<TArg0, TArg1, TArg2>(Span<char> destination, IForma
/// <summary>
/// Enables enumerating each split within a <see cref="ReadOnlySpan{T}"/> that has been divided using one or more separators.
/// </summary>
/// <typeparam name="T">The type of items in the <see cref="SpanSplitEnumerator{T}"/>.</typeparam>
public ref struct SpanSplitEnumerator<T> where T : IEquatable<T>
{
/// <summary>The input span being split.</summary>
Expand Down
16 changes: 16 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,22 @@ private protected static ArgumentException CreateGetMemberWithSameMetadataDefini
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
public MethodInfo? GetMethod(string name, int genericParameterCount, Type[] types, ParameterModifier[]? modifiers) => GetMethod(name, genericParameterCount, DefaultLookup, null, types, modifiers);

/// <summary>
/// Searches for the specified method whose parameters match the specified generic parameter count and argument types, using the specified binding constraints.
/// </summary>
/// <param name="name">The string containing the name of the method to get.</param>
/// <param name="genericParameterCount">The number of generic type parameters of the method.</param>
/// <param name="bindingAttr">
/// A bitwise combination of the enumeration values that specify how the search is conducted.
/// -or-
/// Default to return null.
/// </param>
/// <param name="types">
/// An array of <see cref="Type"/> objects representing the number, order, and type of the parameters for the method to get.
/// -or-
/// An empty array of <see cref="Type"/> objects (as provided by the <see cref="EmptyTypes"/> field) to get a method that takes no parameters.
/// </param>
/// <returns>An object representing the method that matches the specified generic parameter count, argument types, and binding constraints, if found; otherwise, <see langword="null" />.</returns>
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
public MethodInfo? GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Type[] types) => GetMethod(name, genericParameterCount, bindingAttr, null, types, null);

Expand Down
Loading