diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs index 9a6c6d44c5090..7a44e3cce0191 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs @@ -287,9 +287,9 @@ private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param, count = 0; for (int i = 0; i < objAttr.Length; i++) { - if (objAttr[i] != null) + if (objAttr[i] is object attr) { - attributes[count] = (Attribute)objAttr[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + attributes[count] = (Attribute)attr; count++; } } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.CoreCLR.cs index 252627d27633a..ef5ec59482110 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.CoreCLR.cs @@ -116,7 +116,7 @@ internal override int IndexOf(T[] array, T value, int startIndex, int count) { for (int i = startIndex; i < endIndex; i++) { - if (array[i] != null && array[i]!.Equals(value)) return i; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (array[i] != null && array[i]!.Equals(value)) return i; } } return -1; @@ -136,7 +136,7 @@ internal override int LastIndexOf(T[] array, T value, int startIndex, int count) { for (int i = startIndex; i >= endIndex; i--) { - if (array[i] != null && array[i]!.Equals(value)) return i; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (array[i] != null && array[i]!.Equals(value)) return i; } } return -1; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs index bba499737c27a..34d08a8b056be 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -160,10 +160,10 @@ private static bool TrySetSlot(object?[] a, int index, object o) // The slot may be already set because we have added and removed the same method before. // Optimize this case, because it's cheaper than copying the array. - if (a[index] != null) + if (a[index] is object ai) { MulticastDelegate d = (MulticastDelegate)o; - MulticastDelegate dd = (MulticastDelegate)a[index]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + MulticastDelegate dd = (MulticastDelegate)ai; if (dd._methodPtr == d._methodPtr && dd._target == d._target && diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs index acdf1663b80c3..23a973f15ae34 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs @@ -1622,14 +1622,14 @@ internal void AddLocalSymInfoToCurrentScope( { int i = GetCurrentActiveScopeIndex(); m_localSymInfos[i] ??= new LocalSymInfo(); - m_localSymInfos[i]!.AddLocalSymInfo(strName, signature, slot, startOffset, endOffset); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + m_localSymInfos[i]!.AddLocalSymInfo(strName, signature, slot, startOffset, endOffset); } internal void AddUsingNamespaceToCurrentScope(string strNamespace) { int i = GetCurrentActiveScopeIndex(); m_localSymInfos[i] ??= new LocalSymInfo(); - m_localSymInfos[i]!.AddUsingNamespace(strNamespace); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + m_localSymInfos[i]!.AddUsingNamespace(strNamespace); } internal void AddScopeInfo(ScopeAction sa, int iOffset) @@ -1693,9 +1693,9 @@ internal void EmitScopeTree(ISymbolWriter symWriter) { symWriter.CloseScope(m_iOffsets[i]); } - if (m_localSymInfos[i] != null) + if (m_localSymInfos[i] is LocalSymInfo lsi) { - m_localSymInfos[i]!.EmitLocalSymInfo(symWriter); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + lsi.EmitLocalSymInfo(symWriter); } } } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index 744efa515e3cd..f76df3efa4915 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -3900,9 +3900,9 @@ private void CreateInstanceCheckThis() Type[] argsType = new Type[args.Length]; for (int i = 0; i < args.Length; i++) { - if (args[i] != null) + if (args[i] is object arg) { - argsType[i] = args[i]!.GetType(); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + argsType[i] = arg.GetType(); } } diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs index d30c4114f6a6c..22281c58e3169 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs @@ -57,9 +57,9 @@ public DelegateWrapper(Delegate d, bool wrapArgs) { for (int i = 0; i < _expectedParamsCount; i++) { - if (_cachedTargetTypes[i] != null) + if (_cachedTargetTypes[i] is Type t) { - args[i] = Enum.ToObject(_cachedTargetTypes[i]!, args[i]); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + args[i] = Enum.ToObject(t, args[i]); } } } diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs index a7a74c66c3204..abd485f2a1065 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs @@ -1089,15 +1089,16 @@ private static List GetHandles(BlockingCollection[] collections, List tokensList = new List(collections.Length + 1); // + 1 for the external token tokensList.Add(externalCancellationToken); - //Read the appropriate WaitHandle based on the operation mode. + // Read the appropriate WaitHandle based on the operation mode. if (isAddOperation) { for (int i = 0; i < collections.Length; i++) { - if (collections[i]._freeNodes != null) + BlockingCollection c = collections[i]; + if (c._freeNodes != null) { - handlesList.Add(collections[i]._freeNodes!.AvailableWaitHandle); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) - tokensList.Add(collections[i]._producersCancellationTokenSource.Token); + handlesList.Add(c._freeNodes.AvailableWaitHandle); + tokensList.Add(c._producersCancellationTokenSource.Token); } } } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs index 14124ff46f5cf..cbfc3cdda8afa 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs @@ -97,14 +97,13 @@ public override int GetHashCode() { return MemberType.GetHashCode() ^ _accessorsCreator.GetHashCode(); } - else + + if (_accessors != null && _accessors[0] is MemberInfo accessor) { - if (_accessors == null || _accessors[0] == null) - { - throw new Exception(SR.Diagnostic_InternalExceptionMessage); - } - return MemberType.GetHashCode() ^ _accessors[0]!.GetHashCode(); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + return MemberType.GetHashCode() ^ accessor.GetHashCode(); } + + throw new Exception(SR.Diagnostic_InternalExceptionMessage); } public override bool Equals(object? obj) diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs index ca8be31d9ec3d..b74cb3d1374fc 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs @@ -109,9 +109,11 @@ public override bool Equals(object? obj) for (int i = 0; i < Count; i++) { - if (InnerList[i] != other.InnerList[i]) + object? thisObj = InnerList[i]; + object? otherObj = other.InnerList[i]; + if (thisObj != otherObj) { - if (InnerList[i] == null || !InnerList[i]!.Equals(other.InnerList[i])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644 + if (thisObj is null || !thisObj.Equals(otherObj)) { return false; } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs index 8d688f312bc5b..613f1ce2e1aa0 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs @@ -664,11 +664,11 @@ internal static void GetPrintDialogInfo(string printer, ref string port, ref str NameValueCollection options = LoadPrinterOptions(cups_dests.options, cups_dests.num_options); - if (options["printer-state"] != null) - state = int.Parse(options["printer-state"]!); // TODO-NULLABLE dotnet/roslyn#34644 + if (options["printer-state"] is string printerState) + state = int.Parse(printerState); - if (options["printer-comment"] != null) - comment = options["printer-state"]!; // TODO-NULLABLE dotnet/roslyn#34644 + if (options["printer-comment"] is string printerComment) + comment = printerComment; switch (state) { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs index 8834b0bca994b..f8bf7ecbf4454 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs @@ -355,11 +355,11 @@ internal static void DumpHeaders(StringBuilder sb, params HttpHeaders?[] headers for (int i = 0; i < headers.Length; i++) { - if (headers[i] != null) + if (headers[i] is HttpHeaders hh) { - foreach (var header in headers[i]!) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644 + foreach (KeyValuePair> header in hh) { - foreach (var headerValue in header.Value) + foreach (string headerValue in header.Value) { sb.Append(" "); sb.Append(header.Key); diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs index c23b06ade9fca..5e672ac89bd45 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs @@ -262,7 +262,7 @@ public virtual bool Contains(object? item) else { for (int i = 0; i < _size; i++) - if ((_items[i] != null) && (_items[i]!.Equals(item))) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (_items[i] is object o && o.Equals(item)) return true; return false; } @@ -916,7 +916,7 @@ public override int IndexOf(object? value, int startIndex, int count) else { for (int i = startIndex; i < endIndex; i++) - if (_list[i] != null && _list[i]!.Equals(value)) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (_list[i] is object o && o.Equals(value)) return i; return -1; } @@ -984,7 +984,7 @@ public override int LastIndexOf(object? value, int startIndex, int count) else { for (int i = startIndex; i >= endIndex; i--) - if (_list[i] != null && _list[i]!.Equals(value)) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (_list[i] is object o && o.Equals(value)) return i; return -1; } @@ -2311,7 +2311,7 @@ public override bool Contains(object? item) else { for (int i = 0; i < _baseSize; i++) - if (_baseList[_baseIndex + i] != null && _baseList[_baseIndex + i]!.Equals(item)) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (_baseList[_baseIndex + i] is object o && o.Equals(item)) return true; return false; } diff --git a/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs b/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs index d16ad828820ae..8b5b1c31c6ffb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs @@ -104,7 +104,7 @@ public sealed override MethodBase BindToMethod( continue; // Validate the parameters. - ParameterInfo[] par = candidates[i]!.GetParametersNoCopy(); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + ParameterInfo[] par = candidates[i]!.GetParametersNoCopy(); #region Match method by parameter count if (par.Length == 0) @@ -112,7 +112,7 @@ public sealed override MethodBase BindToMethod( #region No formal parameters if (args.Length != 0) { - if ((candidates[i]!.CallingConvention & CallingConventions.VarArgs) == 0) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if ((candidates[i]!.CallingConvention & CallingConventions.VarArgs) == 0) continue; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs index abe2362a0b18a..3c11d5b177d40 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs @@ -131,9 +131,9 @@ private static string Serialize(ReadOnlyCollection? payloadName, ReadOnl } default: { - if (payload[i] != null) + if (payload[i] is object o) { - sb.Append(payload[i]!.ToString()); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + sb.Append(o.ToString()); } break; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index 7db6ace267572..6a712d8623092 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -194,23 +194,26 @@ internal static bool TryParseExactMultiple(ReadOnlySpan s, string?[]? form // for (int i = 0; i < formats.Length; i++) { - if (formats[i] == null || formats[i]!.Length == 0) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + string? format = formats[i]; + if (string.IsNullOrEmpty(format)) { result.SetBadFormatSpecifierFailure(); return false; } + // Create a new result each time to ensure the runs are independent. Carry through // flags from the caller and return the result. DateTimeResult innerResult = default; // The buffer to store the parsing result. innerResult.Init(s); innerResult.flags = result.flags; - if (TryParseExact(s, formats[i], dtfi, style, ref innerResult)) + if (TryParseExact(s, format, dtfi, style, ref innerResult)) { result.parsedDate = innerResult.parsedDate; result.timeZoneOffset = innerResult.timeZoneOffset; return true; } } + result.SetBadDateTimeFailure(); return false; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs index e1469148c5399..0ab52cc061241 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs @@ -956,7 +956,7 @@ private Type FindType(int typeIndex) } } Debug.Assert(_typeTable[typeIndex] != null, "Should have found a type!"); - return _typeTable[typeIndex]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + return _typeTable[typeIndex]!; } private string TypeNameFromTypeCode(ResourceTypeCode typeCode) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs index dfdf689194d0b..22c0b183064df 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs @@ -1340,7 +1340,7 @@ private unsafe StringBuilder AppendJoinCore(char* separator, int separatorLen if (values[0] != null) { - Append(values[0]!.ToString()); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + Append(values[0]!.ToString()); } for (int i = 1; i < values.Length; i++) @@ -1348,7 +1348,7 @@ private unsafe StringBuilder AppendJoinCore(char* separator, int separatorLen Append(separator, separatorLength); if (values[i] != null) { - Append(values[i]!.ToString()); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + Append(values[i]!.ToString()); } } return this; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs index 1459ee6393f57..8311d9dadee04 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs @@ -303,9 +303,9 @@ private static int WaitMultiple(ReadOnlySpan waitHandles, bool waitA { for (int i = 0; i < waitHandles.Length; ++i) { - if (safeWaitHandles[i] != null) + if (safeWaitHandles[i] is SafeWaitHandle swh) { - safeWaitHandles[i]!.DangerousRelease(); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + swh.DangerousRelease(); safeWaitHandles[i] = null; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs b/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs index d28dcd8b0b07a..dea4b7db03630 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs @@ -135,8 +135,8 @@ public virtual Type[] FindInterfaces(TypeFilter filter, object? filterCriteria) cnt = 0; for (int i = 0; i < c.Length; i++) { - if (c[i] != null) - ret[cnt++] = c[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (c[i] is Type t) + ret[cnt++] = t!; } return ret; } @@ -272,47 +272,47 @@ public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bin { for (i = 0; i < m.Length; i++) if (m[i] != null) - ret[cnt++] = m[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + ret[cnt++] = m[i]!; } // Copy the Constructors if (c != null) { for (i = 0; i < c.Length; i++) - if (c[i] != null) - ret[cnt++] = c[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (c[i] is ConstructorInfo ci) + ret[cnt++] = ci; } // Copy the Fields if (f != null) { for (i = 0; i < f.Length; i++) - if (f[i] != null) - ret[cnt++] = f[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (f[i] is FieldInfo fi) + ret[cnt++] = fi; } // Copy the Properties if (p != null) { for (i = 0; i < p.Length; i++) - if (p[i] != null) - ret[cnt++] = p[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (p[i] is PropertyInfo pi) + ret[cnt++] = pi; } // Copy the Events if (e != null) { for (i = 0; i < e.Length; i++) - if (e[i] != null) - ret[cnt++] = e[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (e[i] is EventInfo ei) + ret[cnt++] = ei; } // Copy the Types if (t != null) { for (i = 0; i < t.Length; i++) - if (t[i] != null) - ret[cnt++] = t[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + if (t[i] is Type type) + ret[cnt++] = type; } return ret; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs index 6457f16b90379..06fe919e77703 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs @@ -105,8 +105,7 @@ internal void Reset() public override string XmlLang { get { return IsXmlDataNode ? _xmlNodeReader.XmlLang : base.XmlLang; } } public override string this[int i] { get { return IsXmlDataNode ? _xmlNodeReader[i] : GetAttribute(i); } } public override string? this[string name] { get { return IsXmlDataNode ? _xmlNodeReader[name] : GetAttribute(name); } } - // TODO-NULLABLE - unnecessary namespaceURI! - https://github.com/dotnet/roslyn/issues/47221 - public override string? this[string name, string? namespaceURI] { get { return IsXmlDataNode ? _xmlNodeReader[name, namespaceURI!] : GetAttribute(name, namespaceURI); } } + public override string? this[string name, string? namespaceURI] { get { return IsXmlDataNode ? _xmlNodeReader[name, namespaceURI] : GetAttribute(name, namespaceURI); } } public override bool MoveToFirstAttribute() { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs index 6dfadbd82d391..e7c1950ada538 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs @@ -356,7 +356,7 @@ internal IXmlSerializable ReflectionCreateXmlSerializable(Type type) object? o = null; if (type == typeof(System.Xml.Linq.XElement)) { - o = new System.Xml.Linq.XElement("default"!); // TODO-NULLABLE - https://github.com/dotnet/roslyn/issues/39802 + o = new System.Xml.Linq.XElement("default"); } else { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableReader.cs index a8a259e0b3279..6980f99ac9d10 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableReader.cs @@ -85,8 +85,7 @@ public override void Close() public override int AttributeCount { get { return InnerReader.AttributeCount; } } public override string this[int i] { get { return InnerReader[i]; } } public override string? this[string name] { get { return InnerReader[name]; } } - // TODO-NULLABLE - unnecessary namespaceURI! - https://github.com/dotnet/roslyn/issues/47221 - public override string? this[string name, string? namespaceURI] { get { return InnerReader[name, namespaceURI!]; } } + public override string? this[string name, string? namespaceURI] { get { return InnerReader[name, namespaceURI]; } } public override bool EOF { get { return InnerReader.EOF; } } public override ReadState ReadState { get { return InnerReader.ReadState; } } public override XmlNameTable NameTable { get { return InnerReader.NameTable; } } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs index 79922c417deb3..894aa0453dd0d 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs @@ -1586,8 +1586,7 @@ public override string? this[string name] { get { - // TODO-NULLABLE - unnecessary namespaceUri! - https://github.com/dotnet/roslyn/issues/47221 - return _reader[name, namespaceUri!]; + return _reader[name, namespaceUri]; } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs index eefbba970c17f..b852f740d02be 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs @@ -170,7 +170,7 @@ private enum InitInputType private NodeData[]? _attrDuplSortingArray; // name table - private XmlNameTable _nameTable = null!; // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/43523 + private XmlNameTable _nameTable; private bool _nameTableFromSettings; // resolver diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectWriter.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectWriter.cs index d4207fbfa68e8..7466fd9132760 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectWriter.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectWriter.cs @@ -159,7 +159,7 @@ private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo { Type type = memberTypes[i] != null ? memberTypes[i] : - memberData[i] != null ? GetType(memberData[i]!) : // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + memberData[i] != null ? GetType(memberData[i]!) : Converter.s_typeofObject; InternalPrimitiveTypeE code = ToCode(type); @@ -170,7 +170,7 @@ private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo if (memberData[i] != null) { memberObjectInfos[i] = WriteObjectInfo.Serialize( - memberData[i]!, // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) + memberData[i]!, _surrogates, _context, _serObjectInfoInit,