From cca022b6212f33adc982630ab91469882250256c Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Mon, 28 Oct 2024 17:20:22 -0700 Subject: [PATCH] Add some missing docs in System (#107726) * Add some doc * Fix typos --------- Co-authored-by: Tanner Gooding --- .../src/System/Delegate.cs | 12 +++++++++--- .../src/System/MemoryExtensions.cs | 7 +++++++ .../System.Private.CoreLib/src/System/Type.cs | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Delegate.cs b/src/libraries/System.Private.CoreLib/src/System/Delegate.cs index a7133d3473a6c..8b2c712d3c5a1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Delegate.cs @@ -84,9 +84,12 @@ public abstract partial class Delegate : ICloneable, ISerializable /// /// Gets an enumerator for the invocation targets of this delegate. /// + /// Delegate type being enumerated. + /// The delegate being enumerated. + /// A 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 delegate. /// - /// This returns a " /> 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. /// @@ -120,6 +123,8 @@ public TDelegate Current /// /// Implements the IEnumerator pattern. /// + /// if the enumerator was successfully advanced to the next element; + /// otherwise, if the enumerator has passed the end of the collection. public bool MoveNext() { int index = _index + 1; @@ -132,8 +137,9 @@ public bool MoveNext() } /// - /// Implement IEnumerable.GetEnumerator() to return 'this' as the IEnumerator + /// Implement IEnumerable.GetEnumerator() to return 'this' as the IEnumerator. /// + /// An IEnumerator instance that can be used to iterate through the invocation targets of the delegate. [EditorBrowsable(EditorBrowsableState.Never)] // Only here to make foreach work public System.Delegate.InvocationListEnumerator GetEnumerator() => this; } diff --git a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs index 75b3a19e0718d..b344f373bc977 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs @@ -2093,6 +2093,7 @@ public static unsafe int IndexOfAny(this ReadOnlySpan span, ReadOnlySpan /// The span to search. /// The set of values to search for. + /// The first index of any of the specified values, or -1 if none are found. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny(this ReadOnlySpan span, SearchValues values) where T : IEquatable? { @@ -2109,6 +2110,7 @@ public static int IndexOfAny(this ReadOnlySpan span, SearchValues value /// /// The span to search. /// The set of values to search for. + /// The first index of any of the specified values, or -1 if none are found. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny(this ReadOnlySpan span, SearchValues values) { @@ -2596,6 +2598,8 @@ ref MemoryMarshal.GetReference(value), /// /// The span to search. /// The value to compare. + /// The type of elements in the span. + /// if matches the beginning of ; otherwise, . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool StartsWith(this ReadOnlySpan span, T value) where T : IEquatable? => span.Length != 0 && (span[0]?.Equals(value) ?? (object?)value is null); @@ -2605,6 +2609,8 @@ public static bool StartsWith(this ReadOnlySpan span, T value) where T : I /// /// The span to search. /// The value to compare. + /// The type of the elements in the span. + /// if matches the end of ; otherwise, . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsWith(this ReadOnlySpan span, T value) where T : IEquatable? => span.Length != 0 && (span[^1]?.Equals(value) ?? (object?)value is null); @@ -4286,6 +4292,7 @@ private static bool TryWrite(Span destination, IForma /// /// Enables enumerating each split within a that has been divided using one or more separators. /// + /// The type of items in the . public ref struct SpanSplitEnumerator where T : IEquatable { /// The input span being split. diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.cs b/src/libraries/System.Private.CoreLib/src/System/Type.cs index 3437d8f377bd4..728e251e4aa73 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.cs @@ -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); + /// + /// Searches for the specified method whose parameters match the specified generic parameter count and argument types, using the specified binding constraints. + /// + /// The string containing the name of the method to get. + /// The number of generic type parameters of the method. + /// + /// A bitwise combination of the enumeration values that specify how the search is conducted. + /// -or- + /// Default to return null. + /// + /// + /// An array of objects representing the number, order, and type of the parameters for the method to get. + /// -or- + /// An empty array of objects (as provided by the field) to get a method that takes no parameters. + /// + /// An object representing the method that matches the specified generic parameter count, argument types, and binding constraints, if found; otherwise, . [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] public MethodInfo? GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Type[] types) => GetMethod(name, genericParameterCount, bindingAttr, null, types, null);