Skip to content

Commit

Permalink
Add some missing docs in System (#107726)
Browse files Browse the repository at this point in the history
* Add some doc

* Fix typos

---------

Co-authored-by: Tanner Gooding <tagoo@outlook.com>
  • Loading branch information
buyaa-n and tannergooding authored Oct 29, 2024
1 parent 3cf6e24 commit cca022b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
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

0 comments on commit cca022b

Please sign in to comment.