Skip to content
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

System.Reflection.Metadata readonly annotation #51813

Closed
Closed
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
Expand Up @@ -272,13 +272,13 @@ public partial struct Blobs : System.Collections.Generic.IEnumerable<System.Refl
{
private object _dummy;
private int _dummyPrimitive;
public System.Reflection.Metadata.Blob Current { get { throw null; } }
public readonly System.Reflection.Metadata.Blob Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public System.Reflection.Metadata.BlobBuilder.Blobs GetEnumerator() { throw null; }
public readonly System.Reflection.Metadata.BlobBuilder.Blobs GetEnumerator() { throw null; }
public bool MoveNext() { throw null; }
public void Reset() { }
System.Collections.Generic.IEnumerator<System.Reflection.Metadata.Blob> System.Collections.Generic.IEnumerable<System.Reflection.Metadata.Blob>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
readonly System.Collections.Generic.IEnumerator<System.Reflection.Metadata.Blob> System.Collections.Generic.IEnumerable<System.Reflection.Metadata.Blob>.GetEnumerator() { throw null; }
readonly System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
void System.IDisposable.Dispose() { }
}
}
Expand Down Expand Up @@ -1996,11 +1996,11 @@ public partial struct NamespaceDefinition
{
private object _dummy;
private int _dummyPrimitive;
public System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.ExportedTypeHandle> ExportedTypes { get { throw null; } }
public System.Reflection.Metadata.StringHandle Name { get { throw null; } }
public System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.NamespaceDefinitionHandle> NamespaceDefinitions { get { throw null; } }
public System.Reflection.Metadata.NamespaceDefinitionHandle Parent { get { throw null; } }
public System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.TypeDefinitionHandle> TypeDefinitions { get { throw null; } }
public readonly System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.ExportedTypeHandle> ExportedTypes { get { throw null; } }
public readonly System.Reflection.Metadata.StringHandle Name { get { throw null; } }
public readonly System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.NamespaceDefinitionHandle> NamespaceDefinitions { get { throw null; } }
public readonly System.Reflection.Metadata.NamespaceDefinitionHandle Parent { get { throw null; } }
public readonly System.Collections.Immutable.ImmutableArray<System.Reflection.Metadata.TypeDefinitionHandle> TypeDefinitions { get { throw null; } }
}
public readonly partial struct NamespaceDefinitionHandle : System.IEquatable<System.Reflection.Metadata.NamespaceDefinitionHandle>
{
Expand Down Expand Up @@ -2241,16 +2241,16 @@ public partial struct SignatureHeader : System.IEquatable<System.Reflection.Meta
public const byte CallingConventionOrKindMask = (byte)15;
public SignatureHeader(byte rawValue) { throw null; }
public SignatureHeader(System.Reflection.Metadata.SignatureKind kind, System.Reflection.Metadata.SignatureCallingConvention convention, System.Reflection.Metadata.SignatureAttributes attributes) { throw null; }
public System.Reflection.Metadata.SignatureAttributes Attributes { get { throw null; } }
public System.Reflection.Metadata.SignatureCallingConvention CallingConvention { get { throw null; } }
public bool HasExplicitThis { get { throw null; } }
public bool IsGeneric { get { throw null; } }
public bool IsInstance { get { throw null; } }
public System.Reflection.Metadata.SignatureKind Kind { get { throw null; } }
public byte RawValue { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.SignatureHeader other) { throw null; }
public override int GetHashCode() { throw null; }
public readonly System.Reflection.Metadata.SignatureAttributes Attributes { get { throw null; } }
public readonly System.Reflection.Metadata.SignatureCallingConvention CallingConvention { get { throw null; } }
public readonly bool HasExplicitThis { get { throw null; } }
public readonly bool IsGeneric { get { throw null; } }
public readonly bool IsInstance { get { throw null; } }
public readonly System.Reflection.Metadata.SignatureKind Kind { get { throw null; } }
public readonly byte RawValue { get { throw null; } }
public override readonly bool Equals(object? obj) { throw null; }
public readonly bool Equals(System.Reflection.Metadata.SignatureHeader other) { throw null; }
public override readonly int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.SignatureHeader left, System.Reflection.Metadata.SignatureHeader right) { throw null; }
public static bool operator !=(System.Reflection.Metadata.SignatureHeader left, System.Reflection.Metadata.SignatureHeader right) { throw null; }
public override string ToString() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal Chunks(BlobBuilder builder)
}

