@@ -324,4 +324,132 @@ public static Sequence<T> CreatePooledBufferWriter<T>(bool isSensitive, int mini
324324 /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="minimumSpanLength"/> is negative.</exception>
325325 public static Sequence < byte > CreatePooledBufferWriter ( bool isSensitive , int minimumSpanLength = 0 )
326326 => CreatePooledBufferWriter < byte > ( isSensitive , minimumSpanLength ) ;
327+
328+ /// <summary>
329+ /// Creates a new <see cref="ArrayBufferWriter{T}"/> with the default initial capacity.
330+ /// </summary>
331+ /// <typeparam name="T">The type of elements in the buffer. Must be an unmanaged value type.</typeparam>
332+ /// <returns>
333+ /// A new <see cref="ArrayBufferWriter{T}"/> instance that implements <see cref="IBufferWriter{T}"/>.
334+ /// </returns>
335+ /// <remarks>
336+ /// <para>
337+ /// The returned <see cref="ArrayBufferWriter{T}"/> is a simple, non-pooled buffer writer that uses
338+ /// a single contiguous array that grows as needed. Unlike <see cref="CreatePooledBufferWriter{T}"/>,
339+ /// this method does not provide secure memory handling.
340+ /// </para>
341+ /// <para>
342+ /// Use this method when you need a simple buffer writer for non-sensitive data and do not require
343+ /// the overhead of memory pooling.
344+ /// </para>
345+ /// </remarks>
346+ /// <example>
347+ /// <code>
348+ /// using var writer = BufferFactory.CreateArrayBufferWriter<int>();
349+ /// var span = writer.GetSpan(10);
350+ /// // Write data to span
351+ /// writer.Advance(10);
352+ /// // Access the written data
353+ /// ReadOnlySpan<int> data = writer.WrittenSpan;
354+ /// </code>
355+ /// </example>
356+ public static ArrayBufferWriter < T > CreateArrayBufferWriter < T > ( )
357+ where T : struct
358+ => new ( ) ;
359+
360+ /// <summary>
361+ /// Creates a new <see cref="ArrayBufferWriter{T}"/> with the specified initial capacity.
362+ /// </summary>
363+ /// <typeparam name="T">The type of elements in the buffer. Must be an unmanaged value type.</typeparam>
364+ /// <param name="initialCapacity">The initial capacity of the underlying buffer.</param>
365+ /// <returns>
366+ /// A new <see cref="ArrayBufferWriter{T}"/> instance that implements <see cref="IBufferWriter{T}"/>.
367+ /// </returns>
368+ /// <remarks>
369+ /// <para>
370+ /// The returned <see cref="ArrayBufferWriter{T}"/> is a simple, non-pooled buffer writer that uses
371+ /// a single contiguous array. Specifying an appropriate initial capacity can help reduce reallocations
372+ /// when the expected data size is known in advance.
373+ /// </para>
374+ /// <para>
375+ /// Unlike <see cref="CreatePooledBufferWriter{T}"/>, this method does not provide secure memory handling.
376+ /// Use this method when you need a simple buffer writer for non-sensitive data.
377+ /// </para>
378+ /// </remarks>
379+ /// <example>
380+ /// <code>
381+ /// using var writer = BufferFactory.CreateArrayBufferWriter<int>(1024);
382+ /// var span = writer.GetSpan(100);
383+ /// // Write data to span
384+ /// writer.Advance(100);
385+ /// // Access the written data
386+ /// ReadOnlySpan<int> data = writer.WrittenSpan;
387+ /// </code>
388+ /// </example>
389+ /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="initialCapacity"/> is not positive.</exception>
390+ public static ArrayBufferWriter < T > CreateArrayBufferWriter < T > ( int initialCapacity )
391+ where T : struct
392+ => new ( initialCapacity ) ;
393+
394+ /// <summary>
395+ /// Creates a new <see cref="ArrayBufferWriter{T}"/> for bytes with the default initial capacity.
396+ /// </summary>
397+ /// <returns>
398+ /// A new <see cref="ArrayBufferWriter{T}"/> instance that implements <see cref="IBufferWriter{T}"/>.
399+ /// </returns>
400+ /// <remarks>
401+ /// <para>
402+ /// This is a convenience overload for the common case of working with byte buffers.
403+ /// The returned <see cref="ArrayBufferWriter{T}"/> is a simple, non-pooled buffer writer that uses
404+ /// a single contiguous array that grows as needed.
405+ /// </para>
406+ /// <para>
407+ /// Unlike <see cref="CreatePooledBufferWriter(bool, int)"/>, this method does not provide secure memory handling.
408+ /// Use this method when you need a simple buffer writer for non-sensitive byte data.
409+ /// </para>
410+ /// </remarks>
411+ /// <example>
412+ /// <code>
413+ /// using var writer = BufferFactory.CreateArrayBufferWriter();
414+ /// var span = writer.GetSpan(100);
415+ /// // Write byte data to span
416+ /// writer.Advance(100);
417+ /// // Access the written data
418+ /// ReadOnlySpan<byte> data = writer.WrittenSpan;
419+ /// </code>
420+ /// </example>
421+ public static ArrayBufferWriter < byte > CreateArrayBufferWriter ( )
422+ => new ( ) ;
423+
424+ /// <summary>
425+ /// Creates a new <see cref="ArrayBufferWriter{T}"/> for bytes with the specified initial capacity.
426+ /// </summary>
427+ /// <param name="initialCapacity">The initial capacity of the underlying buffer.</param>
428+ /// <returns>
429+ /// A new <see cref="ArrayBufferWriter{T}"/> instance that implements <see cref="IBufferWriter{T}"/>.
430+ /// </returns>
431+ /// <remarks>
432+ /// <para>
433+ /// This is a convenience overload for the common case of working with byte buffers.
434+ /// Specifying an appropriate initial capacity can help reduce reallocations when the expected
435+ /// data size is known in advance.
436+ /// </para>
437+ /// <para>
438+ /// Unlike <see cref="CreatePooledBufferWriter(bool, int)"/>, this method does not provide secure memory handling.
439+ /// Use this method when you need a simple buffer writer for non-sensitive byte data.
440+ /// </para>
441+ /// </remarks>
442+ /// <example>
443+ /// <code>
444+ /// using var writer = BufferFactory.CreateArrayBufferWriter(1024);
445+ /// var span = writer.GetSpan(100);
446+ /// // Write byte data to span
447+ /// writer.Advance(100);
448+ /// // Access the written data
449+ /// ReadOnlySpan<byte> data = writer.WrittenSpan;
450+ /// </code>
451+ /// </example>
452+ /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="initialCapacity"/> is not positive.</exception>
453+ public static ArrayBufferWriter < byte > CreateArrayBufferWriter ( int initialCapacity )
454+ => new ( initialCapacity ) ;
327455}
0 commit comments