Skip to content
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 @@ -308,7 +308,7 @@ public bool MoveNext()
return false;
}

public T Current
public readonly T Current
{
get
{
Expand All @@ -327,7 +327,7 @@ void IEnumerator.Reset()
_current = _start - 1;
}

public void Dispose()
public readonly void Dispose()
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public MemoryHandle(void* pointer, GCHandle handle = default, IPinnable? pinnabl
/// Returns the pointer to memory, where the memory is assumed to be pinned and hence the address won't change.
/// </summary>
[CLSCompliant(false)]
public void* Pointer => _pointer;
public readonly void* Pointer => _pointer;

/// <summary>
/// Frees the pinned handle and releases IPinnable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public DictionaryEntry(object key, object? value)

public object Key
{
get => _key;
readonly get => _key;
set => _key = value;
}

public object? Value
{
get => _value;
readonly get => _value;
set => _value = value;
}

Expand All @@ -43,7 +43,7 @@ public void Deconstruct(out object key, out object? value)
value = Value;
}

public override string ToString() =>
public override readonly string ToString() =>
KeyValuePair.PairToString(_key, _value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1807,11 +1807,11 @@ public bool MoveNext()
return false;
}

public KeyValuePair<TKey, TValue> Current => _current;
public readonly KeyValuePair<TKey, TValue> Current => _current;

public void Dispose() { }
public readonly void Dispose() { }

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down Expand Up @@ -1840,7 +1840,7 @@ void IEnumerator.Reset()
_current = default;
}

DictionaryEntry IDictionaryEnumerator.Entry
readonly DictionaryEntry IDictionaryEnumerator.Entry
{
get
{
Expand All @@ -1853,7 +1853,7 @@ DictionaryEntry IDictionaryEnumerator.Entry
}
}

object IDictionaryEnumerator.Key
readonly object IDictionaryEnumerator.Key
{
get
{
Expand All @@ -1866,7 +1866,7 @@ object IDictionaryEnumerator.Key
}
}

object? IDictionaryEnumerator.Value
readonly object? IDictionaryEnumerator.Value
{
get
{
Expand Down Expand Up @@ -2022,7 +2022,7 @@ internal Enumerator(Dictionary<TKey, TValue> dictionary)
_currentKey = default;
}

public void Dispose() { }
public readonly void Dispose() { }

public bool MoveNext()
{
Expand All @@ -2047,9 +2047,9 @@ public bool MoveNext()
return false;
}

public TKey Current => _currentKey!;
public readonly TKey Current => _currentKey!;

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down Expand Up @@ -2216,7 +2216,7 @@ internal Enumerator(Dictionary<TKey, TValue> dictionary)
_currentValue = default;
}

public void Dispose() { }
public readonly void Dispose() { }

public bool MoveNext()
{
Expand All @@ -2240,9 +2240,9 @@ public bool MoveNext()
return false;
}

public TValue Current => _currentValue!;
public readonly TValue Current => _currentValue!;

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ internal static IAlternateEqualityComparer<TAlternate, T> GetAlternateComparer(H
/// <summary>Adds the specified element to a set.</summary>
/// <param name="item">The element to add to the set.</param>
/// <returns>true if the element is added to the set; false if the element is already present.</returns>
public bool Add(TAlternate item)
public readonly bool Add(TAlternate item)
{
HashSet<T> set = Set;
IAlternateEqualityComparer<TAlternate, T> comparer = GetAlternateComparer(set);
Expand Down Expand Up @@ -538,7 +538,7 @@ public bool Add(TAlternate item)
/// <summary>Removes the specified element from a set.</summary>
/// <param name="item">The element to remove.</param>
/// <returns>true if the element is successfully found and removed; otherwise, false.</returns>
public bool Remove(TAlternate item)
public readonly bool Remove(TAlternate item)
{
HashSet<T> set = Set;
IAlternateEqualityComparer<TAlternate, T> comparer = GetAlternateComparer(set);
Expand Down Expand Up @@ -623,7 +623,7 @@ public bool TryGetValue(TAlternate equalValue, [MaybeNullWhen(false)] out T actu
}

/// <summary>Finds the item in the set and returns a reference to the found item, or a null reference if not found.</summary>
internal ref readonly T FindValue(TAlternate item)
internal readonly ref readonly T FindValue(TAlternate item)
{
HashSet<T> set = Set;
IAlternateEqualityComparer<TAlternate, T> comparer = GetAlternateComparer(set);
Expand Down Expand Up @@ -1834,11 +1834,11 @@ public bool MoveNext()
return false;
}

public T Current => _current;
public readonly T Current => _current;

public void Dispose() { }
public readonly void Dispose() { }

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ internal Enumerator(List<T> list)
_current = default;
}

public void Dispose()
public readonly void Dispose()
{
}

Expand Down Expand Up @@ -1228,7 +1228,7 @@ private bool MoveNextRare()
return false;
}

public T Current => _current!;
public readonly T Current => _current!;

object? IEnumerator.Current
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public T Current
}
}