object IEnumerator.Current => Current;
public BlobBuilder Current => _currentOpt!;
public readonly BlobBuilder Current => _currentOpt!;

public bool MoveNext()
{
Expand Down Expand Up @@ -56,9 +56,9 @@ public void Reset()
void IDisposable.Dispose() { }

// IEnumerable:
public Chunks GetEnumerator() => this;
IEnumerator<BlobBuilder> IEnumerable<BlobBuilder>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public readonly Chunks GetEnumerator() => this;
readonly IEnumerator<BlobBuilder> IEnumerable<BlobBuilder>.GetEnumerator() => GetEnumerator();
readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

public struct Blobs : IEnumerable<Blob>, IEnumerator<Blob>, IEnumerator
Expand All @@ -72,7 +72,7 @@ internal Blobs(BlobBuilder builder)

object IEnumerator.Current => Current;

public Blob Current
public readonly Blob Current
{
get
{
Expand All @@ -94,9 +94,9 @@ public Blob Current
void IDisposable.Dispose() { }

// IEnumerable:
public Blobs GetEnumerator() => this;
IEnumerator<Blob> IEnumerable<Blob>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public readonly Blobs GetEnumerator() => this;
readonly IEnumerator<Blob> IEnumerable<Blob>.GetEnumerator() => GetEnumerator();
readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ internal struct RowCounts : IComparable<RowCounts>
public int AggregateInserts;
public int Updates;

public int CompareTo(RowCounts other)
public readonly int CompareTo(RowCounts other)
{
return AggregateInserts - other.AggregateInserts;
}

public override string ToString()
public override readonly string ToString()
{
return $"+0x{AggregateInserts:x} ~0x{Updates:x}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal BlobHeap(MemoryBlock block, MetadataKind metadataKind)
}
}

internal byte[] GetBytes(BlobHandle handle)
internal readonly byte[] GetBytes(BlobHandle handle)
{
if (handle.IsVirtual)
{
Expand Down Expand Up @@ -136,7 +136,7 @@ internal BlobReader GetBlobReader(BlobHandle handle)
return new BlobReader(GetMemoryBlock(handle));
}

internal BlobHandle GetNextHandle(BlobHandle handle)
internal readonly BlobHandle GetNextHandle(BlobHandle handle)
{
if (handle.IsVirtual)
{
Expand All @@ -158,7 +158,7 @@ internal BlobHandle GetNextHandle(BlobHandle handle)
return BlobHandle.FromOffset(nextIndex);
}

internal byte[] GetVirtualBlobBytes(BlobHandle handle, bool unique)
internal readonly byte[] GetVirtualBlobBytes(BlobHandle handle, bool unique)
{
BlobHandle.VirtualIndex index = handle.GetVirtualIndex();
byte[] result = s_virtualValues![(int)index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static MemoryBlock TrimEnd(MemoryBlock block)
return block.GetMemoryBlockAt(0, i + 2);
}

internal string GetString(StringHandle handle, MetadataStringDecoder utf8Decoder)
internal readonly string GetString(StringHandle handle, MetadataStringDecoder utf8Decoder)
{
return handle.IsVirtual ? GetVirtualHandleString(handle, utf8Decoder) : GetNonVirtualString(handle, utf8Decoder, prefixOpt: null);
}
Expand All @@ -159,7 +159,7 @@ internal static string GetVirtualString(StringHandle.VirtualIndex index)
return s_virtualValues![(int)index];
}

private string GetNonVirtualString(StringHandle handle, MetadataStringDecoder utf8Decoder, byte[]? prefixOpt)
private readonly string GetNonVirtualString(StringHandle handle, MetadataStringDecoder utf8Decoder, byte[]? prefixOpt)
{
Debug.Assert(handle.StringKind != StringKind.Virtual);

Expand All @@ -168,7 +168,7 @@ private string GetNonVirtualString(StringHandle handle, MetadataStringDecoder ut
return Block.PeekUtf8NullTerminated(handle.GetHeapOffset(), prefixOpt, utf8Decoder, out bytesRead, otherTerminator);
}

private unsafe MemoryBlock GetNonVirtualStringMemoryBlock(StringHandle handle)
private unsafe readonly MemoryBlock GetNonVirtualStringMemoryBlock(StringHandle handle)
{
Debug.Assert(handle.StringKind != StringKind.Virtual);

Expand All @@ -180,7 +180,7 @@ private unsafe MemoryBlock GetNonVirtualStringMemoryBlock(StringHandle handle)
return new MemoryBlock(Block.Pointer + offset, length);
}

private unsafe byte[] GetNonVirtualStringBytes(StringHandle handle, byte[] prefix)
private unsafe readonly byte[] GetNonVirtualStringBytes(StringHandle handle, byte[] prefix)
{
Debug.Assert(handle.StringKind != StringKind.Virtual);

Expand All @@ -191,7 +191,7 @@ private unsafe byte[] GetNonVirtualStringBytes(StringHandle handle, byte[] prefi
return bytes;
}

private string GetVirtualHandleString(StringHandle handle, MetadataStringDecoder utf8Decoder)
private readonly string GetVirtualHandleString(StringHandle handle, MetadataStringDecoder utf8Decoder)
{
Debug.Assert(handle.IsVirtual);

Expand Down Expand Up @@ -230,7 +230,7 @@ internal BlobReader GetBlobReader(StringHandle handle)
return new BlobReader(GetMemoryBlock(handle));
}

internal StringHandle GetNextHandle(StringHandle handle)
internal readonly StringHandle GetNextHandle(StringHandle handle)
{
if (handle.IsVirtual)
{
Expand All @@ -246,7 +246,7 @@ internal StringHandle GetNextHandle(StringHandle handle)
return StringHandle.FromOffset(terminator + 1);
}

internal bool Equals(StringHandle handle, string value, MetadataStringDecoder utf8Decoder, bool ignoreCase)
internal readonly bool Equals(StringHandle handle, string value, MetadataStringDecoder utf8Decoder, bool ignoreCase)
{
Debug.Assert(value != null);

Expand All @@ -265,7 +265,7 @@ internal bool Equals(StringHandle handle, string value, MetadataStringDecoder ut
return this.Block.Utf8NullTerminatedEquals(handle.GetHeapOffset(), value, utf8Decoder, otherTerminator, ignoreCase);
}

internal bool StartsWith(StringHandle handle, string value, MetadataStringDecoder utf8Decoder, bool ignoreCase)
internal readonly bool StartsWith(StringHandle handle, string value, MetadataStringDecoder utf8Decoder, bool ignoreCase)
{
Debug.Assert(value != null);

Expand All @@ -287,7 +287,7 @@ internal bool StartsWith(StringHandle handle, string value, MetadataStringDecode
/// <summary>
/// Returns true if the given raw (non-virtual) handle represents the same string as given ASCII string.
/// </summary>
internal bool EqualsRaw(StringHandle rawHandle, string asciiString)
internal readonly bool EqualsRaw(StringHandle rawHandle, string asciiString)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
Expand All @@ -297,7 +297,7 @@ internal bool EqualsRaw(StringHandle rawHandle, string asciiString)
/// <summary>
/// Returns the heap index of the given ASCII character or -1 if not found prior null terminator or end of heap.
/// </summary>
internal int IndexOfRaw(int startIndex, char asciiChar)
internal readonly int IndexOfRaw(int startIndex, char asciiChar)
{
Debug.Assert(asciiChar != 0 && asciiChar <= 0x7f);
return this.Block.Utf8NullTerminatedOffsetOfAsciiChar(startIndex, asciiChar);
Expand All @@ -306,7 +306,7 @@ internal int IndexOfRaw(int startIndex, char asciiChar)
/// <summary>
/// Returns true if the given raw (non-virtual) handle represents a string that starts with given ASCII prefix.
/// </summary>
internal bool StartsWithRaw(StringHandle rawHandle, string asciiPrefix)
internal readonly bool StartsWithRaw(StringHandle rawHandle, string asciiPrefix)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
Expand All @@ -316,7 +316,7 @@ internal bool StartsWithRaw(StringHandle rawHandle, string asciiPrefix)
/// <summary>
/// Equivalent to Array.BinarySearch, searches for given raw (non-virtual) handle in given array of ASCII strings.
/// </summary>
internal int BinarySearchRaw(string[] asciiKeys, StringHandle rawHandle)
internal readonly int BinarySearchRaw(string[] asciiKeys, StringHandle rawHandle)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
Expand Down
Loading