Skip to content

Commit 8004b2d

Browse files
committed
docs(extensions): 完善 SpanExtensions.BigEndian 读取方法的双语文档注释
为 ReadFloatBigEndianValue、ReadDoubleBigEndianValue、ReadBytesValue、 ReadStringValue 及其重载方法添加 remarks 英文翻译,并统一 param/returns/exception 标签为双语格式。
1 parent dbb63fa commit 8004b2d

1 file changed

Lines changed: 44 additions & 26 deletions

File tree

GameFrameX.Foundation.Extensions/SpanExtensions.BigEndian.cs

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,13 @@ public static long ReadLongBigEndianValue(this Span<byte> buffer, ref int offset
469469
/// <summary>
470470
/// 从指定的字节缓冲区和偏移量以大端字节序读取一个单精度浮点数值,并更新偏移量。
471471
/// </summary>
472-
/// <param name="buffer">要读取的字节跨度。</param>
473-
/// <param name="offset">读写操作的起始位置,读取后会自动增加4字节。</param>
474-
/// <returns>返回读取的单精度浮点数值。</returns>
475-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
472+
/// <remarks>
473+
/// Reads a single-precision floating-point value from the specified byte buffer at the given offset in big-endian byte order and updates the offset.
474+
/// </remarks>
475+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
476+
/// <param name="offset">读写操作的起始位置,读取后会自动增加4字节 / The starting position for read/write, automatically increments by 4 bytes after reading.</param>
477+
/// <returns>返回读取的单精度浮点数值 / Returns the read single-precision floating-point value.</returns>
478+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
476479
public static float ReadFloatBigEndianValue(this Span<byte> buffer, ref int offset)
477480
{
478481
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));
@@ -490,10 +493,13 @@ public static float ReadFloatBigEndianValue(this Span<byte> buffer, ref int offs
490493
/// <summary>
491494
/// 从指定的字节缓冲区和偏移量以大端字节序读取一个双精度浮点数值,并更新偏移量。
492495
/// </summary>
493-
/// <param name="buffer">要读取的字节跨度。</param>
494-
/// <param name="offset">读写操作的起始位置,读取后会自动增加8字节。</param>
495-
/// <returns>返回读取的双精度浮点数值。</returns>
496-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
496+
/// <remarks>
497+
/// Reads a double-precision floating-point value from the specified byte buffer at the given offset in big-endian byte order and updates the offset.
498+
/// </remarks>
499+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
500+
/// <param name="offset">读写操作的起始位置,读取后会自动增加8字节 / The starting position for read/write, automatically increments by 8 bytes after reading.</param>
501+
/// <returns>返回读取的双精度浮点数值 / Returns the read double-precision floating-point value.</returns>
502+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
497503
public static double ReadDoubleBigEndianValue(this Span<byte> buffer, ref int offset)
498504
{
499505
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));
@@ -511,10 +517,13 @@ public static double ReadDoubleBigEndianValue(this Span<byte> buffer, ref int of
511517
/// <summary>
512518
/// 从指定的字节缓冲区和偏移量读取一个字节数组,包含长度信息。
513519
/// </summary>
514-
/// <param name="buffer">要读取的字节跨度。</param>
515-
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数(4字节长度 + 数据长度)。</param>
516-
/// <returns>返回读取的字节数组,如果长度为0则返回空数组。</returns>
517-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
520+
/// <remarks>
521+
/// Reads a byte array from the specified byte buffer at the given offset with length information.
522+
/// </remarks>
523+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
524+
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数(4字节长度 + 数据长度)/ The starting position for read/write, automatically increments by the corresponding bytes (4-byte length + data length).</param>
525+
/// <returns>返回读取的字节数组,如果长度为0则返回空数组 / Returns the read byte array; returns an empty array if length is 0.</returns>
526+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
518527
public static byte[] ReadBytesValue(this Span<byte> buffer, ref int offset)
519528
{
520529
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));
@@ -540,10 +549,13 @@ public static byte[] ReadBytesValue(this Span<byte> buffer, ref int offset)
540549
/// <summary>
541550
/// 从指定的字节缓冲区和偏移量读取一个字符串,包含长度信息。
542551
/// </summary>
543-
/// <param name="buffer">要读取的字节跨度。</param>
544-
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数(2字节长度 + UTF-8字节数据)。</param>
545-
/// <returns>返回读取的字符串,使用 UTF-8 解码,如果长度为0则返回空字符串。</returns>
546-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
552+
/// <remarks>
553+
/// Reads a string from the specified byte buffer at the given offset with length information using UTF-8 decoding.
554+
/// </remarks>
555+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
556+
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数(2字节长度 + UTF-8字节数据)/ The starting position for read/write, automatically increments by the corresponding bytes (2-byte length + UTF-8 data).</param>
557+
/// <returns>返回读取的字符串,使用 UTF-8 解码,如果长度为0则返回空字符串 / Returns the read string using UTF-8 decoding; returns an empty string if length is 0.</returns>
558+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
547559
public static string ReadStringValue(this Span<byte> buffer, ref int offset)
548560
{
549561
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));
@@ -568,11 +580,14 @@ public static string ReadStringValue(this Span<byte> buffer, ref int offset)
568580
/// <summary>
569581
/// 从指定偏移量开始读取指定长度的字节数组。
570582
/// </summary>
571-
/// <param name="buffer">要读取的字节跨度。</param>
572-
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数。</param>
573-
/// <param name="len">需要读取的字节数组长度。</param>
574-
/// <returns>返回从缓冲区读取的字节数组,如果长度小于等于0则返回空数组。</returns>
575-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
583+
/// <remarks>
584+
/// Reads a byte array of specified length starting from the specified offset.
585+
/// </remarks>
586+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
587+
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数 / The starting position for read/write, automatically increments by the corresponding bytes.</param>
588+
/// <param name="len">需要读取的字节数组长度 / The length of the byte array to read.</param>
589+
/// <returns>返回从缓冲区读取的字节数组,如果长度小于等于0则返回空数组 / Returns the byte array read from the buffer; returns an empty array if length is less than or equal to 0.</returns>
590+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
576591
public static byte[] ReadBytesValue(this Span<byte> buffer, ref int offset, int len)
577592
{
578593
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));
@@ -596,11 +611,14 @@ public static byte[] ReadBytesValue(this Span<byte> buffer, ref int offset, int
596611
/// <summary>
597612
/// 从指定偏移量开始读取指定长度的字符串。
598613
/// </summary>
599-
/// <param name="buffer">要读取的字节跨度。</param>
600-
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数。</param>
601-
/// <param name="len">要读取的字符串字节长度。</param>
602-
/// <returns>返回读取的字符串,使用 UTF-8 解码,如果长度小于等于0则返回空字符串。</returns>
603-
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出。</exception>
614+
/// <remarks>
615+
/// Reads a string of specified byte length starting from the specified offset using UTF-8 decoding.
616+
/// </remarks>
617+
/// <param name="buffer">要读取的字节跨度 / The byte span to read from.</param>
618+
/// <param name="offset">读写操作的起始位置,读取后会自动增加相应字节数 / The starting position for read/write, automatically increments by the corresponding bytes.</param>
619+
/// <param name="len">要读取的字符串字节长度 / The byte length of the string to read.</param>
620+
/// <returns>返回读取的字符串,使用 UTF-8 解码,如果长度小于等于0则返回空字符串 / Returns the read string using UTF-8 decoding; returns an empty string if length is less than or equal to 0.</returns>
621+
/// <exception cref="ArgumentOutOfRangeException">当 <paramref name="offset"/> 为负数或超出缓冲区边界时抛出 / Thrown when <paramref name="offset"/> is negative or exceeds buffer bounds.</exception>
604622
public static string ReadStringValue(this Span<byte> buffer, ref int offset, int len)
605623
{
606624
ArgumentOutOfRangeException.ThrowIfNegative(offset, nameof(offset));

0 commit comments

Comments
 (0)