Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
Expand Down Expand Up @@ -49,6 +49,16 @@ public AssemblyNameInfo(string name, Version? version = null, string? cultureNam
}
#endif

/// <summary>
/// Initializes a new instance of the AssemblyNameInfo class.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is on a wrong method

/// </summary>
/// <param name="name">The simple name of the assembly.</param>
/// <param name="version">The version of the assembly.</param>
/// <param name="cultureName">The name of the culture associated with the assembly.</param>
/// <param name="flags">The attributes of the assembly.</param>
/// <param name="publicKeyOrToken">The public key or its token. Set <paramref name="flags"/> to <see cref="AssemblyNameFlags.PublicKey"/> when it's public key.</param>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception>
Comment on lines +60 to +61

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both these reference null, but only one uses the langword approach.

internal AssemblyNameInfo(AssemblyNameParser.AssemblyNameParts parts)
{
Name = parts._name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public partial class BlobBuilder
private uint FrozenLength => _length | IsFrozenMask;
private Span<byte> Span => _buffer.AsSpan(0, Length);

/// <param name="capacity">To be added.</param>
Copy link

@jkotas jkotas Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we omit these "To be added" comments (or replace them with AI generated boilerplate)? It is easy to scan for public APIs with missing docs anytime. We do not have to have placeholders for it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

public BlobBuilder(int capacity = DefaultChunkSize)
{
if (capacity < 0)
Expand All @@ -63,6 +64,7 @@ public BlobBuilder(int capacity = DefaultChunkSize)
_buffer = new byte[Math.Max(MinChunkSize, capacity)];
}

/// <param name="minimalSize">To be added.</param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

protected virtual BlobBuilder AllocateChunk(int minimalSize)
{
return new BlobBuilder(Math.Max(_buffer.Length, minimalSize));
Expand Down Expand Up @@ -789,6 +791,15 @@ public void WriteBytes(byte[] buffer, int start, int byteCount)
WriteBytes(buffer.AsSpan(start, byteCount));
}

/// <summary>
/// Writes a specified number of occurrences of a byte value to the builder.
/// </summary>
/// <param name="value">To be added.</param>
/// <param name="byteCount">The number of occurences of <paramref name="value"/> to write.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="byteCount"/> is negative.</exception>
/// <exception cref="InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="byteCount"/> is negative.</exception>
/// <exception cref="T:System.InvalidOperationException">The builder is not writable, it has been linked with another one.</exception>
internal void WriteBytes(ReadOnlySpan<byte> buffer)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong method. The doc comment should be on the public ones.

{
if (!IsHead)
Expand Down Expand Up @@ -991,6 +1002,14 @@ public void WriteUTF16(string value)
WriteUTF16(value.AsSpan());
}

/// <summary>
/// Writes UTF-16 (little-endian) encoded string at the current position.
/// </summary>
/// <param name="value">To be added.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
/// <exception cref="T:System.InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
private void WriteUTF16(ReadOnlySpan<char> value)
{
if (!IsHead)
Expand Down Expand Up @@ -1072,6 +1091,15 @@ public void WriteUTF8(string value, bool allowUnpairedSurrogates = true)
WriteUTF8(value, 0, value.Length, allowUnpairedSurrogates, prependSize: false);
}

/// <summary>
/// Writes UTF-8 encoded string at the current position.
/// </summary>
/// <param name="value">Constant value.</param>
/// <param name="allowUnpairedSurrogates"> True to encode unpaired surrogates as specified, otherwise replace them with U+FFFD character. </param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
/// <exception cref="T:System.InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
internal unsafe void WriteUTF8(string str, int start, int length, bool allowUnpairedSurrogates, bool prependSize)
{
Debug.Assert(start >= 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public BlobReader(byte* buffer, int length)

}

/// <summary>
/// Creates a reader of the specified memory block.
/// </summary>
/// <param name="buffer">Pointer to the start of the memory block.</param>
/// <param name="length">Length in bytes of the memory block.</param>
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null and <paramref name="length"/> is greater than zero.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length"/> is negative.</exception>
/// <exception cref="PlatformNotSupportedException">The current platform is not little-endian.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/> and <paramref name="length"/> is greater than zero.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="length"/> is negative.</exception>
/// <exception cref="T:System.PlatformNotSupportedException">The current platform is not little-endian.</exception>
internal BlobReader(MemoryBlock block)
{
Debug.Assert(block.Length >= 0 && (block.Pointer != null || block.Length == 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,27 @@ public struct BlobWriter
// position in buffer relative to the beginning of the array:
private int _position;

/// <param name="size">To be added.</param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

public BlobWriter(int size)
: this(new byte[size])
{
}

/// <param name="buffer">To be added.</param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

public BlobWriter(byte[] buffer)
: this(buffer, 0, buffer.Length)
{
}

/// <param name="blob">To be added.</param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

public BlobWriter(Blob blob)
: this(blob.Buffer, blob.Start, blob.Length)
{
}

/// <param name="buffer">To be added.</param>
/// <param name="start">To be added.</param>
/// <param name="count">To be added.</param>
Comment on lines +41 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete.

public BlobWriter(byte[] buffer, int start, int count)
{
Debug.Assert(buffer != null);
Expand Down Expand Up @@ -147,6 +153,10 @@ public unsafe void WriteBytes(byte* buffer, int byteCount)
WriteBytes(new ReadOnlySpan<byte>(buffer, byteCount));
}

/// <param name="value">To be added.</param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My base assumption is that every item should have a <summary>. I will stop for now, but everytime I marked something "Incomplete." that is what I was implying.

/// <param name="byteCount">To be added.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="byteCount"/> is negative.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="byteCount"/> is negative.</exception>
internal void WriteBytes(ReadOnlySpan<byte> buffer)
{
int start = Advance(buffer.Length);
Expand Down Expand Up @@ -234,112 +244,132 @@ public void WriteBytes(byte[] buffer, int start, int byteCount)
WriteBytes(buffer.AsSpan(start, byteCount));
}

/// <param name="offset">To be added.</param>
public void PadTo(int offset)
{
WriteBytes(0, offset - Offset);
}

/// <param name="alignment">To be added.</param>
public void Align(int alignment)
{
int offset = Offset;
WriteBytes(0, BitArithmetic.Align(offset, alignment) - offset);
}

/// <param name="value">To be added.</param>
public void WriteBoolean(bool value)
{
WriteByte((byte)(value ? 1 : 0));
}

/// <param name="value">To be added.</param>
public void WriteByte(byte value)
{
int start = Advance(sizeof(byte));
_buffer[start] = value;
}

/// <param name="value">To be added.</param>
public void WriteSByte(sbyte value)
{
WriteByte(unchecked((byte)value));
}

/// <param name="value">To be added.</param>
public void WriteDouble(double value)
{
int start = Advance(sizeof(double));
_buffer.WriteDouble(start, value);
}

/// <param name="value">To be added.</param>
public void WriteSingle(float value)
{
int start = Advance(sizeof(float));
_buffer.WriteSingle(start, value);
}

/// <param name="value">To be added.</param>
public void WriteInt16(short value)
{
WriteUInt16(unchecked((ushort)value));
}

/// <param name="value">To be added.</param>
public void WriteUInt16(ushort value)
{
int start = Advance(sizeof(ushort));
_buffer.WriteUInt16(start, value);
}

/// <param name="value">To be added.</param>
public void WriteInt16BE(short value)
{
WriteUInt16BE(unchecked((ushort)value));
}

/// <param name="value">To be added.</param>
public void WriteUInt16BE(ushort value)
{
int start = Advance(sizeof(ushort));
_buffer.WriteUInt16BE(start, value);
}

/// <param name="value">To be added.</param>
public void WriteInt32BE(int value)
{
WriteUInt32BE(unchecked((uint)value));
}

/// <param name="value">To be added.</param>
public void WriteUInt32BE(uint value)
{
int start = Advance(sizeof(uint));
_buffer.WriteUInt32BE(start, value);
}

/// <param name="value">To be added.</param>
public void WriteInt32(int value)
{
WriteUInt32(unchecked((uint)value));
}

/// <param name="value">To be added.</param>
public void WriteUInt32(uint value)
{
int start = Advance(sizeof(uint));
_buffer.WriteUInt32(start, value);
}

/// <param name="value">To be added.</param>
public void WriteInt64(long value)
{
WriteUInt64(unchecked((ulong)value));
}

/// <param name="value">To be added.</param>
public void WriteUInt64(ulong value)
{
int start = Advance(sizeof(ulong));
_buffer.WriteUInt64(start, value);
}

/// <param name="value">To be added.</param>
public void WriteDecimal(decimal value)
{
int start = Advance(BlobUtilities.SizeOfSerializedDecimal);
_buffer.WriteDecimal(start, value);
}

/// <param name="value">To be added.</param>
public void WriteGuid(Guid value)
{
int start = Advance(BlobUtilities.SizeOfGuid);
_buffer.WriteGuid(start, value);
}

/// <param name="value">To be added.</param>
public void WriteDateTime(DateTime value)
{
WriteInt64(value.Ticks);
Expand Down Expand Up @@ -393,6 +423,12 @@ public void WriteUTF16(string value)
WriteUTF16(value.AsSpan());
}

/// <summary>
/// Writes UTF-16 (little-endian) encoded string at the current position.
/// </summary>
/// <param name="value">To be added.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
private void WriteUTF16(ReadOnlySpan<char> value)
{
if (BitConverter.IsLittleEndian)
Expand Down Expand Up @@ -464,6 +500,13 @@ public void WriteUTF8(string value, bool allowUnpairedSurrogates)
WriteUTF8(value, 0, value.Length, allowUnpairedSurrogates, prependSize: false);
}

/// <summary>
/// Writes UTF-8 encoded string at the current position.
/// </summary>
/// <param name="value">To be added.</param>
/// <param name="allowUnpairedSurrogates">To be added.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
private unsafe void WriteUTF8(string str, int start, int length, bool allowUnpairedSurrogates, bool prependSize)
{
fixed (char* strPtr = str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,44 @@ internal int Token
}
}

/// <summary>
/// Returns a value that indicates whether the current instance and the specified object are equal.
/// </summary>
/// <param name="obj">The object to compare with the current instance.</param>
/// <returns><see langword="true"/> if <paramref name="obj"/> is an <see cref="T:System.Reflection.Metadata.EntityHandle"/> and is equal to the current instance; otherwise, <see langword="false"/>.</returns>
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is EntityHandle entityHandle && Equals(entityHandle);
}

/// <summary>
/// Returns a value that indicates whether the current instance and the specified <see cref="T:System.Reflection.Metadata.EntityHandle"/> are equal.
/// </summary>
/// <param name="other">The value to compare with the current instance.</param>
/// <returns><see langword="true"/> if the current instance and <paramref name="other"/> are equal; otherwise, <see langword="false"/>.</returns>
public bool Equals(EntityHandle other)
{
return _vToken == other._vToken;
}

/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <returns>The hash code for this instance.</returns>
public override int GetHashCode()
{
return unchecked((int)_vToken);
}

/// <param name="left">To be added.</param>
/// <param name="right">To be added.</param>
public static bool operator ==(EntityHandle left, EntityHandle right)
{
return left.Equals(right);
}

/// <param name="left">To be added.</param>
/// <param name="right">To be added.</param>
public static bool operator !=(EntityHandle left, EntityHandle right)
{
return !left.Equals(right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,17 @@ internal int Token
}
}

/// <param name="obj">To be added.</param>
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is Handle handle && Equals(handle);
}

/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns><see langword="true"/> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <see langword="false"/>.</returns>
public bool Equals(Handle other)
{
return _value == other._value && _vType == other._vType;
Expand All @@ -175,11 +181,15 @@ public override int GetHashCode()
return _value ^ (_vType << 24);
}

/// <param name="left">To be added.</param>
/// <param name="right">To be added.</param>
public static bool operator ==(Handle left, Handle right)
{
return left.Equals(right);
}

/// <param name="left">To be added.</param>
/// <param name="right">To be added.</param>
public static bool operator !=(Handle left, Handle right)
{
return !left.Equals(right);
Expand Down
Loading