private void ThrowEnumerationNotStartedOrEnded()
private readonly void ThrowEnumerationNotStartedOrEnded()
{
Debug.Assert(_index == -1 || _index == -2);
throw new InvalidOperationException(_index == -1 ? SR.InvalidOperation_EnumNotStarted : SR.InvalidOperation_EnumEnded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ValueListBuilder(Span<T> initialSpan)

public int Length
{
get => _pos;
readonly get => _pos;
set
{
Debug.Assert(value >= 0);
Expand Down Expand Up @@ -138,12 +138,12 @@ private void AddWithResize(T item)
_pos = pos + 1;
}

public ReadOnlySpan<T> AsSpan()
public readonly ReadOnlySpan<T> AsSpan()
{
return _span.Slice(0, _pos);
}

public bool TryCopyTo(Span<T> destination, out int itemsWritten)
public readonly bool TryCopyTo(Span<T> destination, out int itemsWritten)
{
if (_span.Slice(0, _pos).TryCopyTo(destination))
{
Expand Down
26 changes: 13 additions & 13 deletions src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,29 @@ private struct DecCalc

private uint High
{
get => uhi;
readonly get => uhi;
set => uhi = value;
}

private uint Low
{
get => ulo;
readonly get => ulo;
set => ulo = value;
}

private uint Mid
{
get => umid;
readonly get => umid;
set => umid = value;
}

private bool IsNegative => (int)uflags < 0;
private readonly bool IsNegative => (int)uflags < 0;

private int Scale => (byte)(uflags >> ScaleShift);
private readonly int Scale => (byte)(uflags >> ScaleShift);

private ulong Low64
{
get => ulomid;
readonly get => ulomid;
set => ulomid = value;
}

Expand Down Expand Up @@ -2520,7 +2520,7 @@ public ulong Low64
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
readonly get => ulo64LE;
set => ulo64LE = value;
#endif
}
Expand All @@ -2534,7 +2534,7 @@ public ulong High64
get => ((ulong)U2 << 32) | U1;
set { U2 = (uint)(value >> 32); U1 = (uint)value; }
#else
get => uhigh64LE;
readonly get => uhigh64LE;
set => uhigh64LE = value;
#endif
}
Expand Down Expand Up @@ -2563,7 +2563,7 @@ public ulong Low64
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
readonly get => ulo64LE;
set => ulo64LE = value;
#endif
}
Expand All @@ -2574,7 +2574,7 @@ public ulong High64
get => ((ulong)U3 << 32) | U2;
set { U3 = (uint)(value >> 32); U2 = (uint)value; }
#else
get => uhigh64LE;
readonly get => uhigh64LE;
set => uhigh64LE = value;
#endif
}
Expand Down Expand Up @@ -2609,7 +2609,7 @@ public ulong Low64
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
readonly get => ulo64LE;
set => ulo64LE = value;
#endif
}
Expand All @@ -2620,7 +2620,7 @@ public ulong Mid64
get => ((ulong)U3 << 32) | U2;
set { U3 = (uint)(value >> 32); U2 = (uint)value; }
#else
get => umid64LE;
readonly get => umid64LE;
set => umid64LE = value;
#endif
}
Expand All @@ -2631,7 +2631,7 @@ public ulong High64
get => ((ulong)U5 << 32) | U4;
set { U5 = (uint)(value >> 32); U4 = (uint)value; }
#else
get => uhigh64LE;
readonly get => uhigh64LE;
set => uhigh64LE = value;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Private.CoreLib/src/System/Delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal InvocationListEnumerator(MulticastDelegate? d)
/// <summary>
/// Implements the IEnumerator pattern.
/// </summary>
public TDelegate Current
public readonly TDelegate Current
{
get => _current!;
}
Expand All @@ -141,7 +141,7 @@ public bool MoveNext()
/// </summary>
/// <returns>An IEnumerator instance that can be used to iterate through the invocation targets of the delegate.</returns>
[EditorBrowsable(EditorBrowsableState.Never)] // Only here to make foreach work
public System.Delegate.InvocationListEnumerator<TDelegate> GetEnumerator() => this;
public readonly System.Delegate.InvocationListEnumerator<TDelegate> GetEnumerator() => this;
}

public object? DynamicInvoke(params object?[]? args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal static void MarshalToNative(EventPipeProviderConfiguration managed, ref
native.m_pFilterData = (char*)Marshal.StringToCoTaskMemUni(managed.FilterData);
}

internal void Release()
internal readonly void Release()
{
if (m_pProviderName != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private static unsafe bool GenerateMetadataForProperty(PropertyAnalysis property
return true;
}

internal unsafe bool GenerateMetadataV2(byte* pMetadataBlob, ref uint offset, uint blobSize)
internal readonly unsafe bool GenerateMetadataV2(byte* pMetadataBlob, ref uint offset, uint blobSize)
{
if (TypeInfo == null)
return false;
Expand Down Expand Up @@ -564,7 +564,7 @@ internal static bool GetTypeInfoFromType(Type? type, out TraceLoggingTypeInfo? t
}
}

internal bool GetMetadataLength(out uint size)
internal readonly bool GetMetadataLength(out uint size)
{
size = 0;

Expand Down Expand Up @@ -667,7 +667,7 @@ private static TypeCode GetTypeCodeExtended(Type parameterType)
return Type.GetTypeCode(parameterType);
}

internal bool GetMetadataLengthV2(out uint size)
internal readonly bool GetMetadataLengthV2(out uint size)
{
return GetMetadataLengthForNamedTypeV2(ParameterName, TypeInfo, out size);
}
Expand Down
Loading
Loading