}
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
}
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
}
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
}
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
}
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
ticks = -ticks;
}
- result.parsedTimeSpan._ticks = ticks;
+ result.parsedTimeSpan = new TimeSpan(ticks);
return true;
}
else
internal bool TryParse(ReadOnlySpan<char> input, ref TimeSpanResult result)
{
- result.parsedTimeSpan._ticks = 0;
+ result.parsedTimeSpan = default;
_str = input;
_len = input.Length;
return result.SetBadTimeSpanFailure();
}
- result.parsedTimeSpan._ticks = time;
+ result.parsedTimeSpan = new TimeSpan(time);
return true;
}
namespace System.Runtime.InteropServices
{
- public struct HandleRef
+ public readonly struct HandleRef
{
// ! Do not add or rearrange fields as the EE depends on this layout.
//------------------------------------------------------------------
- private object _wrapper;
- private IntPtr _handle;
+ private readonly object _wrapper;
+ private readonly IntPtr _handle;
//------------------------------------------------------------------
public HandleRef(object wrapper, IntPtr handle)
namespace System.Runtime.Serialization
{
- public struct SerializationEntry
+ public readonly struct SerializationEntry
{
- private string _name;
- private object _value;
- private Type _type;
+ private readonly string _name;
+ private readonly object _value;
+ private readonly Type _type;
internal SerializationEntry(string entryName, object entryValue, Type entryType)
{
}
// Helper to allow sharing all code via IComparable<T> inlineable
- internal struct ComparerComparable<T, TComparer> : IComparable<T>
+ internal readonly struct ComparerComparable<T, TComparer> : IComparable<T>
where TComparer : IComparer<T>
{
- readonly T _value;
- readonly TComparer _comparer;
+ private readonly T _value;
+ private readonly TComparer _comparer;
public ComparerComparable(T value, TComparer comparer)
{
void OnValueChanged(object previousValue, object currentValue, bool contextChanged);
}
- public struct AsyncLocalValueChangedArgs<T>
+ public readonly struct AsyncLocalValueChangedArgs<T>
{
- public T PreviousValue { get; private set; }
- public T CurrentValue { get; private set; }
+ public T PreviousValue { get; }
+ public T CurrentValue { get; }
//
// If the value changed because we changed to a different ExecutionContext, this is true. If it changed
// because someone set the Value property, this is false.
//
- public bool ThreadContextChanged { get; private set; }
+ public bool ThreadContextChanged { get; }
internal AsyncLocalValueChangedArgs(T previousValue, T currentValue, bool contextChanged)
- : this()
{
PreviousValue = previousValue;
CurrentValue = currentValue;
// an appropriate custom ILMarshaler to keep WInRT interop scenarios enabled.
//
[Serializable]
- public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable, ISpanFormattable
+ public readonly struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable, ISpanFormattable
{
public const long TicksPerMillisecond = 10000;
private const double MillisecondsPerTick = 1.0 / TicksPerMillisecond;
// internal so that DateTime doesn't have to call an extra get
// method for some arithmetic operations.
- internal long _ticks; // Do not rename (binary serialization)
+ internal readonly long _ticks; // Do not rename (binary serialization)
public TimeSpan(long ticks)
{
// Private value type used by the Sort methods.
- private struct SorterObjectArray
+ private readonly struct SorterObjectArray
{
- private object[] keys;
- private object[] items;
- private IComparer comparer;
+ private readonly object[] keys;
+ private readonly object[] items;
+ private readonly IComparer comparer;
internal SorterObjectArray(object[] keys, object[] items, IComparer comparer)
{
// Private value used by the Sort methods for instances of Array.
// This is slower than the one for Object[], since we can't use the JIT helpers
// to access the elements. We must use GetValue & SetValue.
- private struct SorterGenericArray
+ private readonly struct SorterGenericArray
{
- private Array keys;
- private Array items;
- private IComparer comparer;
+ private readonly Array keys;
+ private readonly Array items;
+ private readonly IComparer comparer;
internal SorterGenericArray(Array keys, Array items, IComparer comparer)
{
// around lack of first class support for byref fields in C# and IL. The JIT and
// type loader has special handling for it that turns it into a thin wrapper around ref T.
[NonVersionable]
- internal ref struct ByReference<T>
+ internal readonly ref struct ByReference<T>
{
- private IntPtr _value;
+ private readonly IntPtr _value;
public ByReference(ref T value)
{
NestedType
}
- private struct Filter
+ private readonly struct Filter
{
- private MdUtf8String m_name;
- private MemberListType m_listType;
- private uint m_nameHash;
+ private readonly MdUtf8String m_name;
+ private readonly MemberListType m_listType;
+ private readonly uint m_nameHash;
public unsafe Filter(byte* pUtf8Name, int cUtf8Name, MemberListType listType)
{
}
#region Library
- internal unsafe struct MdUtf8String
+ internal readonly unsafe struct MdUtf8String
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern unsafe bool EqualsCaseSensitive(void* szLhs, void* szRhs, int cSz);
return len;
}
- private void* m_pStringHeap; // This is the raw UTF8 string.
- private int m_StringHeapByteLength;
+ private readonly void* m_pStringHeap; // This is the raw UTF8 string.
+ private readonly int m_StringHeapByteLength;
internal MdUtf8String(void* pStringHeap)
{