Skip to content

Adding missing System.Buffers documentation #90891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,53 @@ namespace System.Buffers.Binary
public static partial class BinaryPrimitives
{
/// <summary>
/// This is a no-op and added only for consistency.
/// This allows the caller to read a struct of numeric primitives and reverse each field
/// rather than having to skip sbyte fields.
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="sbyte" /> value, which effectively does nothing for an <see cref="sbyte" />.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The passed-in value, unmodified.</returns>
/// <remarks>This method effectively does nothing and was added only for consistency.</remarks>
[CLSCompliant(false)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static sbyte ReverseEndianness(sbyte value) => value;

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="short" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static short ReverseEndianness(short value) => (short)ReverseEndianness((ushort)value);

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="int" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int ReverseEndianness(int value) => (int)ReverseEndianness((uint)value);

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="long" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long ReverseEndianness(long value) => (long)ReverseEndianness((ulong)value);

/// <summary>Reverses a primitive value by performing an endianness swap of the specified <see cref="nint"/> value.</summary>
/// <summary>
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="nint" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static nint ReverseEndianness(nint value) => (nint)ReverseEndianness((nint_t)value);

/// <summary>Reverses a primitive value by performing an endianness swap of the specified <see cref="Int128"/> value.</summary>
/// <summary>
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="Int128" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -70,16 +81,19 @@ public static Int128 ReverseEndianness(Int128 value)
}

/// <summary>
/// This is a no-op and added only for consistency.
/// This allows the caller to read a struct of numeric primitives and reverse each field
/// rather than having to skip byte fields.
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="byte" /> value, which effectively does nothing for an <see cref="byte" />.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The passed-in value, unmodified.</returns>
/// <remarks>This method effectively does nothing and was added only for consistency.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte ReverseEndianness(byte value) => value;

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="ushort" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[CLSCompliant(false)]
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -96,14 +110,18 @@ public static ushort ReverseEndianness(ushort value)
}

/// <summary>
/// Reverses a 16-bit character value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="char" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static char ReverseEndianness(char value) => (char)ReverseEndianness((ushort)value);

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="uint" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[CLSCompliant(false)]
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -134,8 +152,10 @@ public static uint ReverseEndianness(uint value)
}

/// <summary>
/// Reverses a primitive value - performs an endianness swap
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="ulong" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[CLSCompliant(false)]
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -148,14 +168,18 @@ public static ulong ReverseEndianness(ulong value)
+ ReverseEndianness((uint)(value >> 32));
}

/// <summary>Reverses a primitive value by performing an endianness swap of the specified <see cref="nuint"/> value.</summary>
/// <summary>
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="nuint" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[CLSCompliant(false)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static nuint ReverseEndianness(nuint value) => (nuint)ReverseEndianness((nuint_t)value);

/// <summary>Reverses a primitive value by performing an endianness swap of the specified <see cref="UInt128"/> value.</summary>
/// <summary>
/// Reverses a primitive value by performing an endianness swap of the specified <see cref="UInt128" /> value.
/// </summary>
/// <param name="value">The value to reverse.</param>
/// <returns>The reversed value.</returns>
[CLSCompliant(false)]
Expand Down
Loading