Add XML doc comments for StreamExtensions.CreateString and SpanAction

This commit is contained in:
Dustin Campbell 2024-07-19 12:15:56 -07:00
Родитель 3b480de903
Коммит 749ded88f0
1 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -555,8 +555,47 @@ internal static class StringExtensions
#endif
}
/// <summary>
/// Encapsulates a method that receives a span of objects of type <typeparamref name="T"/>
/// and a state object of type <typeparamref name="TArg"/>.
/// </summary>
/// <typeparam name="T">
/// The type of the objects in the span.
/// </typeparam>
/// <typeparam name="TArg">
/// The type of the object that represents the state.
/// </typeparam>
/// <param name="span">
/// A span of objects of type <typeparamref name="T"/>.
/// </param>
/// <param name="arg">
/// A state object of type <typeparamref name="TArg"/>.
/// </param>
public delegate void SpanAction<T, in TArg>(Span<T> span, TArg arg);
/// <summary>
/// Creates a new string with a specific length and initializes it after creation by using the specified callback.
/// </summary>
/// <typeparam name="TState">
/// The type of the element to pass to <paramref name="action"/>.
/// </typeparam>
/// <param name="length">
/// The length of the string to create.
/// </param>
/// <param name="state">
/// The element to pass to <paramref name="action"/>.
/// </param>
/// <param name="action">
/// A callback to initialize the string
/// </param>
/// <returns>
/// The created string.
/// </returns>
/// <remarks>
/// The initial content of the destination span passed to <paramref name="action"/> is undefined.
/// Therefore, it is the delegate's responsibility to ensure that every element of the span is assigned.
/// Otherwise, the resulting string could contain random characters
/// </remarks>
public unsafe static string CreateString<TState>(int length, TState state, SpanAction<char, TState> action)
{
#if NET