get { return false; }
}
- object? ICollection.SyncRoot
+ object ICollection.SyncRoot
{
get
{
Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
}
}
- return m_syncRoot;
+ return m_syncRoot!; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34901
}
}
get { return false; }
}
- object? ICollection.SyncRoot
+ object ICollection.SyncRoot
{
get
{
}
else
{
- Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
+ Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34901
}
}
- return m_syncRoot;
+ return m_syncRoot!;
}
}
get { return false; }
}
- object? ICollection.SyncRoot
+ object ICollection.SyncRoot
{
get
{
Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
}
}
- return m_syncRoot;
+ return m_syncRoot!; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34901
}
}
// IList & ICollection methods.
// This enables two-way data binding and index access in Jupiter
//
- object IList.this[int index]
+ object? IList.this[int index]
{
get
{
}
}
- int IList.Add(object value)
+ int IList.Add(object? value)
{
return _list.Add(value);
}
- bool IList.Contains(object value)
+ bool IList.Contains(object? value)
{
return _list.Contains(value);
}
}
}
- int IList.IndexOf(object value)
+ int IList.IndexOf(object? value)
{
return _list.IndexOf(value);
}
- void IList.Insert(int index, object value)
+ void IList.Insert(int index, object? value)
{
_list.Insert(index, value);
}
- void IList.Remove(object value)
+ void IList.Remove(object? value)
{
_list.Remove(value);
}
}
// object GetAt(uint index)
- internal object GetAt(uint index)
+ internal object? GetAt(uint index)
{
IList _this = Unsafe.As<IList>(this);
EnsureIndexInt32(index, _this.Count);
}
// bool IndexOf(object value, out uint index)
- internal bool IndexOf(object value, out uint index)
+ internal bool IndexOf(object? value, out uint index)
{
IList _this = Unsafe.As<IList>(this);
int ind = _this.IndexOf(value);
}
// void SetAt(uint index, object value)
- internal void SetAt(uint index, object value)
+ internal void SetAt(uint index, object? value)
{
IList _this = Unsafe.As<IList>(this);
EnsureIndexInt32(index, _this.Count);
}
// void InsertAt(uint index, object value)
- internal void InsertAt(uint index, object value)
+ internal void InsertAt(uint index, object? value)
{
IList _this = Unsafe.As<IList>(this);
}
// void Append(object value)
- internal void Append(object value)
+ internal void Append(object? value)
{
IList _this = Unsafe.As<IList>(this);
_this.Add(value);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
/*============================================================
**
** Class: ArrayList
#endif
public class ArrayList : IList, ICloneable
{
- private object[] _items; // Do not rename (binary serialization)
+ private object?[] _items = null!; // Do not rename (binary serialization)
private int _size; // Do not rename (binary serialization)
private int _version; // Do not rename (binary serialization)
// Sets or Gets the element at the given index.
//
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
// increased by one. If required, the capacity of the list is doubled
// before adding the new element.
//
- public virtual int Add(object value)
+ public virtual int Add(object? value)
{
if (_size == _items.Length) EnsureCapacity(_size + 1);
_items[_size] = value;
// The method uses the Array.BinarySearch method to perform the
// search.
//
- public virtual int BinarySearch(int index, int count, object value, IComparer comparer)
+ public virtual int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum);
return Array.BinarySearch((Array)_items, index, count, value, comparer);
}
- public virtual int BinarySearch(object value)
+ public virtual int BinarySearch(object? value)
{
return BinarySearch(0, Count, value, null);
}
- public virtual int BinarySearch(object value, IComparer comparer)
+ public virtual int BinarySearch(object? value, IComparer? comparer)
{
return BinarySearch(0, Count, value, comparer);
}
// It does a linear, O(n) search. Equality is determined by calling
// item.Equals().
//
- public virtual bool Contains(object item)
+ public virtual bool Contains(object? item)
{
if (item == null)
{
else
{
for (int i = 0; i < _size; i++)
- if ((_items[i] != null) && (_items[i].Equals(item)))
+ if ((_items[i] != null) && (_items[i]!.Equals(item))) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644
return true;
return false;
}
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
// Delegate rest of error checking to Array.Copy.
- Array.Copy(_items, 0, array, arrayIndex, _size);
+ Array.Copy(_items, 0, array!, arrayIndex, _size);
}
// Copies a section of this list to the given array at the given index.
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
// Delegate rest of error checking to Array.Copy.
- Array.Copy(_items, index, array, arrayIndex, count);
+ Array.Copy(_items, index, array!, arrayIndex, count);
}
// Ensures that the capacity of this list is at least the given minimum
// This method uses the Array.IndexOf method to perform the
// search.
//
- public virtual int IndexOf(object value)
+ public virtual int IndexOf(object? value)
{
return Array.IndexOf((Array)_items, value, 0, _size);
}
// This method uses the Array.IndexOf method to perform the
// search.
//
- public virtual int IndexOf(object value, int startIndex)
+ public virtual int IndexOf(object? value, int startIndex)
{
if (startIndex > _size)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
// This method uses the Array.IndexOf method to perform the
// search.
//
- public virtual int IndexOf(object value, int startIndex, int count)
+ public virtual int IndexOf(object? value, int startIndex, int count)
{
if (startIndex > _size)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
// is increased by one. If required, the capacity of the list is doubled
// before inserting the new element.
//
- public virtual void Insert(int index, object value)
+ public virtual void Insert(int index, object? value)
{
// Note that insertions at the end are legal.
if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
// This method uses the Array.LastIndexOf method to perform the
// search.
//
- public virtual int LastIndexOf(object value)
+ public virtual int LastIndexOf(object? value)
{
return LastIndexOf(value, _size - 1, _size);
}
// This method uses the Array.LastIndexOf method to perform the
// search.
//
- public virtual int LastIndexOf(object value, int startIndex)
+ public virtual int LastIndexOf(object? value, int startIndex)
{
if (startIndex >= _size)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
// This method uses the Array.LastIndexOf method to perform the
// search.
//
- public virtual int LastIndexOf(object value, int startIndex, int count)
+ public virtual int LastIndexOf(object? value, int startIndex, int count)
{
if (Count != 0 && (startIndex < 0 || count < 0))
throw new ArgumentOutOfRangeException(startIndex < 0 ? nameof(startIndex) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
// Removes the element at the given index. The size of the list is
// decreased by one.
//
- public virtual void Remove(object obj)
+ public virtual void Remove(object? obj)
{
int index = IndexOf(obj);
if (index >= 0)
// Returns an IList that contains count copies of value.
//
- public static ArrayList Repeat(object value, int count)
+ public static ArrayList Repeat(object? value, int count)
{
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
// Sorts the elements in this list. Uses Array.Sort with the
// provided comparer.
- public virtual void Sort(IComparer comparer)
+ public virtual void Sort(IComparer? comparer)
{
Sort(0, Count, comparer);
}
//
// This method uses the Array.Sort method to sort the elements.
//
- public virtual void Sort(int index, int count, IComparer comparer)
+ public virtual void Sort(int index, int count, IComparer? comparer)
{
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum);
// ToArray returns a new Object array containing the contents of the ArrayList.
// This requires copying the ArrayList, which is an O(n) operation.
- public virtual object[] ToArray()
+ public virtual object?[] ToArray()
{
if (_size == 0)
return Array.Empty<Object>();
- object[] array = new object[_size];
+ object?[] array = new object[_size];
Array.Copy(_items, 0, array, 0, _size);
return array;
}
get { return _list.IsSynchronized; }
}
- public override object this[int index]
+ public override object? this[int index]
{
get
{
get { return _list.SyncRoot; }
}
- public override int Add(object obj)
+ public override int Add(object? obj)
{
int i = _list.Add(obj);
_version++;
}
// Other overloads with automatically work
- public override int BinarySearch(int index, int count, object value, IComparer comparer)
+ public override int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
if (index < 0 || count < 0)
throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
return new IListWrapper(_list);
}
- public override bool Contains(object obj)
+ public override bool Contains(object? obj)
{
return _list.Contains(obj);
}
return new IListWrapperEnumWrapper(this, index, count);
}
- public override int IndexOf(object value)
+ public override int IndexOf(object? value)
{
return _list.IndexOf(value);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex)
+ public override int IndexOf(object? value, int startIndex)
{
return IndexOf(value, startIndex, _list.Count - startIndex);
}
- public override int IndexOf(object value, int startIndex, int count)
+ public override int IndexOf(object? value, int startIndex, int count)
{
if (startIndex < 0 || startIndex > Count) throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
if (count < 0 || startIndex > Count - count) throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
else
{
for (int i = startIndex; i < endIndex; i++)
- if (_list[i] != null && _list[i].Equals(value))
+ if (_list[i] != null && _list[i]!.Equals(value)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644
return i;
return -1;
}
}
- public override void Insert(int index, object obj)
+ public override void Insert(int index, object? obj)
{
_list.Insert(index, obj);
_version++;
if (c.Count > 0)
{
- ArrayList al = _list as ArrayList;
+ ArrayList? al = _list as ArrayList;
if (al != null)
{
// We need to special case ArrayList.
}
}
- public override int LastIndexOf(object value)
+ public override int LastIndexOf(object? value)
{
return LastIndexOf(value, _list.Count - 1, _list.Count);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex)
+ public override int LastIndexOf(object? value, int startIndex)
{
return LastIndexOf(value, startIndex, startIndex + 1);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex, int count)
+ public override int LastIndexOf(object? value, int startIndex, int count)
{
if (_list.Count == 0)
return -1;
else
{
for (int i = startIndex; i >= endIndex; i--)
- if (_list[i] != null && _list[i].Equals(value))
+ if (_list[i] != null && _list[i]!.Equals(value)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644
return i;
return -1;
}
}
- public override void Remove(object value)
+ public override void Remove(object? value)
{
int index = IndexOf(value);
if (index >= 0)
int j = index + count - 1;
while (i < j)
{
- object tmp = _list[i];
+ object? tmp = _list[i];
_list[i++] = _list[j];
_list[j--] = tmp;
}
return new Range(this, index, count);
}
- public override void Sort(int index, int count, IComparer comparer)
+ public override void Sort(int index, int count, IComparer? comparer)
{
if (index < 0 || count < 0)
throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
if (Count == 0)
- return Array.Empty<Object>();
+ return Array.Empty<object?>();
- object[] array = new object[Count];
+ object?[] array = new object[Count];
_list.CopyTo(array, 0);
return array;
}
// class that implements all of ArrayList's methods.
private sealed class IListWrapperEnumWrapper : IEnumerator, ICloneable
{
- private IEnumerator _en;
+ private IEnumerator _en = null!;
private int _remaining;
private int _initialStartIndex; // for reset
private int _initialCount; // for reset
return r && _remaining-- > 0;
}
- public object Current
+ public object? Current
{
get
{
get { return true; }
}
- public override object this[int index]
+ public override object? this[int index]
{
get
{
get { return _root; }
}
- public override int Add(object value)
+ public override int Add(object? value)
{
lock (_root)
{
}
}
- public override int BinarySearch(object value)
+ public override int BinarySearch(object? value)
{
lock (_root)
{
}
}
- public override int BinarySearch(object value, IComparer comparer)
+ public override int BinarySearch(object? value, IComparer? comparer)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int BinarySearch(int index, int count, object value, IComparer comparer)
+ public override int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
lock (_root)
{
}
}
- public override bool Contains(object item)
+ public override bool Contains(object? item)
{
lock (_root)
{
}
}
- public override int IndexOf(object value)
+ public override int IndexOf(object? value)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex)
+ public override int IndexOf(object? value, int startIndex)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex, int count)
+ public override int IndexOf(object? value, int startIndex, int count)
{
lock (_root)
{
}
}
- public override void Insert(int index, object value)
+ public override void Insert(int index, object? value)
{
lock (_root)
{
}
}
- public override int LastIndexOf(object value)
+ public override int LastIndexOf(object? value)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex)
+ public override int LastIndexOf(object? value, int startIndex)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex, int count)
+ public override int LastIndexOf(object? value, int startIndex, int count)
{
lock (_root)
{
}
}
- public override void Remove(object value)
+ public override void Remove(object? value)
{
lock (_root)
{
}
}
- public override void Sort(IComparer comparer)
+ public override void Sort(IComparer? comparer)
{
lock (_root)
{
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override void Sort(int index, int count, IComparer comparer)
+ public override void Sort(int index, int count, IComparer? comparer)
{
lock (_root)
{
}
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
lock (_root)
{
get { return true; }
}
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
get { return _root; }
}
- public virtual int Add(object value)
+ public virtual int Add(object? value)
{
lock (_root)
{
}
}
- public virtual bool Contains(object item)
+ public virtual bool Contains(object? item)
{
lock (_root)
{
}
}
- public virtual int IndexOf(object value)
+ public virtual int IndexOf(object? value)
{
lock (_root)
{
}
}
- public virtual void Insert(int index, object value)
+ public virtual void Insert(int index, object? value)
{
lock (_root)
{
}
}
- public virtual void Remove(object value)
+ public virtual void Remove(object? value)
{
lock (_root)
{
get { return _list.IsSynchronized; }
}
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
get { return _list.SyncRoot; }
}
- public virtual int Add(object obj)
+ public virtual int Add(object? obj)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
- public virtual bool Contains(object obj)
+ public virtual bool Contains(object? obj)
{
return _list.Contains(obj);
}
return _list.GetEnumerator();
}
- public virtual int IndexOf(object value)
+ public virtual int IndexOf(object? value)
{
return _list.IndexOf(value);
}
- public virtual void Insert(int index, object obj)
+ public virtual void Insert(int index, object? obj)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
- public virtual void Remove(object value)
+ public virtual void Remove(object? value)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
get { return _list.IsSynchronized; }
}
- public override object this[int index]
+ public override object? this[int index]
{
get
{
get { return _list.SyncRoot; }
}
- public override int Add(object obj)
+ public override int Add(object? obj)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int BinarySearch(int index, int count, object value, IComparer comparer)
+ public override int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
return _list.BinarySearch(index, count, value, comparer);
}
return arrayList;
}
- public override bool Contains(object obj)
+ public override bool Contains(object? obj)
{
return _list.Contains(obj);
}
return _list.GetEnumerator(index, count);
}
- public override int IndexOf(object value)
+ public override int IndexOf(object? value)
{
return _list.IndexOf(value);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex)
+ public override int IndexOf(object? value, int startIndex)
{
return _list.IndexOf(value, startIndex);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex, int count)
+ public override int IndexOf(object? value, int startIndex, int count)
{
return _list.IndexOf(value, startIndex, count);
}
- public override void Insert(int index, object obj)
+ public override void Insert(int index, object? obj)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
- public override int LastIndexOf(object value)
+ public override int LastIndexOf(object? value)
{
return _list.LastIndexOf(value);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex)
+ public override int LastIndexOf(object? value, int startIndex)
{
return _list.LastIndexOf(value, startIndex);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex, int count)
+ public override int LastIndexOf(object? value, int startIndex, int count)
{
return _list.LastIndexOf(value, startIndex, count);
}
- public override void Remove(object value)
+ public override void Remove(object? value)
{
throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
}
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override void Sort(int index, int count, IComparer comparer)
+ public override void Sort(int index, int count, IComparer? comparer)
{
_list.Sort(index, count, comparer);
_version = _list._version;
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
return _list.ToArray();
}
get { return _list.IsSynchronized; }
}
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
get { return _list.SyncRoot; }
}
- public virtual int Add(object obj)
+ public virtual int Add(object? obj)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
- public virtual bool Contains(object obj)
+ public virtual bool Contains(object? obj)
{
return _list.Contains(obj);
}
return _list.GetEnumerator();
}
- public virtual int IndexOf(object value)
+ public virtual int IndexOf(object? value)
{
return _list.IndexOf(value);
}
- public virtual void Insert(int index, object obj)
+ public virtual void Insert(int index, object? obj)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
- public virtual void Remove(object value)
+ public virtual void Remove(object? value)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
get { return _list.IsSynchronized; }
}
- public override object this[int index]
+ public override object? this[int index]
{
get
{
get { return _list.SyncRoot; }
}
- public override int Add(object obj)
+ public override int Add(object? obj)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int BinarySearch(int index, int count, object value, IComparer comparer)
+ public override int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
return _list.BinarySearch(index, count, value, comparer);
}
return arrayList;
}
- public override bool Contains(object obj)
+ public override bool Contains(object? obj)
{
return _list.Contains(obj);
}
return _list.GetEnumerator(index, count);
}
- public override int IndexOf(object value)
+ public override int IndexOf(object? value)
{
return _list.IndexOf(value);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex)
+ public override int IndexOf(object? value, int startIndex)
{
return _list.IndexOf(value, startIndex);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int IndexOf(object value, int startIndex, int count)
+ public override int IndexOf(object? value, int startIndex, int count)
{
return _list.IndexOf(value, startIndex, count);
}
- public override void Insert(int index, object obj)
+ public override void Insert(int index, object? obj)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
- public override int LastIndexOf(object value)
+ public override int LastIndexOf(object? value)
{
return _list.LastIndexOf(value);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex)
+ public override int LastIndexOf(object? value, int startIndex)
{
return _list.LastIndexOf(value, startIndex);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex, int count)
+ public override int LastIndexOf(object? value, int startIndex, int count)
{
return _list.LastIndexOf(value, startIndex, count);
}
- public override void Remove(object value)
+ public override void Remove(object? value)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override void Sort(int index, int count, IComparer comparer)
+ public override void Sort(int index, int count, IComparer? comparer)
{
throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
return _list.ToArray();
}
private int _index;
private int _endIndex; // Where to stop.
private int _version;
- private object _currentElement;
+ private object? _currentElement;
private int _startIndex; // Save this for Reset.
internal ArrayListEnumerator(ArrayList list, int index, int count)
return false;
}
- public object Current
+ public object? Current
{
get
{
_version++;
}
- public override int Add(object value)
+ public override int Add(object? value)
{
InternalUpdateRange();
_baseList.Insert(_baseIndex + _baseSize, value);
}
}
- public override int BinarySearch(int index, int count, object value, IComparer comparer)
+ public override int BinarySearch(int index, int count, object? value, IComparer? comparer)
{
if (index < 0 || count < 0)
throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
return arrayList;
}
- public override bool Contains(object item)
+ public override bool Contains(object? item)
{
InternalUpdateRange();
if (item == null)
else
{
for (int i = 0; i < _baseSize; i++)
- if (_baseList[_baseIndex + i] != null && _baseList[_baseIndex + i].Equals(item))
+ if (_baseList[_baseIndex + i] != null && _baseList[_baseIndex + i]!.Equals(item)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644
return true;
return false;
}
}
- public override int IndexOf(object value)
+ public override int IndexOf(object? value)
{
InternalUpdateRange();
int i = _baseList.IndexOf(value, _baseIndex, _baseSize);
return -1;
}
- public override int IndexOf(object value, int startIndex)
+ public override int IndexOf(object? value, int startIndex)
{
if (startIndex < 0)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_NeedNonNegNum);
return -1;
}
- public override int IndexOf(object value, int startIndex, int count)
+ public override int IndexOf(object? value, int startIndex, int count)
{
if (startIndex < 0 || startIndex > _baseSize)
throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index);
return -1;
}
- public override void Insert(int index, object value)
+ public override void Insert(int index, object? value)
{
if (index < 0 || index > _baseSize) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
}
- public override int LastIndexOf(object value)
+ public override int LastIndexOf(object? value)
{
InternalUpdateRange();
int i = _baseList.LastIndexOf(value, _baseIndex + _baseSize - 1, _baseSize);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex)
+ public override int LastIndexOf(object? value, int startIndex)
{
return LastIndexOf(value, startIndex, startIndex + 1);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
- public override int LastIndexOf(object value, int startIndex, int count)
+ public override int LastIndexOf(object? value, int startIndex, int count)
{
InternalUpdateRange();
if (_baseSize == 0)
}
}
- public override void Sort(int index, int count, IComparer comparer)
+ public override void Sort(int index, int count, IComparer? comparer)
{
if (index < 0 || count < 0)
throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
InternalUpdateVersion();
}
- public override object this[int index]
+ public override object? this[int index]
{
get
{
}
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
InternalUpdateRange();
if (_baseSize == 0)
- return Array.Empty<Object>();
+ return Array.Empty<object?>();
object[] array = new object[_baseSize];
Array.Copy(_baseList._items, _baseIndex, array, 0, _baseSize);
return array;
private ArrayList _list;
private int _index;
private int _version;
- private object _currentElement;
+ private object? _currentElement;
private bool _isArrayList;
// this object is used to indicate enumeration has not started or has terminated
private static object s_dummyObject = new object();
}
}
- public object Current
+ public object? Current
{
get
{
- object temp = _currentElement;
+ object? temp = _currentElement;
if (s_dummyObject == temp)
{ // check if enumeration has not started or has terminated
if (_index == -1)
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public object[] Items
+ public object?[] Items
{
get
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
/*============================================================
**
** Purpose: Default IComparer implementation.
if (info == null)
throw new ArgumentNullException(nameof(info));
- _compareInfo = (CompareInfo)info.GetValue("CompareInfo", typeof(CompareInfo));
+ _compareInfo = (CompareInfo)info.GetValue("CompareInfo", typeof(CompareInfo))!;
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
// If a doesn't implement IComparable and b does, -(b.CompareTo(a)) is returned.
// Otherwise an exception is thrown.
//
- public int Compare(object a, object b)
+ public int Compare(object? a, object? b)
{
if (a == b) return 0;
if (a == null) return -1;
if (b == null) return 1;
- string sa = a as string;
+ string? sa = a as string;
if (sa != null && b is string sb)
return _compareInfo.Compare(sa, sb);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
#pragma warning disable 618 // obsolete types
namespace System.Collections
{
internal sealed class CompatibleComparer : IEqualityComparer
{
- private readonly IHashCodeProvider _hcp;
- private readonly IComparer _comparer;
+ private readonly IHashCodeProvider? _hcp;
+ private readonly IComparer? _comparer;
- internal CompatibleComparer(IHashCodeProvider hashCodeProvider, IComparer comparer)
+ internal CompatibleComparer(IHashCodeProvider? hashCodeProvider, IComparer? comparer)
{
_hcp = hashCodeProvider;
_comparer = comparer;
}
- internal IHashCodeProvider HashCodeProvider => _hcp;
+ internal IHashCodeProvider? HashCodeProvider => _hcp;
- internal IComparer Comparer => _comparer;
+ internal IComparer? Comparer => _comparer;
- public new bool Equals(object a, object b) => Compare(a, b) == 0;
+ public new bool Equals(object? a, object? b) => Compare(a, b) == 0;
- public int Compare(object a, object b)
+ public int Compare(object? a, object? b)
{
if (a == b)
return 0;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
// Used by Hashtable and Dictionary's SeralizationInfo .ctor's to store the SeralizationInfo
// object until OnDeserialization is called.
{
internal static partial class HashHelpers
{
- private static ConditionalWeakTable<object, SerializationInfo> s_serializationInfoTable;
+ private static ConditionalWeakTable<object, SerializationInfo>? s_serializationInfoTable;
public static ConditionalWeakTable<object, SerializationInfo> SerializationInfoTable
{
if (s_serializationInfoTable == null)
Interlocked.CompareExchange(ref s_serializationInfoTable, new ConditionalWeakTable<object, SerializationInfo>(), null);
- return s_serializationInfoTable;
+ return s_serializationInfoTable!; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34901
}
}
}
-}
\ No newline at end of file
+}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
+#nullable enable
using System.Diagnostics;
namespace System.Collections
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
/*============================================================
**
** Class: Hashtable
// This cannot be serialized
private struct bucket
{
- public object key;
- public object val;
+ public object? key;
+ public object? val;
public int hash_coll; // Store hash code; sign bit means there was a collision.
}
- private bucket[] _buckets;
+ private bucket[] _buckets = null!;
// The total number of entries in the hash table.
private int _count;
private volatile int _version;
private volatile bool _isWriterInProgress;
- private ICollection _keys;
- private ICollection _values;
+ private ICollection? _keys;
+ private ICollection? _values;
- private IEqualityComparer _keycomparer;
+ private IEqualityComparer? _keycomparer;
[Obsolete("Please use EqualityComparer property.")]
- protected IHashCodeProvider hcp
+ protected IHashCodeProvider? hcp
{
get
{
}
else if (_keycomparer == null)
{
- _keycomparer = new CompatibleComparer(value, (IComparer)null);
+ _keycomparer = new CompatibleComparer(value, (IComparer?)null);
}
else
{
}
[Obsolete("Please use KeyComparer properties.")]
- protected IComparer comparer
+ protected IComparer? comparer
{
get
{
}
else if (_keycomparer == null)
{
- _keycomparer = new CompatibleComparer((IHashCodeProvider)null, value);
+ _keycomparer = new CompatibleComparer((IHashCodeProvider?)null, value);
}
else
{
}
- protected IEqualityComparer EqualityComparer
+ protected IEqualityComparer? EqualityComparer
{
get
{
Debug.Assert(_loadsize < hashsize, "Invalid hashtable loadsize!");
}
- public Hashtable(int capacity, float loadFactor, IEqualityComparer equalityComparer) : this(capacity, loadFactor)
+ public Hashtable(int capacity, float loadFactor, IEqualityComparer? equalityComparer) : this(capacity, loadFactor)
{
_keycomparer = equalityComparer;
}
[Obsolete("Please use Hashtable(IEqualityComparer) instead.")]
- public Hashtable(IHashCodeProvider hcp, IComparer comparer)
+ public Hashtable(IHashCodeProvider? hcp, IComparer? comparer)
: this(0, 1.0f, hcp, comparer)
{
}
- public Hashtable(IEqualityComparer equalityComparer) : this(0, 1.0f, equalityComparer)
+ public Hashtable(IEqualityComparer? equalityComparer) : this(0, 1.0f, equalityComparer)
{
}
[Obsolete("Please use Hashtable(int, IEqualityComparer) instead.")]
- public Hashtable(int capacity, IHashCodeProvider hcp, IComparer comparer)
+ public Hashtable(int capacity, IHashCodeProvider? hcp, IComparer? comparer)
: this(capacity, 1.0f, hcp, comparer)
{
}
- public Hashtable(int capacity, IEqualityComparer equalityComparer)
+ public Hashtable(int capacity, IEqualityComparer? equalityComparer)
: this(capacity, 1.0f, equalityComparer)
{
}
// dictionary. The hashtable is created with the given load factor.
//
public Hashtable(IDictionary d, float loadFactor)
- : this(d, loadFactor, (IEqualityComparer)null)
+ : this(d, loadFactor, (IEqualityComparer?)null)
{
}
[Obsolete("Please use Hashtable(IDictionary, IEqualityComparer) instead.")]
- public Hashtable(IDictionary d, IHashCodeProvider hcp, IComparer comparer)
+ public Hashtable(IDictionary d, IHashCodeProvider? hcp, IComparer? comparer)
: this(d, 1.0f, hcp, comparer)
{
}
- public Hashtable(IDictionary d, IEqualityComparer equalityComparer)
+ public Hashtable(IDictionary d, IEqualityComparer? equalityComparer)
: this(d, 1.0f, equalityComparer)
{
}
[Obsolete("Please use Hashtable(int, float, IEqualityComparer) instead.")]
- public Hashtable(int capacity, float loadFactor, IHashCodeProvider hcp, IComparer comparer)
+ public Hashtable(int capacity, float loadFactor, IHashCodeProvider? hcp, IComparer? comparer)
: this(capacity, loadFactor)
{
if (hcp != null || comparer != null)
}
[Obsolete("Please use Hashtable(IDictionary, float, IEqualityComparer) instead.")]
- public Hashtable(IDictionary d, float loadFactor, IHashCodeProvider hcp, IComparer comparer)
+ public Hashtable(IDictionary d, float loadFactor, IHashCodeProvider? hcp, IComparer? comparer)
: this((d != null ? d.Count : 0), loadFactor, hcp, comparer)
{
if (d == null)
Add(e.Key, e.Value);
}
- public Hashtable(IDictionary d, float loadFactor, IEqualityComparer equalityComparer)
+ public Hashtable(IDictionary d, float loadFactor, IEqualityComparer? equalityComparer)
: this((d != null ? d.Count : 0), loadFactor, equalityComparer)
{
if (d == null)
// ArgumentException is thrown if the key is null or if the key is already
// present in the hashtable.
//
- public virtual void Add(object key, object value)
+ public virtual void Add(object key, object? value)
{
Insert(key, value, true);
}
while (bucket > 0)
{
bucket--;
- object keyv = lbuckets[bucket].key;
+ object? keyv = lbuckets[bucket].key;
if ((keyv != null) && (keyv != lbuckets))
{
ht[keyv] = lbuckets[bucket].val;
// search and is thus be substantially slower than the ContainsKey
// method.
//
- public virtual bool ContainsValue(object value)
+ public virtual bool ContainsValue(object? value)
{
if (value == null)
{
{
for (int i = _buckets.Length; --i >= 0;)
{
- object val = _buckets[i].val;
+ object? val = _buckets[i].val;
if (val != null && val.Equals(value))
return true;
}
bucket[] lbuckets = _buckets;
for (int i = lbuckets.Length; --i >= 0;)
{
- object keyv = lbuckets[i].key;
+ object? keyv = lbuckets[i].key;
if ((keyv != null) && (keyv != _buckets))
{
array.SetValue(keyv, arrayIndex++);
bucket[] lbuckets = _buckets;
for (int i = lbuckets.Length; --i >= 0;)
{
- object keyv = lbuckets[i].key;
+ object? keyv = lbuckets[i].key;
if ((keyv != null) && (keyv != _buckets))
{
DictionaryEntry entry = new DictionaryEntry(keyv, lbuckets[i].val);
bucket[] lbuckets = _buckets;
for (int i = lbuckets.Length; --i >= 0;)
{
- object keyv = lbuckets[i].key;
+ object? keyv = lbuckets[i].key;
if ((keyv != null) && (keyv != _buckets))
{
array[index++] = new KeyValuePairs(keyv, lbuckets[i].val);
bucket[] lbuckets = _buckets;
for (int i = lbuckets.Length; --i >= 0;)
{
- object keyv = lbuckets[i].key;
+ object? keyv = lbuckets[i].key;
if ((keyv != null) && (keyv != _buckets))
{
array.SetValue(lbuckets[i].val, arrayIndex++);
// Returns the value associated with the given key. If an entry with the
// given key is not found, the returned value is null.
//
- public virtual object this[object key]
+ public virtual object? this[object key]
{
get
{
// instance in the constructor, this method will call comparer.Compare(item, key).
// Otherwise, it will call item.Equals(key).
//
- protected virtual bool KeyEquals(object item, object key)
+ protected virtual bool KeyEquals(object? item, object key)
{
Debug.Assert(key != null, "key can't be null here!");
if (object.ReferenceEquals(_buckets, item))
// Inserts an entry into this hashtable. This method is called from the Set
// and Add methods. If the add parameter is true and the given key already
// exists in the hashtable, an exception is thrown.
- private void Insert(object key, object nvalue, bool add)
+ private void Insert(object key, object? nvalue, bool add)
{
if (key == null)
{
throw new InvalidOperationException(SR.InvalidOperation_HashInsertFailed);
}
- private void putEntry(bucket[] newBuckets, object key, object nvalue, int hashcode)
+ private void putEntry(bucket[] newBuckets, object key, object? nvalue, int hashcode)
{
Debug.Assert(hashcode >= 0, "hashcode >= 0"); // make sure collision bit (sign bit) wasn't set.
// Also, if the Hashtable is using randomized hashing, serialize the old
// view of the _keycomparer so perevious frameworks don't see the new types
#pragma warning disable 618
- IEqualityComparer keyComparerForSerilization = _keycomparer;
+ IEqualityComparer? keyComparerForSerilization = _keycomparer;
if (keyComparerForSerilization == null)
{
}
else if (keyComparerForSerilization is CompatibleComparer)
{
- CompatibleComparer c = keyComparerForSerilization as CompatibleComparer;
+ CompatibleComparer c = (keyComparerForSerilization as CompatibleComparer)!;
info.AddValue(ComparerName, c.Comparer, typeof(IComparer));
info.AddValue(HashCodeProviderName, c.HashCodeProvider, typeof(IHashCodeProvider));
}
}
int hashsize = 0;
- IComparer c = null;
+ IComparer? c = null;
#pragma warning disable 618
- IHashCodeProvider hcp = null;
+ IHashCodeProvider? hcp = null;
#pragma warning restore 618
- object[] serKeys = null;
- object[] serValues = null;
+ object[]? serKeys = null;
+ object?[]? serValues = null;
SerializationInfoEnumerator enumerator = siInfo.GetEnumerator();
hashsize = siInfo.GetInt32(HashSizeName);
break;
case KeyComparerName:
- _keycomparer = (IEqualityComparer)siInfo.GetValue(KeyComparerName, typeof(IEqualityComparer));
+ _keycomparer = (IEqualityComparer?)siInfo.GetValue(KeyComparerName, typeof(IEqualityComparer));
break;
case ComparerName:
- c = (IComparer)siInfo.GetValue(ComparerName, typeof(IComparer));
+ c = (IComparer?)siInfo.GetValue(ComparerName, typeof(IComparer));
break;
case HashCodeProviderName:
#pragma warning disable 618
- hcp = (IHashCodeProvider)siInfo.GetValue(HashCodeProviderName, typeof(IHashCodeProvider));
+ hcp = (IHashCodeProvider?)siInfo.GetValue(HashCodeProviderName, typeof(IHashCodeProvider));
#pragma warning restore 618
break;
case KeysName:
- serKeys = (object[])siInfo.GetValue(KeysName, typeof(object[]));
+ serKeys = (object[]?)siInfo.GetValue(KeysName, typeof(object[]));
break;
case ValuesName:
- serValues = (object[])siInfo.GetValue(ValuesName, typeof(object[]));
+ serValues = (object?[]?)siInfo.GetValue(ValuesName, typeof(object[]));
break;
}
}
get { return true; }
}
- public override object this[object key]
+ public override object? this[object key]
{
get
{
get { return _table.SyncRoot; }
}
- public override void Add(object key, object value)
+ public override void Add(object key, object? value)
{
lock (_table.SyncRoot)
{
return _table.ContainsKey(key);
}
- public override bool ContainsValue(object key)
+ public override bool ContainsValue(object? key)
{
lock (_table.SyncRoot)
{
private int _version;
private bool _current;
private int _getObjectRetType; // What should GetObject return?
- private object _currentKey;
- private object _currentValue;
+ private object? _currentKey;
+ private object? _currentValue;
internal const int Keys = 1;
internal const int Values = 2;
{
if (_current == false)
throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
- return _currentKey;
+ return _currentKey!;
}
}
while (_bucket > 0)
{
_bucket--;
- object keyv = _hashtable._buckets[_bucket].key;
+ object? keyv = _hashtable._buckets[_bucket].key;
if ((keyv != null) && (keyv != _hashtable._buckets))
{
_currentKey = keyv;
{
if (_current == false)
throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
- return new DictionaryEntry(_currentKey, _currentValue);
+ return new DictionaryEntry(_currentKey!, _currentValue);
}
}
- public virtual object Current
+ public virtual object? Current
{
get
{
else if (_getObjectRetType == Values)
return _currentValue;
else
- return new DictionaryEntry(_currentKey, _currentValue);
+ return new DictionaryEntry(_currentKey!, _currentValue);
}
}
- public virtual object Value
+ public virtual object? Value
{
get
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System;
namespace System.Collections
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
namespace System.Collections
{
/// <summary>
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System;
namespace System.Collections
public interface IList : ICollection
{
// The Item property provides methods to read and edit entries in the List.
- object this[int index]
+ object? this[int index]
{
get;
set;
// implementation-dependent, so while ArrayList may always insert
// in the last available location, a SortedList most likely would not.
// The return value is the position the new element was inserted in.
- int Add(object value);
+ int Add(object? value);
// Returns whether the list contains a particular item.
- bool Contains(object value);
+ bool Contains(object? value);
// Removes all items from the list.
void Clear();
// Returns the index of a particular item, if it is in the list.
// Returns -1 if the item isn't in the list.
- int IndexOf(object value);
+ int IndexOf(object? value);
// Inserts value into the list at position index.
// index must be non-negative and less than or equal to the
// number of elements in the list. If index equals the number
// of items in the list, then value is appended to the end.
- void Insert(int index, object value);
+ void Insert(int index, object? value);
// Removes an item from the list.
- void Remove(object value);
+ void Remove(object? value);
// Removes the item at position index.
void RemoveAt(int index);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System;
namespace System.Collections
{
public interface IStructuralComparable
{
- int CompareTo(object other, IComparer comparer);
+ int CompareTo(object? other, IComparer comparer);
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
/*============================================================
**
** Class: KeyValuePairs
private readonly object _key;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- private readonly object _value;
+ private readonly object? _value;
- public KeyValuePairs(object key, object value)
+ public KeyValuePairs(object key, object? value)
{
_value = value;
_key = key;
**
===========================================================*/
-
+#nullable enable
namespace System.Collections
{
/// This is a simple implementation of IDictionary using a singly linked list. This
// Needs to be public to support binary serialization compatibility
public class ListDictionaryInternal : IDictionary
{
- private DictionaryNode head; // Do not rename (binary serialization)
+ private DictionaryNode? head; // Do not rename (binary serialization)
private int version; // Do not rename (binary serialization)
private int count; // Do not rename (binary serialization)
{
}
- public object this[object key]
+ public object? this[object key]
{
get
{
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- DictionaryNode node = head;
+ DictionaryNode? node = head;
while (node != null)
{
version++;
- DictionaryNode last = null;
- DictionaryNode node;
+ DictionaryNode? last = null;
+ DictionaryNode? node;
for (node = head; node != null; node = node.next)
{
if (node.key.Equals(key))
}
}
- public void Add(object key, object value)
+ public void Add(object key, object? value)
{
if (key == null)
{
version++;
- DictionaryNode last = null;
- DictionaryNode node;
+ DictionaryNode? last = null;
+ DictionaryNode? node;
for (node = head; node != null; node = node.next)
{
if (node.key.Equals(key))
{
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
- for (DictionaryNode node = head; node != null; node = node.next)
+ for (DictionaryNode? node = head; node != null; node = node.next)
{
if (node.key.Equals(key))
{
if (array.Length - index < this.Count)
throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index));
- for (DictionaryNode node = head; node != null; node = node.next)
+ for (DictionaryNode? node = head; node != null; node = node.next)
{
array.SetValue(new DictionaryEntry(node.key, node.value), index);
index++;
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
}
version++;
- DictionaryNode last = null;
- DictionaryNode node;
+ DictionaryNode? last = null;
+ DictionaryNode? node;
for (node = head; node != null; node = node.next)
{
if (node.key.Equals(key))
}
else
{
- last.next = node.next;
+ last!.next = node.next;
}
count--;
}
private class NodeEnumerator : IDictionaryEnumerator
{
private ListDictionaryInternal list;
- private DictionaryNode current;
+ private DictionaryNode? current;
private int version;
private bool start;
current = null;
}
+#pragma warning disable CS8612 // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/30958
public object Current
+#pragma warning restore CS8612
{
get
{
}
}
- public object Value
+ public object? Value
{
get
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Length - index < list.Count)
throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index));
- for (DictionaryNode node = list.head; node != null; node = node.next)
+ for (DictionaryNode? node = list.head; node != null; node = node.next)
{
array.SetValue(isKeys ? node.key : node.value, index);
index++;
get
{
int count = 0;
- for (DictionaryNode node = list.head; node != null; node = node.next)
+ for (DictionaryNode? node = list.head; node != null; node = node.next)
{
count++;
}
private class NodeKeyValueEnumerator : IEnumerator
{
private ListDictionaryInternal list;
- private DictionaryNode current;
+ private DictionaryNode? current;
private int version;
private bool isKeys;
private bool start;
current = null;
}
- public object Current
+ public object? Current
{
get
{
[Serializable]
private class DictionaryNode
{
- public object key;
- public object value;
- public DictionaryNode next;
+ public object key = null!;
+ public object? value;
+ public DictionaryNode? next;
}
}
}
}
}
- int IList.Add(object value)
+ int IList.Add(object? value)
{
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
return -1;
return -1;
}
- void IList.Insert(int index, object value)
+ void IList.Insert(int index, object? value)
{
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
- void IList.Remove(object value)
+ void IList.Remove(object? value)
{
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
}
}
- return (DaylightTime)m_CachedDaylightChanges[objYear];
+ return (DaylightTime)m_CachedDaylightChanges[objYear]!;
}
// The per-year information is cached in this instance value. As a result it can
for (int i = 0; i < iMax; i += 2)
{
- hashtable.Add(_attributes[i], _attributes[i + 1]);
+ hashtable.Add(_attributes[i]!, _attributes[i + 1]);
}
return hashtable;
for (int i = 0; i < iMax; i += 2)
{
- string strAttrName = (string)_attributes[i];
+ string? strAttrName = (string?)_attributes[i];
if (string.Equals(strAttrName, name))
throw new ArgumentException(SR.Argument_AttributeNamesMustBeUnique);
for (int i = 0; i < iMax; i++)
{
- string lhs = (string)_attributes[i];
- string rhs = (string)other._attributes[i];
+ string? lhs = (string?)_attributes[i];
+ string? rhs = (string?)other._attributes[i];
if (!string.Equals(lhs, rhs))
return false;
for (int i = 0; i < iMax; i += 2)
{
- string strAttrName = (string)_attributes[i];
- string strAttrValue = (string)_attributes[i + 1];
+ string? strAttrName = (string?)_attributes[i];
+ string? strAttrValue = (string?)_attributes[i + 1];
write(obj, strAttrName);
write(obj, "=\"");
for (int i = 0; i < _children.Count; ++i)
{
- ((SecurityElement)_children[i]).ToString(string.Empty, obj, write);
+ ((SecurityElement)_children[i]!).ToString(string.Empty, obj, write);
}
}
for (int i = 0; i < iMax; i += 2)
{
- string strAttrName = (string)_attributes[i];
+ string? strAttrName = (string?)_attributes[i];
if (string.Equals(strAttrName, name))
{
- string strAttrValue = (string)_attributes[i + 1];
+ string? strAttrValue = (string?)_attributes[i + 1];
return Unescape(strAttrValue);
}
if (name == null)
throw new ArgumentNullException(nameof(name));
- object codePageObj;
+ object? codePageObj;
codePageObj = s_nameToCodePage[name];
if (codePageObj != null)
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return 0;
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T1>.Default.Compare(Item1, other.Item1);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T2>.Default.Compare(Item2, other.Item2);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T3>.Default.Compare(Item3, other.Item3);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T4>.Default.Compare(Item4, other.Item4);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T5>.Default.Compare(Item5, other.Item5);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T6>.Default.Compare(Item6, other.Item6);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<T7>.Default.Compare(Item7, other.Item7);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;
return Comparer<TRest>.Default.Compare(Rest, other.Rest);
}
- int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
if (other == null) return 1;