Skip to content

Commit

Permalink
readonly annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
hrrrrustic committed Apr 12, 2021
1 parent 355eff5 commit 9a167d8
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 80 deletions.
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

0 comments on commit 9a167d8

Please sign in to comment.