public static int CreateMask(int previous) { throw null; }
public static System.Collections.Specialized.BitVector32.Section CreateSection(short maxValue) { throw null; }
public static System.Collections.Specialized.BitVector32.Section CreateSection(short maxValue, System.Collections.Specialized.BitVector32.Section previous) { throw null; }
- public override bool Equals(object o) { throw null; }
+ public override bool Equals(object? o) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
public static string ToString(System.Collections.Specialized.BitVector32 value) { throw null; }
public short Mask { get { throw null; } }
public short Offset { get { throw null; } }
public bool Equals(System.Collections.Specialized.BitVector32.Section obj) { throw null; }
- public override bool Equals(object o) { throw null; }
+ public override bool Equals(object? o) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Collections.Specialized.BitVector32.Section a, System.Collections.Specialized.BitVector32.Section b) { throw null; }
public static bool operator !=(System.Collections.Specialized.BitVector32.Section a, System.Collections.Specialized.BitVector32.Section b) { throw null; }
public bool IsFixedSize { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public bool IsSynchronized { get { throw null; } }
- public object this[object key] { get { throw null; } set { } }
+ public object? this[object key] { get { throw null; } set { } }
public System.Collections.ICollection Keys { get { throw null; } }
public object SyncRoot { get { throw null; } }
public System.Collections.ICollection Values { get { throw null; } }
- public void Add(object key, object value) { }
+ public void Add(object key, object? value) { }
public void Clear() { }
public bool Contains(object key) { throw null; }
public void CopyTo(System.Array array, int index) { }
}
public partial interface IOrderedDictionary : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable
{
- object this[int index] { get; set; }
+ object? this[int index] { get; set; }
new System.Collections.IDictionaryEnumerator GetEnumerator();
- void Insert(int index, object key, object value);
+ void Insert(int index, object key, object? value);
void RemoveAt(int index);
}
public partial class ListDictionary : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable
{
public ListDictionary() { }
- public ListDictionary(System.Collections.IComparer comparer) { }
+ public ListDictionary(System.Collections.IComparer? comparer) { }
public int Count { get { throw null; } }
public bool IsFixedSize { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public bool IsSynchronized { get { throw null; } }
- public object this[object key] { get { throw null; } set { } }
+ public object? this[object key] { get { throw null; } set { } }
public System.Collections.ICollection Keys { get { throw null; } }
public object SyncRoot { get { throw null; } }
public System.Collections.ICollection Values { get { throw null; } }
- public void Add(object key, object value) { }
+ public void Add(object key, object? value) { }
public void Clear() { }
public bool Contains(object key) { throw null; }
public void CopyTo(System.Array array, int index) { }
public abstract partial class NameObjectCollectionBase : System.Collections.ICollection, System.Collections.IEnumerable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
{
protected NameObjectCollectionBase() { }
- protected NameObjectCollectionBase(System.Collections.IEqualityComparer equalityComparer) { }
+ protected NameObjectCollectionBase(System.Collections.IEqualityComparer? equalityComparer) { }
[System.ObsoleteAttribute("Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
- protected NameObjectCollectionBase(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer) { }
+ protected NameObjectCollectionBase(System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { }
protected NameObjectCollectionBase(int capacity) { }
- protected NameObjectCollectionBase(int capacity, System.Collections.IEqualityComparer equalityComparer) { }
+ protected NameObjectCollectionBase(int capacity, System.Collections.IEqualityComparer? equalityComparer) { }
[System.ObsoleteAttribute("Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
- protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer) { }
+ protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { }
protected NameObjectCollectionBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public virtual int Count { get { throw null; } }
protected bool IsReadOnly { get { throw null; } set { } }
public virtual System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
- protected void BaseAdd(string name, object value) { }
+ protected void BaseAdd(string? name, object? value) { }
protected void BaseClear() { }
- protected object BaseGet(int index) { throw null; }
- protected object BaseGet(string name) { throw null; }
- protected string[] BaseGetAllKeys() { throw null; }
- protected object[] BaseGetAllValues() { throw null; }
- protected object[] BaseGetAllValues(System.Type type) { throw null; }
- protected string BaseGetKey(int index) { throw null; }
+ protected object? BaseGet(int index) { throw null; }
+ protected object? BaseGet(string? name) { throw null; }
+ protected string?[] BaseGetAllKeys() { throw null; }
+ protected object?[] BaseGetAllValues() { throw null; }
+ protected object?[] BaseGetAllValues(System.Type type) { throw null; }
+ protected string? BaseGetKey(int index) { throw null; }
protected bool BaseHasKeys() { throw null; }
- protected void BaseRemove(string name) { }
+ protected void BaseRemove(string? name) { }
protected void BaseRemoveAt(int index) { }
- protected void BaseSet(int index, object value) { }
- protected void BaseSet(string name, object value) { }
+ protected void BaseSet(int index, object? value) { }
+ protected void BaseSet(string? name, object? value) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- public virtual void OnDeserialization(object sender) { }
+ public virtual void OnDeserialization(object? sender) { }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
public partial class KeysCollection : System.Collections.ICollection, System.Collections.IEnumerable
{
internal KeysCollection() { }
public int Count { get { throw null; } }
- public string this[int index] { get { throw null; } }
+ public string? this[int index] { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
- public virtual string Get(int index) { throw null; }
+ public virtual string? Get(int index) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
}
public partial class NameValueCollection : System.Collections.Specialized.NameObjectCollectionBase
{
public NameValueCollection() { }
- public NameValueCollection(System.Collections.IEqualityComparer equalityComparer) { }
+ public NameValueCollection(System.Collections.IEqualityComparer? equalityComparer) { }
[System.ObsoleteAttribute("Please use NameValueCollection(IEqualityComparer) instead.")]
- public NameValueCollection(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer) { }
+ public NameValueCollection(System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { }
public NameValueCollection(System.Collections.Specialized.NameValueCollection col) { }
public NameValueCollection(int capacity) { }
- public NameValueCollection(int capacity, System.Collections.IEqualityComparer equalityComparer) { }
+ public NameValueCollection(int capacity, System.Collections.IEqualityComparer? equalityComparer) { }
[System.ObsoleteAttribute("Please use NameValueCollection(Int32, IEqualityComparer) instead.")]
- public NameValueCollection(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer) { }
+ public NameValueCollection(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { }
public NameValueCollection(int capacity, System.Collections.Specialized.NameValueCollection col) { }
protected NameValueCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- public virtual string[] AllKeys { get { throw null; } }
- public string this[int index] { get { throw null; } }
- public string this[string name] { get { throw null; } set { } }
+ public virtual string?[] AllKeys { get { throw null; } }
+ public string? this[int index] { get { throw null; } }
+ public string? this[string? name] { get { throw null; } set { } }
public void Add(System.Collections.Specialized.NameValueCollection c) { }
- public virtual void Add(string name, string value) { }
+ public virtual void Add(string? name, string? value) { }
public virtual void Clear() { }
public void CopyTo(System.Array dest, int index) { }
- public virtual string Get(int index) { throw null; }
- public virtual string Get(string name) { throw null; }
- public virtual string GetKey(int index) { throw null; }
- public virtual string[] GetValues(int index) { throw null; }
- public virtual string[] GetValues(string name) { throw null; }
+ public virtual string? Get(int index) { throw null; }
+ public virtual string? Get(string? name) { throw null; }
+ public virtual string? GetKey(int index) { throw null; }
+ public virtual string[]? GetValues(int index) { throw null; }
+ public virtual string[]? GetValues(string? name) { throw null; }
public bool HasKeys() { throw null; }
protected void InvalidateCachedArrays() { }
- public virtual void Remove(string name) { }
- public virtual void Set(string name, string value) { }
+ public virtual void Remove(string? name) { }
+ public virtual void Set(string? name, string? value) { }
}
public partial class OrderedDictionary : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.Collections.Specialized.IOrderedDictionary, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
{
public OrderedDictionary() { }
- public OrderedDictionary(System.Collections.IEqualityComparer comparer) { }
+ public OrderedDictionary(System.Collections.IEqualityComparer? comparer) { }
public OrderedDictionary(int capacity) { }
- public OrderedDictionary(int capacity, System.Collections.IEqualityComparer comparer) { }
+ public OrderedDictionary(int capacity, System.Collections.IEqualityComparer? comparer) { }
protected OrderedDictionary(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public int Count { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
- public object this[int index] { get { throw null; } set { } }
- public object this[object key] { get { throw null; } set { } }
+ public object? this[int index] { get { throw null; } set { } }
+ public object? this[object key] { get { throw null; } set { } }
public System.Collections.ICollection Keys { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IDictionary.IsFixedSize { get { throw null; } }
public System.Collections.ICollection Values { get { throw null; } }
- public void Add(object key, object value) { }
+ public void Add(object key, object? value) { }
public System.Collections.Specialized.OrderedDictionary AsReadOnly() { throw null; }
public void Clear() { }
public bool Contains(object key) { throw null; }
public void CopyTo(System.Array array, int index) { }
public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- public void Insert(int index, object key, object value) { }
- protected virtual void OnDeserialization(object sender) { }
+ public void Insert(int index, object key, object? value) { }
+ protected virtual void OnDeserialization(object? sender) { }
public void Remove(object key) { }
public void RemoveAt(int index) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public int Count { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public bool IsSynchronized { get { throw null; } }
- public string this[int index] { get { throw null; } set { } }
+ public string? this[int index] { get { throw null; } set { } }
public object SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
- object System.Collections.IList.this[int index] { get { throw null; } set { } }
- public int Add(string value) { throw null; }
+ object? System.Collections.IList.this[int index] { get { throw null; } set { } }
+ public int Add(string? value) { throw null; }
public void AddRange(string[] value) { }
public void Clear() { }
- public bool Contains(string value) { throw null; }
+ public bool Contains(string? value) { throw null; }
public void CopyTo(string[] array, int index) { }
public System.Collections.Specialized.StringEnumerator GetEnumerator() { throw null; }
- public int IndexOf(string value) { throw null; }
- public void Insert(int index, string value) { }
- public void Remove(string value) { }
+ public int IndexOf(string? value) { throw null; }
+ public void Insert(int index, string? value) { }
+ public void Remove(string? value) { }
public void RemoveAt(int index) { }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
- int System.Collections.IList.Add(object value) { throw null; }
- bool System.Collections.IList.Contains(object value) { throw null; }
- int System.Collections.IList.IndexOf(object value) { throw null; }
- void System.Collections.IList.Insert(int index, object value) { }
- void System.Collections.IList.Remove(object value) { }
+ int System.Collections.IList.Add(object? value) { throw null; }
+ bool System.Collections.IList.Contains(object? value) { throw null; }
+ int System.Collections.IList.IndexOf(object? value) { throw null; }
+ void System.Collections.IList.Insert(int index, object? value) { }
+ void System.Collections.IList.Remove(object? value) { }
}
public partial class StringDictionary : System.Collections.IEnumerable
{
public StringDictionary() { }
public virtual int Count { get { throw null; } }
public virtual bool IsSynchronized { get { throw null; } }
- public virtual string this[string key] { get { throw null; } set { } }
+ public virtual string? this[string key] { get { throw null; } set { } }
public virtual System.Collections.ICollection Keys { get { throw null; } }
public virtual object SyncRoot { get { throw null; } }
public virtual System.Collections.ICollection Values { get { throw null; } }
- public virtual void Add(string key, string value) { }
+ public virtual void Add(string key, string? value) { }
public virtual void Clear() { }
public virtual bool ContainsKey(string key) { throw null; }
- public virtual bool ContainsValue(string value) { throw null; }
+ public virtual bool ContainsValue(string? value) { throw null; }
public virtual void CopyTo(System.Array array, int index) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
public virtual void Remove(string key) { }
public partial class StringEnumerator
{
internal StringEnumerator() { }
- public string Current { get { throw null; } }
+ public string? Current { get { throw null; } }
public bool MoveNext() { throw null; }
public void Reset() { }
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Collections.Specialized.cs" />
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>System.Collections.Specialized</RootNamespace>
<AssemblyName>System.Collections.Specialized</AssemblyName>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Collections\Specialized\BitVector32.cs" />
return new Section(CreateMaskFromHighValue(maxValue), offset);
}
- public override bool Equals(object o)
+ public override bool Equals(object? o)
{
if (!(o is BitVector32))
{
}
}
- public override bool Equals(object o)
+ public override bool Equals(object? o)
{
if (o is Section)
return Equals((Section)o);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace System.Collections.Specialized
{
/// <devdoc>
private const int FixedSizeCutoverPoint = 6;
// Instance variables. This keeps the HybridDictionary very light-weight when empty
- private ListDictionary list; // Do not rename (binary serialization)
- private Hashtable hashtable; // Do not rename (binary serialization)
+ private ListDictionary? list; // Do not rename (binary serialization)
+ private Hashtable? hashtable; // Do not rename (binary serialization)
private readonly bool caseInsensitive; // Do not rename (binary serialization)
public HybridDictionary()
}
}
- public object this[object key]
+ public object? this[object key]
{
get
{
// Although we never made the same guarantee for HybridDictionary,
// it is still nice to do the same thing here since we have recommended
// HybridDictionary as replacement for Hashtable.
- ListDictionary cachedList = list;
+ ListDictionary? cachedList = list;
if (hashtable != null)
{
return hashtable[key];
if (list.Count >= CutoverPoint - 1)
{
ChangeOver();
+ Debug.Assert(hashtable != null);
hashtable[key] = value;
}
else
private void ChangeOver()
{
+ Debug.Assert(list != null);
IDictionaryEnumerator en = list.GetEnumerator();
Hashtable newTable;
if (caseInsensitive)
{
get
{
- ListDictionary cachedList = list;
+ ListDictionary? cachedList = list;
if (hashtable != null)
{
return hashtable.Count;
}
}
- public void Add(object key, object value)
+ public void Add(object key, object? value)
{
if (hashtable != null)
{
else if (list.Count + 1 >= CutoverPoint)
{
ChangeOver();
+ Debug.Assert(hashtable != null);
hashtable.Add(key, value);
}
else
public bool Contains(object key)
{
- ListDictionary cachedList = list;
+ ListDictionary? cachedList = list;
if (hashtable != null)
{
return hashtable.Contains(key);
/// <devdoc>
/// Returns the object at the given index
/// </devdoc>
- object this[int index] { get; set; }
+ object? this[int index] { get; set; }
// Returns an IDictionaryEnumerator for this dictionary.
new IDictionaryEnumerator GetEnumerator();
/// <devdoc>
/// Inserts the given object, with the given key, at the given index
/// </devdoc>
- void Insert(int index, object key, object value);
+ void Insert(int index, object key, object? value);
/// <devdoc>
/// Removes the object and key at the given index
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace System.Collections.Specialized
{
/// <devdoc>
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class ListDictionary : 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)
- private readonly IComparer comparer; // Do not rename (binary serialization)
+ private readonly IComparer? comparer; // Do not rename (binary serialization)
public ListDictionary()
{
}
- public ListDictionary(IComparer comparer)
+ public ListDictionary(IComparer? comparer)
{
this.comparer = comparer;
}
- public object this[object key]
+ public object? this[object key]
{
get
{
{
throw new ArgumentNullException(nameof(key));
}
- DictionaryNode node = head;
+ DictionaryNode? node = head;
if (comparer == null)
{
while (node != null)
throw new ArgumentNullException(nameof(key));
}
version++;
- DictionaryNode last = null;
- DictionaryNode node;
+ DictionaryNode? last = null;
+ DictionaryNode? node;
for (node = head; node != null; node = node.next)
{
object oldKey = node.key;
}
}
- public void Add(object key, object value)
+ public void Add(object key, object? value)
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
version++;
- DictionaryNode last = null;
- DictionaryNode node;
- for (node = head; node != null; node = node.next)
+ DictionaryNode? last = null;
+
+ for (DictionaryNode? node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
{
throw new ArgumentNullException(nameof(key));
}
- for (DictionaryNode node = head; node != null; node = node.next)
+ for (DictionaryNode? node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
if (array.Length - index < count)
throw new ArgumentException(SR.Arg_InsufficientSpace);
- 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));
}
version++;
- DictionaryNode last = null;
- DictionaryNode node;
+ DictionaryNode? last = null;
+ DictionaryNode? node;
for (node = head; node != null; node = node.next)
{
object oldKey = node.key;
}
else
{
+ Debug.Assert(last != null);
last.next = node.next;
}
count--;
private class NodeEnumerator : IDictionaryEnumerator
{
private readonly ListDictionary _list;
- private DictionaryNode _current;
+ private DictionaryNode? _current;
private readonly int _version;
private bool _start;
}
}
- public object Value
+ public object? Value
{
get
{
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum_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 readonly ListDictionary _list;
- private DictionaryNode _current;
+ private DictionaryNode? _current;
private readonly int _version;
private readonly bool _isKeys;
private bool _start;
_current = null;
}
- public object Current
+ public object? Current
{
get
{
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class DictionaryNode
{
- public object key; // Do not rename (binary serialization)
- public object value; // Do not rename (binary serialization)
- public DictionaryNode next; // Do not rename (binary serialization)
+ public object key = null!; // Do not rename (binary serialization)
+ public object? value; // Do not rename (binary serialization)
+ public DictionaryNode? next; // Do not rename (binary serialization)
}
}
}
public abstract class NameObjectCollectionBase : ICollection, ISerializable, IDeserializationCallback
{
private bool _readOnly = false;
- private ArrayList _entriesArray;
+ private ArrayList _entriesArray = null!; // initialized in Reset method, called from constructor
private IEqualityComparer _keyComparer;
- private volatile Hashtable _entriesTable;
- private volatile NameObjectEntry _nullKeyEntry;
- private KeysCollection _keys;
+ private volatile Hashtable _entriesTable = null!; // initialized in Reset method, called from constructor
+ private volatile NameObjectEntry? _nullKeyEntry;
+ private KeysCollection? _keys;
private int _version;
private static readonly StringComparer s_defaultComparer = CultureInfo.InvariantCulture.CompareInfo.GetStringComparer(CompareOptions.IgnoreCase);
{
}
- protected NameObjectCollectionBase(IEqualityComparer equalityComparer)
+ protected NameObjectCollectionBase(IEqualityComparer? equalityComparer)
{
_keyComparer = (equalityComparer == null) ? s_defaultComparer : equalityComparer;
Reset();
}
- protected NameObjectCollectionBase(int capacity, IEqualityComparer equalityComparer) : this(equalityComparer)
+ protected NameObjectCollectionBase(int capacity, IEqualityComparer? equalityComparer) : this(equalityComparer)
{
Reset(capacity);
}
[Obsolete("Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
- protected NameObjectCollectionBase(IHashCodeProvider hashProvider, IComparer comparer)
+ protected NameObjectCollectionBase(IHashCodeProvider? hashProvider, IComparer? comparer)
{
_keyComparer = new CompatibleComparer(hashProvider, comparer);
Reset();
}
[Obsolete("Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
- protected NameObjectCollectionBase(int capacity, IHashCodeProvider hashProvider, IComparer comparer)
+ protected NameObjectCollectionBase(int capacity, IHashCodeProvider? hashProvider, IComparer? comparer)
{
_keyComparer = new CompatibleComparer(hashProvider, comparer);
Reset(capacity);
throw new PlatformNotSupportedException();
}
- public virtual void OnDeserialization(object sender)
+ public virtual void OnDeserialization(object? sender)
{
throw new PlatformNotSupportedException();
}
_version++;
}
- private NameObjectEntry FindEntry(string key)
+ private NameObjectEntry? FindEntry(string? key)
{
if (key != null)
- return (NameObjectEntry)_entriesTable[key];
+ return (NameObjectEntry?)_entriesTable[key];
else
return _nullKeyEntry;
}
/// <para>Adds an entry with the specified key and value into the
/// <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected void BaseAdd(string name, object value)
+ protected void BaseAdd(string? name, object? value)
{
if (_readOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
/// <para>Removes the entries with the specified key from the
/// <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected void BaseRemove(string name)
+ protected void BaseRemove(string? name)
{
if (_readOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
if (_readOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
- string key = BaseGetKey(index);
+ string? key = BaseGetKey(index);
if (key != null)
{
/// <para>Gets the value of the first entry with the specified key from
/// the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected object BaseGet(string name)
+ protected object? BaseGet(string? name)
{
- NameObjectEntry e = FindEntry(name);
+ NameObjectEntry? e = FindEntry(name);
return (e != null) ? e.Value : null;
}
/// into the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/>
/// instance.</para>
/// </devdoc>
- protected void BaseSet(string name, object value)
+ protected void BaseSet(string? name, object? value)
{
if (_readOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
- NameObjectEntry entry = FindEntry(name);
+ NameObjectEntry? entry = FindEntry(name);
if (entry != null)
{
entry.Value = value;
/// <para>Gets the value of the entry at the specified index of
/// the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected object BaseGet(int index)
+ protected object? BaseGet(int index)
{
- NameObjectEntry entry = (NameObjectEntry)_entriesArray[index];
+ NameObjectEntry entry = (NameObjectEntry)_entriesArray[index]!; // no null entry added to the array
return entry.Value;
}
/// <see cref='System.Collections.Specialized.NameObjectCollectionBase'/>
/// instance.</para>
/// </devdoc>
- protected string BaseGetKey(int index)
+ protected string? BaseGetKey(int index)
{
- NameObjectEntry entry = (NameObjectEntry)_entriesArray[index];
+ NameObjectEntry entry = (NameObjectEntry)_entriesArray[index]!;
return entry.Key;
}
/// <para>Sets the value of the entry at the specified index of
/// the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected void BaseSet(int index, object value)
+ protected void BaseSet(int index, object? value)
{
if (_readOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
- NameObjectEntry entry = (NameObjectEntry)_entriesArray[index];
+ NameObjectEntry entry = (NameObjectEntry)_entriesArray[index]!;
entry.Value = value;
_version++;
}
/// <para>Returns a <see cref='string' qualify='true'/> array containing all the keys in the
/// <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected string[] BaseGetAllKeys()
+ protected string?[] BaseGetAllKeys()
{
int n = _entriesArray.Count;
- string[] allKeys = new string[n];
+ string?[] allKeys = new string[n];
for (int i = 0; i < n; i++)
allKeys[i] = BaseGetKey(i);
/// <para>Returns an <see cref='object' qualify='true'/> array containing all the values in the
/// <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected object[] BaseGetAllValues()
+ protected object?[] BaseGetAllValues()
{
int n = _entriesArray.Count;
- object[] allValues = new object[n];
+ object?[] allValues = new object[n];
for (int i = 0; i < n; i++)
allValues[i] = BaseGet(i);
/// <para>Returns an array of the specified type containing
/// all the values in the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- protected object[] BaseGetAllValues(Type type)
+ protected object?[] BaseGetAllValues(Type type)
{
int n = _entriesArray.Count;
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
- object[] allValues = (object[])Array.CreateInstance(type, n);
+ object?[] allValues = (object?[])Array.CreateInstance(type, n);
for (int i = 0; i < n; i++)
{
internal class NameObjectEntry
{
- internal NameObjectEntry(string name, object value)
+ internal NameObjectEntry(string? name, object? value)
{
Key = name;
Value = value;
}
- internal string Key;
- internal object Value;
+ internal string? Key;
+ internal object? Value;
}
//
_pos = -1;
}
- public object Current
+ public object? Current
{
get
{
/// <devdoc>
/// <para> Gets the key at the specified index of the collection.</para>
/// </devdoc>
- public virtual string Get(int index)
+ public virtual string? Get(int index)
{
return _coll.BaseGetKey(index);
}
/// <devdoc>
/// <para>Represents the entry at the specified index of the collection.</para>
/// </devdoc>
- public string this[int index]
+ public string? this[int index]
{
get
{
*
*/
+using System.Diagnostics;
using System.Runtime.Serialization;
using System.Text;
/// </devdoc>
public class NameValueCollection : NameObjectCollectionBase
{
- private string[] _all; // Do not rename (binary serialization)
- private string[] _allKeys; // Do not rename (binary serialization)
+ private string?[]? _all; // Do not rename (binary serialization)
+ private string?[]? _allKeys; // Do not rename (binary serialization)
//
// Constructors
public NameValueCollection(NameValueCollection col)
: base(col != null ? col.Comparer : null)
{
- Add(col);
+ Add(col!);
}
[Obsolete("Please use NameValueCollection(IEqualityComparer) instead.")]
- public NameValueCollection(IHashCodeProvider hashProvider, IComparer comparer)
+ public NameValueCollection(IHashCodeProvider? hashProvider, IComparer? comparer)
: base(hashProvider, comparer)
{
}
{
}
- public NameValueCollection(IEqualityComparer equalityComparer) : base(equalityComparer)
+ public NameValueCollection(IEqualityComparer? equalityComparer) : base(equalityComparer)
{
}
- public NameValueCollection(int capacity, IEqualityComparer equalityComparer)
+ public NameValueCollection(int capacity, IEqualityComparer? equalityComparer)
: base(capacity, equalityComparer)
{
}
}
[Obsolete("Please use NameValueCollection(Int32, IEqualityComparer) instead.")]
- public NameValueCollection(int capacity, IHashCodeProvider hashProvider, IComparer comparer)
+ public NameValueCollection(int capacity, IHashCodeProvider? hashProvider, IComparer? comparer)
: base(capacity, hashProvider, comparer)
{
}
_allKeys = null;
}
- private static string GetAsOneString(ArrayList list)
+ private static string? GetAsOneString(ArrayList? list)
{
int n = (list != null) ? list.Count : 0;
if (n == 1)
{
- return (string)list[0];
+ Debug.Assert(list != null);
+ return (string?)list[0];
}
else if (n > 1)
{
- StringBuilder s = new StringBuilder((string)list[0]);
+ Debug.Assert(list != null);
+ StringBuilder s = new StringBuilder((string?)list[0]);
for (int i = 1; i < n; i++)
{
s.Append(',');
- s.Append((string)list[i]);
+ s.Append((string?)list[i]);
}
return s.ToString();
}
}
- private static string[] GetAsStringArray(ArrayList list)
+ private static string[]? GetAsStringArray(ArrayList? list)
{
int n = (list != null) ? list.Count : 0;
if (n == 0)
return null;
string[] array = new string[n];
- list.CopyTo(0, array, 0, n);
+ list!.CopyTo(0, array, 0, n);
return array;
}
for (int i = 0; i < n; i++)
{
- string key = c.GetKey(i);
- string[] values = c.GetValues(i);
+ string? key = c.GetKey(i);
+ string[]? values = c.GetValues(i);
if (values != null)
{
int n = Count;
if (_all == null)
{
- string[] all = new string[n];
+ string?[] all = new string[n];
for (int i = 0; i < n; i++)
{
all[i] = Get(i);
/// <para>Adds an entry with the specified name and value into the
/// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public virtual void Add(string name, string value)
+ public virtual void Add(string? name, string? value)
{
if (IsReadOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
InvalidateCachedArrays();
- ArrayList values = (ArrayList)BaseGet(name);
+ ArrayList? values = (ArrayList?)BaseGet(name);
if (values == null)
{
/// <devdoc>
/// <para> Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one comma-separated list.</para>
/// </devdoc>
- public virtual string Get(string name)
+ public virtual string? Get(string? name)
{
- ArrayList values = (ArrayList)BaseGet(name);
+ ArrayList? values = (ArrayList?)BaseGet(name);
return GetAsOneString(values);
}
/// <devdoc>
/// <para>Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public virtual string[] GetValues(string name)
+ public virtual string[]? GetValues(string? name)
{
- ArrayList values = (ArrayList)BaseGet(name);
+ ArrayList? values = (ArrayList?)BaseGet(name);
return GetAsStringArray(values);
}
/// <devdoc>
/// <para>Adds a value to an entry in the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public virtual void Set(string name, string value)
+ public virtual void Set(string? name, string? value)
{
if (IsReadOnly)
throw new NotSupportedException(SR.CollectionReadOnly);
/// <devdoc>
/// <para>Removes the entries with the specified key from the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para>
/// </devdoc>
- public virtual void Remove(string name)
+ public virtual void Remove(string? name)
{
InvalidateCachedArrays();
BaseRemove(name);
/// <para> Represents the entry with the specified key in the
/// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public string this[string name]
+ public string? this[string? name]
{
get
{
/// Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one
/// comma-separated list.</para>
/// </devdoc>
- public virtual string Get(int index)
+ public virtual string? Get(int index)
{
- ArrayList values = (ArrayList)BaseGet(index);
+ ArrayList? values = (ArrayList?)BaseGet(index);
return GetAsOneString(values);
}
/// <devdoc>
/// <para> Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public virtual string[] GetValues(int index)
+ public virtual string[]? GetValues(int index)
{
- ArrayList values = (ArrayList)BaseGet(index);
+ ArrayList? values = (ArrayList?)BaseGet(index);
return GetAsStringArray(values);
}
/// <devdoc>
/// <para>Gets the key at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public virtual string GetKey(int index)
+ public virtual string? GetKey(int index)
{
return BaseGetKey(index);
}
/// <devdoc>
/// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
/// </devdoc>
- public string this[int index]
+ public string? this[int index]
{
get
{
/// <devdoc>
/// <para>Gets all the keys in the <see cref='System.Collections.Specialized.NameValueCollection'/>. </para>
/// </devdoc>
- public virtual string[] AllKeys
+ public virtual string?[] AllKeys
{
get
{
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class OrderedDictionary : IOrderedDictionary, ISerializable, IDeserializationCallback
{
- private ArrayList _objectsArray;
- private Hashtable _objectsTable;
+ private ArrayList? _objectsArray;
+ private Hashtable? _objectsTable;
private int _initialCapacity;
- private IEqualityComparer _comparer;
+ private IEqualityComparer? _comparer;
private bool _readOnly;
- private readonly SerializationInfo _siInfo; //A temporary variable which we need during deserialization.
+ private readonly SerializationInfo? _siInfo; //A temporary variable which we need during deserialization.
private const string KeyComparerName = "KeyComparer"; // Do not rename (binary serialization)
private const string ArrayListName = "ArrayList"; // Do not rename (binary serialization)
{
}
- public OrderedDictionary(IEqualityComparer comparer) : this(0, comparer)
+ public OrderedDictionary(IEqualityComparer? comparer) : this(0, comparer)
{
}
- public OrderedDictionary(int capacity, IEqualityComparer comparer)
+ public OrderedDictionary(int capacity, IEqualityComparer? comparer)
{
_initialCapacity = capacity;
_comparer = comparer;
{
get
{
- EnsureObjectsArray();
- return new OrderedDictionaryKeyValueCollection(_objectsArray, true);
+ ArrayList objectsArray = EnsureObjectsArray();
+ return new OrderedDictionaryKeyValueCollection(objectsArray, true);
}
}
- private void EnsureObjectsArray()
- {
- if (_objectsArray == null)
- {
- _objectsArray = new ArrayList(_initialCapacity);
- }
- }
+ private ArrayList EnsureObjectsArray() => _objectsArray ??= new ArrayList(_initialCapacity);
- private void EnsureObjectsTable()
- {
- if (_objectsTable == null)
- {
- _objectsTable = new Hashtable(_initialCapacity, _comparer);
- }
- }
+ private Hashtable EnsureObjectsTable() => _objectsTable ??= new Hashtable(_initialCapacity, _comparer);
/// <devdoc>
/// The SyncRoot object. Not used because IsSynchronized is false
/// <devdoc>
/// Gets or sets the object at the specified index
/// </devdoc>
- public object this[int index]
+ public object? this[int index]
{
get
{
- EnsureObjectsArray();
- return ((DictionaryEntry)_objectsArray[index]).Value;
+ ArrayList objectsArray = EnsureObjectsArray();
+ return ((DictionaryEntry)objectsArray[index]!).Value;
}
set
{
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- EnsureObjectsArray();
- EnsureObjectsTable();
- object key = ((DictionaryEntry)_objectsArray[index]).Key;
- _objectsArray[index] = new DictionaryEntry(key, value);
- _objectsTable[key] = value;
+ ArrayList objectsArray = EnsureObjectsArray();
+ Hashtable objectsTable = EnsureObjectsTable();
+ object key = ((DictionaryEntry)objectsArray[index]!).Key;
+ objectsArray[index] = new DictionaryEntry(key, value);
+ objectsTable[key] = value;
}
}
/// <devdoc>
/// Gets or sets the object with the specified key
/// </devdoc>
- public object this[object key]
+ public object? this[object key]
{
get
{
{
throw new NotSupportedException(SR.OrderedDictionary_ReadOnly);
}
- EnsureObjectsTable();
- if (_objectsTable.Contains(key))
+ Hashtable objectsTable = EnsureObjectsTable();
+ if (objectsTable.Contains(key))
{
- _objectsTable[key] = value;
- EnsureObjectsArray();
- _objectsArray[IndexOfKey(key)] = new DictionaryEntry(key, value);
+ objectsTable[key] = value;
+ ArrayList objectsArray = EnsureObjectsArray();
+ objectsArray[IndexOfKey(key)] = new DictionaryEntry(key, value);
}
else
{
{
get
{
- EnsureObjectsArray();
- return new OrderedDictionaryKeyValueCollection(_objectsArray, false);
+ ArrayList objectsArray = EnsureObjectsArray();
+ return new OrderedDictionaryKeyValueCollection(objectsArray, false);
}
}
/// <devdoc>
/// Adds a new entry to the table with the lowest-available index.
/// </devdoc>
- public void Add(object key, object value)
+ public void Add(object key, object? value)
{
if (_readOnly)
{
throw new NotSupportedException(SR.OrderedDictionary_ReadOnly);
}
- EnsureObjectsTable();
- EnsureObjectsArray();
- _objectsTable.Add(key, value);
- _objectsArray.Add(new DictionaryEntry(key, value));
+ Hashtable objectsTable = EnsureObjectsTable();
+ ArrayList objectsArray = EnsureObjectsArray();
+ objectsTable.Add(key, value);
+ objectsArray.Add(new DictionaryEntry(key, value));
}
/// <devdoc>
/// </devdoc>
public void CopyTo(Array array, int index)
{
- EnsureObjectsTable();
- _objectsTable.CopyTo(array, index);
+ Hashtable objectsTable = EnsureObjectsTable();
+ objectsTable.CopyTo(array, index);
}
private int IndexOfKey(object key)
}
for (int i = 0; i < _objectsArray.Count; i++)
{
- object o = ((DictionaryEntry)_objectsArray[i]).Key;
+ object o = ((DictionaryEntry)_objectsArray[i]!).Key;
if (_comparer != null)
{
if (_comparer.Equals(o, key))
/// <devdoc>
/// Inserts a new object at the given index with the given key.
/// </devdoc>
- public void Insert(int index, object key, object value)
+ public void Insert(int index, object key, object? value)
{
if (_readOnly)
{
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- EnsureObjectsTable();
- EnsureObjectsArray();
- _objectsTable.Add(key, value);
- _objectsArray.Insert(index, new DictionaryEntry(key, value));
+ Hashtable objectsTable = EnsureObjectsTable();
+ ArrayList objectsArray = EnsureObjectsArray();
+ objectsTable.Add(key, value);
+ objectsArray.Insert(index, new DictionaryEntry(key, value));
}
/// <devdoc>
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- // The 'index >= Count' check above ensures
- // that the '_objectsArray' and '_objectsTable' objects are initialized.
- object key = ((DictionaryEntry)_objectsArray[index]).Key;
- _objectsArray.RemoveAt(index);
- _objectsTable.Remove(key);
+ Hashtable objectsTable = EnsureObjectsTable();
+ ArrayList objectsArray = EnsureObjectsArray();
+ object key = ((DictionaryEntry)objectsArray[index]!).Key;
+ objectsArray.RemoveAt(index);
+ objectsTable.Remove(key);
}
/// <devdoc>
return;
}
- EnsureObjectsTable();
- EnsureObjectsArray();
- _objectsTable.Remove(key);
- _objectsArray.RemoveAt(index);
+ Hashtable objectsTable = EnsureObjectsTable();
+ ArrayList objectsArray = EnsureObjectsArray();
+ objectsTable.Remove(key);
+ objectsArray.RemoveAt(index);
}
#region IDictionary implementation
public virtual IDictionaryEnumerator GetEnumerator()
{
- EnsureObjectsArray();
- return new OrderedDictionaryEnumerator(_objectsArray, OrderedDictionaryEnumerator.DictionaryEntry);
+ ArrayList objectsArray = EnsureObjectsArray();
+ return new OrderedDictionaryEnumerator(objectsArray, OrderedDictionaryEnumerator.DictionaryEntry);
}
#endregion
#region IEnumerable implementation
IEnumerator IEnumerable.GetEnumerator()
{
- EnsureObjectsArray();
- return new OrderedDictionaryEnumerator(_objectsArray, OrderedDictionaryEnumerator.DictionaryEntry);
+ ArrayList objectsArray = EnsureObjectsArray();
+ return new OrderedDictionaryEnumerator(objectsArray, OrderedDictionaryEnumerator.DictionaryEntry);
}
#endregion
info.AddValue(InitCapacityName, _initialCapacity);
object[] serArray = new object[Count];
- EnsureObjectsArray();
- _objectsArray.CopyTo(serArray);
+ ArrayList objectsArray = EnsureObjectsArray();
+ objectsArray.CopyTo(serArray);
info.AddValue(ArrayListName, serArray);
}
#endregion
#region IDeserializationCallback implementation
- void IDeserializationCallback.OnDeserialization(object sender)
+ void IDeserializationCallback.OnDeserialization(object? sender)
{
OnDeserialization(sender);
}
- protected virtual void OnDeserialization(object sender)
+ protected virtual void OnDeserialization(object? sender)
{
if (_siInfo == null)
{
throw new SerializationException(SR.Serialization_InvalidOnDeser);
}
- _comparer = (IEqualityComparer)_siInfo.GetValue(KeyComparerName, typeof(IEqualityComparer));
+ _comparer = (IEqualityComparer?)_siInfo.GetValue(KeyComparerName, typeof(IEqualityComparer));
_readOnly = _siInfo.GetBoolean(ReadOnlyName);
_initialCapacity = _siInfo.GetInt32(InitCapacityName);
- object[] serArray = (object[])_siInfo.GetValue(ArrayListName, typeof(object[]));
+ object[]? serArray = (object[]?)_siInfo.GetValue(ArrayListName, typeof(object[]));
if (serArray != null)
{
- EnsureObjectsTable();
- EnsureObjectsArray();
+ Hashtable objectsTable = EnsureObjectsTable();
+ ArrayList objectsArray = EnsureObjectsArray();
foreach (object o in serArray)
{
DictionaryEntry entry;
{
throw new SerializationException(SR.OrderedDictionary_SerializationMismatch);
}
- _objectsArray.Add(entry);
- _objectsTable.Add(entry.Key, entry.Value);
+ objectsArray.Add(entry);
+ objectsTable.Add(entry.Key, entry.Value);
}
}
}
/// <devdoc>
/// Retrieves the current DictionaryEntry. This is the same as Entry, but not strongly-typed.
/// </devdoc>
- public object Current
+ public object? Current
{
get
{
+ Debug.Assert(_arrayEnumerator.Current != null);
if (_objectReturnType == Keys)
{
return ((DictionaryEntry)_arrayEnumerator.Current).Key;
{
get
{
+ Debug.Assert(_arrayEnumerator.Current != null);
return new DictionaryEntry(((DictionaryEntry)_arrayEnumerator.Current).Key, ((DictionaryEntry)_arrayEnumerator.Current).Value);
}
}
{
get
{
+ Debug.Assert(_arrayEnumerator.Current != null);
return ((DictionaryEntry)_arrayEnumerator.Current).Key;
}
}
/// <devdoc>
/// Retrieves the value of the current DictionaryEntry
/// </devdoc>
- public object Value
+ public object? Value
{
get
{
+ Debug.Assert(_arrayEnumerator.Current != null);
return ((DictionaryEntry)_arrayEnumerator.Current).Value;
}
}
throw new ArgumentNullException(nameof(array));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum_Index);
- foreach (object o in _objects)
+ foreach (object? o in _objects)
{
+ Debug.Assert(o != null);
array.SetValue(_isKeys ? ((DictionaryEntry)o).Key : ((DictionaryEntry)o).Value, index);
index++;
}
/// <devdoc>
/// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
/// </devdoc>
- public string this[int index]
+ public string? this[int index]
{
get
{
- return ((string)data[index]);
+ return ((string?)data[index]);
}
set
{
/// <para>Adds a string with the specified value to the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
- public int Add(string value)
+ public int Add(string? value)
{
return data.Add(value);
}
/// <see cref='System.Collections.Specialized.StringCollection'/> contains a string with the specified
/// value.</para>
/// </devdoc>
- public bool Contains(string value)
+ public bool Contains(string? value)
{
return data.Contains(value);
}
/// <para>Returns the index of the first occurrence of a string in
/// the <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
- public int IndexOf(string value)
+ public int IndexOf(string? value)
{
return data.IndexOf(value);
}
/// <para>Inserts a string into the <see cref='System.Collections.Specialized.StringCollection'/> at the specified
/// index.</para>
/// </devdoc>
- public void Insert(int index, string value)
+ public void Insert(int index, string? value)
{
data.Insert(index, value);
}
/// <para> Removes a specific string from the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
- public void Remove(string value)
+ public void Remove(string? value)
{
data.Remove(value);
}
}
}
- object IList.this[int index]
+ object? IList.this[int index]
{
get
{
}
set
{
- this[index] = (string)value;
+ this[index] = (string?)value;
}
}
- int IList.Add(object value)
+ int IList.Add(object? value)
{
- return Add((string)value);
+ return Add((string?)value);
}
- bool IList.Contains(object value)
+ bool IList.Contains(object? value)
{
- return Contains((string)value);
+ return Contains((string?)value);
}
- int IList.IndexOf(object value)
+ int IList.IndexOf(object? value)
{
- return IndexOf((string)value);
+ return IndexOf((string?)value);
}
- void IList.Insert(int index, object value)
+ void IList.Insert(int index, object? value)
{
- Insert(index, (string)value);
+ Insert(index, (string?)value);
}
- void IList.Remove(object value)
+ void IList.Remove(object? value)
{
- Remove((string)value);
+ Remove((string?)value);
}
void ICollection.CopyTo(Array array, int index)
_baseEnumerator = _temp.GetEnumerator();
}
- public string Current
+ public string? Current
{
get
{
- return (string)(_baseEnumerator.Current);
+ return (string?)(_baseEnumerator.Current);
}
}
/// <devdoc>
/// <para>Gets or sets the value associated with the specified key.</para>
/// </devdoc>
- public virtual string this[string key]
+ public virtual string? this[string key]
{
get
{
throw new ArgumentNullException(nameof(key));
}
- return (string)contents[key.ToLowerInvariant()];
+ return (string?)contents[key.ToLowerInvariant()];
}
set
{
/// <devdoc>
/// <para>Adds an entry with the specified key and value into the StringDictionary.</para>
/// </devdoc>
- public virtual void Add(string key, string value)
+ public virtual void Add(string key, string? value)
{
if (key == null)
{
/// <devdoc>
/// <para>Determines if the StringDictionary contains a specific value.</para>
/// </devdoc>
- public virtual bool ContainsValue(string value)
+ public virtual bool ContainsValue(string? value)
{
return contents.ContainsValue(value);
}