diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
index e222d17e5aa31..6a3d62e34a7b0 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
@@ -303,7 +303,7 @@ protected CustomTypeDescriptor(System.ComponentModel.ICustomTypeDescriptor? pare
public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[]? attributes) { throw null; }
- public virtual object? GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; }
+ public virtual object? GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Class)]
public sealed partial class DataObjectAttribute : System.Attribute
@@ -585,7 +585,7 @@ public partial interface ICustomTypeDescriptor
System.ComponentModel.PropertyDescriptorCollection GetProperties();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[]? attributes);
- object? GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd);
+ object? GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd);
}
public partial interface IDataErrorInfo
{
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CustomTypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CustomTypeDescriptor.cs
index 17923164ab301..7adad3b3bc0dc 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CustomTypeDescriptor.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CustomTypeDescriptor.cs
@@ -179,6 +179,6 @@ public virtual PropertyDescriptorCollection GetProperties(Attribute[]? attribute
/// returned. Returning null from this method causes the TypeDescriptor object
/// to use its default type description services.
///
- public virtual object? GetPropertyOwner(PropertyDescriptor pd) => _parent?.GetPropertyOwner(pd);
+ public virtual object? GetPropertyOwner(PropertyDescriptor? pd) => _parent?.GetPropertyOwner(pd);
}
}
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs
index fd9b681c20e8a..57b602ac9e963 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs
@@ -77,6 +77,6 @@ public interface ICustomTypeDescriptor
///
/// Gets the object that directly depends on this value being edited.
///
- object? GetPropertyOwner(PropertyDescriptor pd);
+ object? GetPropertyOwner(PropertyDescriptor? pd);
}
}
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs
index 9908aa66c330a..f41b9fca2a130 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs
@@ -791,7 +791,7 @@ private static IExtenderProvider[] GetExtenders(ICollection components, object i
///
/// Retrieves the owner for a property.
///
- internal object GetExtendedPropertyOwner(object instance, PropertyDescriptor pd)
+ internal object GetExtendedPropertyOwner(object instance, PropertyDescriptor? pd)
{
return GetPropertyOwner(instance.GetType(), instance, pd);
}
@@ -873,7 +873,7 @@ internal PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(
///
/// Retrieves the owner for a property.
///
- internal object GetPropertyOwner(Type type, object instance, PropertyDescriptor pd)
+ internal object GetPropertyOwner(Type type, object instance, PropertyDescriptor? pd)
{
return TypeDescriptor.GetAssociation(type, instance);
}
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
index d8fae944f83c7..72f1dadd00c57 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
@@ -2771,7 +2771,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
return _handler.GetProperties(_instance, attributes);
}
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) => _instance;
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd) => _instance;
}
}
@@ -3121,7 +3121,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
///
/// ICustomTypeDescriptor implementation.
///
- object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
+ object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
return _primary.GetPropertyOwner(pd) ?? _secondary.GetPropertyOwner(pd);
}
@@ -3570,7 +3570,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
/// ICustomTypeDescriptor implementation.
///
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
// Check to see if the provider we get is a ReflectTypeDescriptionProvider.
// If so, we can call on it directly rather than creating another
@@ -3915,7 +3915,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
///
/// ICustomTypeDescriptor implementation.
///
- object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
+ object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
// Check to see if the provider we get is a ReflectTypeDescriptionProvider.
// If so, we can call on it directly rather than creating another
diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.cs
index 10041da15cefc..ca955720c0df1 100644
--- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs
+++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs
@@ -481,7 +481,7 @@ public void EndEdit() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
- object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; }
+ object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("DataSetName")]
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataSetDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
@@ -2207,7 +2207,7 @@ void System.Collections.IDictionary.Remove(object keyword) { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
- object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; }
+ object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
public override string ToString() { throw null; }
public virtual bool TryGetValue(string keyword, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out object? value) { throw null; }
}
@@ -2398,7 +2398,7 @@ protected DbDataRecord() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
- object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; }
+ object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
public abstract partial class DbDataSourceEnumerator
{
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/AdapterUtil.Common.cs b/src/libraries/System.Data.Common/src/System/Data/Common/AdapterUtil.Common.cs
index 38695b358c178..3bf38b5b09a0e 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/AdapterUtil.Common.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/AdapterUtil.Common.cs
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO-NULLABLE: Enable nullability as part of annotation System.Data.{Odbc,OleDb}
-#nullable disable
-
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
@@ -266,7 +263,7 @@ internal static ArgumentOutOfRangeException NotSupportedStatementType(StatementT
//
// DbConnectionOptions, DataAccess
//
- internal static ArgumentException InvalidKeyname(string parameterName)
+ internal static ArgumentException InvalidKeyname(string? parameterName)
{
return Argument(SR.ADP_InvalidKey, parameterName);
}
@@ -286,7 +283,7 @@ internal static Exception WrongType(Type got, Type expected)
//
// Generic Data Provider Collection
//
- internal static Exception CollectionUniqueValue(Type itemType, string propertyName, string propertyValue)
+ internal static Exception CollectionUniqueValue(Type itemType, string propertyName, string? propertyValue)
{
return Argument(SR.Format(SR.ADP_CollectionUniqueValue, itemType.Name, propertyName, propertyValue));
}
@@ -306,19 +303,19 @@ private static InvalidOperationException DataMapping(string error)
}
// DataColumnMapping.GetDataColumnBySchemaAction
- internal static InvalidOperationException ColumnSchemaExpression(string srcColumn, string cacheColumn)
+ internal static InvalidOperationException ColumnSchemaExpression(string? srcColumn, string cacheColumn)
{
return DataMapping(SR.Format(SR.ADP_ColumnSchemaExpression, srcColumn, cacheColumn));
}
// DataColumnMapping.GetDataColumnBySchemaAction
- internal static InvalidOperationException ColumnSchemaMismatch(string srcColumn, Type srcType, DataColumn column)
+ internal static InvalidOperationException ColumnSchemaMismatch(string? srcColumn, Type srcType, DataColumn column)
{
return DataMapping(SR.Format(SR.ADP_ColumnSchemaMismatch, srcColumn, srcType.Name, column.ColumnName, column.DataType.Name));
}
// DataColumnMapping.GetDataColumnBySchemaAction
- internal static InvalidOperationException ColumnSchemaMissing(string cacheColumn, string tableName, string srcColumn)
+ internal static InvalidOperationException ColumnSchemaMissing(string cacheColumn, string tableName, string? srcColumn)
{
if (string.IsNullOrEmpty(tableName))
{
@@ -382,7 +379,7 @@ internal static Exception ColumnsIsParent(ICollection collection)
{
return ParametersIsParent(typeof(DataColumnMapping), collection);
}
- internal static Exception ColumnsUniqueSourceColumn(string srcColumn)
+ internal static Exception ColumnsUniqueSourceColumn(string? srcColumn)
{
return CollectionUniqueValue(typeof(DataColumnMapping), ADP.SourceColumn, srcColumn);
}
@@ -422,7 +419,7 @@ internal static Exception TablesSourceIndex(string srcTable)
{
return CollectionIndexString(typeof(DataTableMapping), ADP.SourceTable, srcTable, typeof(DataTableMappingCollection));
}
- internal static Exception TablesUniqueSourceTable(string srcTable)
+ internal static Exception TablesUniqueSourceTable(string? srcTable)
{
return CollectionUniqueValue(typeof(DataTableMapping), ADP.SourceTable, srcTable);
}
@@ -840,6 +837,6 @@ private static int GenerateUniqueName(Dictionary hash, ref string c
return uniqueIndex;
}
- internal static int SrcCompare(string strA, string strB) => strA == strB ? 0 : 1;
+ internal static int SrcCompare(string? strA, string? strB) => strA == strB ? 0 : 1;
}
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
index c49d8d33ef0ca..ba0a44032fc69 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
@@ -368,7 +368,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
return _propertyDescriptors;
}
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
return this;
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataStorage.cs
index 1a8b361c17f7d..8c28cc2210da2 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/DataStorage.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataStorage.cs
@@ -274,7 +274,7 @@ public virtual void SetCapacity(int capacity)
public abstract object ConvertXmlToObject(string s);
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- public virtual object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib)
+ public virtual object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute? xmlAttrib)
{
return ConvertXmlToObject(xmlReader.Value);
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
index 10567391a3ec5..27ffe33faa3b4 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
@@ -637,7 +637,7 @@ EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attribute
{
return TypeDescriptor.GetEvents(this, attributes, true);
}
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
return this;
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
index f3e1827f8859e..14f3d84387724 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
@@ -101,6 +101,6 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() =>
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? attributes) =>
new PropertyDescriptorCollection(null);
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) => this;
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd) => this;
}
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs
index aa06791989d6e..7489652d9ba15 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs
@@ -349,7 +349,7 @@ public override object ConvertXmlToObject(string s)
// Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set.
[MethodImpl(MethodImplOptions.NoInlining)]
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib)
+ public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute? xmlAttrib)
{
object? retValue = null;
bool isBaseCLRType = false;
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
index 16aea8a6c0bb2..b804c470ed02e 100644
--- a/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
@@ -173,7 +173,7 @@ public override object ConvertXmlToObject(string s)
// Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set.
[MethodImpl(MethodImplOptions.NoInlining)]
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib)
+ public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute? xmlAttrib)
{
if (null == xmlAttrib)
{
diff --git a/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs b/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs
index 796ea59699d03..5d98ebf62ef9d 100644
--- a/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs
@@ -1798,7 +1798,7 @@ internal object ConvertXmlToObject(string s)
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- internal object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib)
+ internal object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute? xmlAttrib)
{
return InsureStorage().ConvertXmlToObject(xmlReader, xmlAttrib);
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/DataException.cs b/src/libraries/System.Data.Common/src/System/Data/DataException.cs
index dfc6806e2efdc..301075bf54304 100644
--- a/src/libraries/System.Data.Common/src/System/Data/DataException.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/DataException.cs
@@ -677,7 +677,7 @@ public static Exception RemovePrimaryKey(DataTable table) => table.TableName.Len
public static Exception DiffgramMissingSQL() => _Data(SR.Xml_MissingSQL);
public static Exception DuplicateConstraintRead(string str) => _Data(SR.Format(SR.Xml_DuplicateConstraint, str));
public static Exception ColumnTypeConflict(string name) => _Data(SR.Format(SR.Xml_ColumnConflict, name));
- public static Exception CannotConvert(string name, string type) => _Data(SR.Format(SR.Xml_CannotConvert, name, type));
+ public static Exception CannotConvert(string name, string? type) => _Data(SR.Format(SR.Xml_CannotConvert, name, type));
public static Exception MissingRefer(string name) => _Data(SR.Format(SR.Xml_MissingRefer, Keywords.REFER, Keywords.XSD_KEYREF, name));
public static Exception InvalidPrefix(string name) => _Data(SR.Format(SR.Xml_InvalidPrefix_SpecialCharacters, name));
public static Exception CanNotDeserializeObjectType() => _InvalidOperation(SR.Xml_CanNotDeserializeObjectType);
diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRowView.cs b/src/libraries/System.Data.Common/src/System/Data/DataRowView.cs
index dc0dd2e7aad7e..c12d20bfd034c 100644
--- a/src/libraries/System.Data.Common/src/System/Data/DataRowView.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/DataRowView.cs
@@ -257,7 +257,7 @@ public void EndEdit()
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? attributes) =>
(_dataView.Table != null ? _dataView.Table.GetPropertyDescriptorCollection(attributes) : s_zeroPropertyDescriptorCollection);
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) => this;
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd) => this;
#endregion
}
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs
index 5677da8639e5d..e4dd696086956 100644
--- a/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs
@@ -119,7 +119,7 @@ public DataTable? this[string? name]
// Case-sensitive smart search: it will look for a table using the ns only if required to
// resolve a conflict
- internal DataTable? GetTableSmart(string name, string ns)
+ internal DataTable? GetTableSmart(string name, string? ns)
{
int fCount = 0;
DataTable? fTable = null;
diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs
index 20b61fc1a3651..d991f29e5f1e1 100644
--- a/src/libraries/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO: Enable after System.ComponentModel.TypeConverter is annotated
-#nullable disable
-
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
@@ -12,7 +9,7 @@ namespace System.Data
internal sealed class DataViewManagerListItemTypeDescriptor : ICustomTypeDescriptor
{
private readonly DataViewManager _dataViewManager;
- private PropertyDescriptorCollection _propsCollection;
+ private PropertyDescriptorCollection? _propsCollection;
internal DataViewManagerListItemTypeDescriptor(DataViewManager dataViewManager)
{
@@ -40,37 +37,37 @@ internal DataView GetDataView(DataTable table)
/// Retrieves the class name for this object. If null is returned,
/// the type name is used.
///
- string ICustomTypeDescriptor.GetClassName() => null;
+ string? ICustomTypeDescriptor.GetClassName() => null;
///
/// Retrieves the name for this object. If null is returned,
/// the default is used.
///
- string ICustomTypeDescriptor.GetComponentName() => null;
+ string? ICustomTypeDescriptor.GetComponentName() => null;
///
/// Retrieves the type converter for this object.
///
[RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
- TypeConverter ICustomTypeDescriptor.GetConverter() => null;
+ TypeConverter ICustomTypeDescriptor.GetConverter() => null!;
///
/// Retrieves the default event.
///
[RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
- EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() => null;
+ EventDescriptor? ICustomTypeDescriptor.GetDefaultEvent() => null;
///
/// Retrieves the default property.
///
[RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
- PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() => null;
+ PropertyDescriptor? ICustomTypeDescriptor.GetDefaultProperty() => null;
///
/// Retrieves the an editor for this object.
///
[RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
- object ICustomTypeDescriptor.GetEditor(Type editorBaseType) => null;
+ object? ICustomTypeDescriptor.GetEditor(Type editorBaseType) => null;
///
/// Retrieves an array of events that the given component instance
@@ -88,7 +85,7 @@ internal DataView GetDataView(DataTable table)
/// filtered by the given set of attributes.
///
[RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) =>
+ EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attributes) =>
new EventDescriptorCollection(null);
///
@@ -109,15 +106,15 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() =>
/// filtered by the given set of attributes.
///
[RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) =>
+ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? attributes) =>
GetPropertiesInternal();
internal PropertyDescriptorCollection GetPropertiesInternal()
{
if (_propsCollection == null)
{
- PropertyDescriptor[] props = null;
- DataSet dataSet = _dataViewManager.DataSet;
+ PropertyDescriptor[]? props = null;
+ DataSet? dataSet = _dataViewManager.DataSet;
if (dataSet != null)
{
int tableCount = dataSet.Tables.Count;
@@ -139,6 +136,6 @@ internal PropertyDescriptorCollection GetPropertiesInternal()
/// descriptor implementation should return the default object, that is the main
/// object that exposes the properties and attributes,
///
- object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) => this;
+ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd) => this;
}
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs b/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs
index 63dbd993fea70..4b13c79f5eba7 100644
--- a/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs
@@ -121,7 +121,7 @@ internal void LoadTypeValues(XmlSchemaSimpleType node)
}
}
- string tempStr = XSDSchema.GetMsdataAttribute(node, Keywords.TARGETNAMESPACE);
+ string? tempStr = XSDSchema.GetMsdataAttribute(node, Keywords.TARGETNAMESPACE);
if (tempStr != null)
_ns = tempStr;
}
@@ -129,7 +129,7 @@ internal void LoadTypeValues(XmlSchemaSimpleType node)
internal bool IsPlainString()
{
return (
- XSDSchema.QualifiedName(_baseType) == XSDSchema.QualifiedName("string") &&
+ XSDSchema.QualifiedName(_baseType!) == XSDSchema.QualifiedName("string") &&
string.IsNullOrEmpty(_name) &&
_length == -1 &&
_minLength == -1 &&
diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs
index 12502ad9da104..df87d51e94541 100644
--- a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO: Enable after System.Private.Xml is annotated
-#nullable disable
-
using System.Diagnostics;
using System.Collections;
using System.Xml;
@@ -14,9 +11,9 @@ namespace System.Data
{
internal sealed class XMLDiffLoader
{
- private ArrayList _tables;
- private DataSet _dataSet;
- private DataTable _dataTable;
+ private ArrayList? _tables;
+ private DataSet? _dataSet;
+ private DataTable? _dataTable;
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void LoadDiffGram(DataSet ds, XmlReader dataTextReader)
@@ -42,7 +39,7 @@ private void CreateTablesHierarchy(DataTable dt)
{
foreach (DataRelation r in dt.ChildRelations)
{
- if (!_tables.Contains(r.ChildTable))
+ if (!_tables!.Contains(r.ChildTable))
{
_tables.Add(r.ChildTable);
CreateTablesHierarchy(r.ChildTable);
@@ -76,8 +73,8 @@ internal void LoadDiffGram(DataTable dt, XmlReader dataTextReader)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void ProcessDiffs(DataSet ds, XmlReader ssync)
{
- DataTable tableBefore;
- DataRow row;
+ DataTable? tableBefore;
+ DataRow? row;
int oldRowRecord;
int pos = -1;
@@ -89,13 +86,13 @@ internal void ProcessDiffs(DataSet ds, XmlReader ssync)
while (iSsyncDepth < ssync.Depth)
{
tableBefore = null;
- string diffId = null;
+ string? diffId = null;
oldRowRecord = -1;
// the diffgramm always contains sql:before and sql:after pairs
- diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
+ diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS)!;
bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
oldRowRecord = ReadOldRowData(ds, ref tableBefore, ref pos, ssync);
if (oldRowRecord == -1)
@@ -104,7 +101,7 @@ internal void ProcessDiffs(DataSet ds, XmlReader ssync)
if (tableBefore == null)
throw ExceptionBuilder.DiffgramMissingSQL();
- row = (DataRow)tableBefore.RowDiffId[diffId];
+ row = (DataRow?)tableBefore.RowDiffId[diffId];
if (row != null)
{
row._oldRecord = oldRowRecord;
@@ -129,8 +126,8 @@ internal void ProcessDiffs(DataSet ds, XmlReader ssync)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void ProcessDiffs(ArrayList tableList, XmlReader ssync)
{
- DataTable tableBefore;
- DataRow row;
+ DataTable? tableBefore;
+ DataRow? row;
int oldRowRecord;
int pos = -1;
@@ -142,13 +139,13 @@ internal void ProcessDiffs(ArrayList tableList, XmlReader ssync)
while (iSsyncDepth < ssync.Depth)
{
tableBefore = null;
- string diffId = null;
+ string diffId;
oldRowRecord = -1;
// the diffgramm always contains sql:before and sql:after pairs
- diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
+ diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS)!;
bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
oldRowRecord = ReadOldRowData(_dataSet, ref tableBefore, ref pos, ssync);
if (oldRowRecord == -1)
@@ -157,7 +154,7 @@ internal void ProcessDiffs(ArrayList tableList, XmlReader ssync)
if (tableBefore == null)
throw ExceptionBuilder.DiffgramMissingSQL();
- row = (DataRow)tableBefore.RowDiffId[diffId];
+ row = (DataRow?)tableBefore.RowDiffId[diffId];
if (row != null)
{
@@ -183,7 +180,7 @@ internal void ProcessDiffs(ArrayList tableList, XmlReader ssync)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void ProcessErrors(DataSet ds, XmlReader ssync)
{
- DataTable table;
+ DataTable? table;
int iSsyncDepth = ssync.Depth;
ssync.Read(); // pass the before node.
@@ -193,9 +190,9 @@ internal void ProcessErrors(DataSet ds, XmlReader ssync)
table = ds.Tables.GetTable(XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI);
if (table == null)
throw ExceptionBuilder.DiffgramMissingSQL();
- string diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
- DataRow row = (DataRow)table.RowDiffId[diffId];
- string rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
+ string diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS)!;
+ DataRow row = (DataRow)table.RowDiffId[diffId]!;
+ string? rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
if (rowError != null)
row.RowError = rowError;
int iRowDepth = ssync.Depth;
@@ -204,10 +201,10 @@ internal void ProcessErrors(DataSet ds, XmlReader ssync)
{
if (XmlNodeType.Element == ssync.NodeType)
{
- DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI];
+ DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI]!;
//if (col == null)
// throw exception here
- string colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
+ string colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS)!;
row.SetColumnError(col, colError);
}
@@ -223,7 +220,7 @@ internal void ProcessErrors(DataSet ds, XmlReader ssync)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void ProcessErrors(ArrayList dt, XmlReader ssync)
{
- DataTable table;
+ DataTable? table;
int iSsyncDepth = ssync.Depth;
ssync.Read(); // pass the before node.
@@ -234,14 +231,14 @@ internal void ProcessErrors(ArrayList dt, XmlReader ssync)
if (table == null)
throw ExceptionBuilder.DiffgramMissingSQL();
- string diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
+ string diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS)!;
- DataRow row = (DataRow)table.RowDiffId[diffId];
+ DataRow? row = (DataRow?)table.RowDiffId[diffId];
if (row == null)
{
for (int i = 0; i < dt.Count; i++)
{
- row = (DataRow)((DataTable)dt[i]).RowDiffId[diffId];
+ row = (DataRow?)((DataTable)dt[i]!).RowDiffId[diffId];
if (row != null)
{
table = row.Table;
@@ -249,9 +246,9 @@ internal void ProcessErrors(ArrayList dt, XmlReader ssync)
}
}
}
- string rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
+ string? rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
if (rowError != null)
- row.RowError = rowError;
+ row!.RowError = rowError;
int iRowDepth = ssync.Depth;
ssync.Read(); // we may be inside a column
@@ -259,11 +256,11 @@ internal void ProcessErrors(ArrayList dt, XmlReader ssync)
{
if (XmlNodeType.Element == ssync.NodeType)
{
- DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI];
+ DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI]!;
//if (col == null)
// throw exception here
- string colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
- row.SetColumnError(col, colError);
+ string? colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
+ row!.SetColumnError(col, colError);
}
ssync.Read();
}
@@ -273,17 +270,17 @@ internal void ProcessErrors(ArrayList dt, XmlReader ssync)
return;
}
- private DataTable GetTable(string tableName, string ns)
+ private DataTable? GetTable(string tableName, string ns)
{
if (_tables == null)
- return _dataSet.Tables.GetTable(tableName, ns);
+ return _dataSet!.Tables.GetTable(tableName, ns);
if (_tables.Count == 0)
- return (DataTable)_tables[0];
+ return (DataTable?)_tables[0];
for (int i = 0; i < _tables.Count; i++)
{
- DataTable dt = (DataTable)_tables[i];
+ DataTable dt = (DataTable)_tables[i]!;
if (string.Equals(dt.TableName, tableName, StringComparison.Ordinal)
&& string.Equals(dt.Namespace, ns, StringComparison.Ordinal))
return dt;
@@ -292,7 +289,7 @@ private DataTable GetTable(string tableName, string ns)
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlReader row)
+ private int ReadOldRowData(DataSet? ds, ref DataTable? table, ref int pos, XmlReader row)
{
// read table information
if (ds != null)
@@ -311,7 +308,7 @@ private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlRead
}
int iRowDepth = row.Depth;
- string value = null;
+ string? value = null;
value = row.GetAttribute(Keywords.ROWORDER, Keywords.MSDNS);
if (!string.IsNullOrEmpty(value))
@@ -376,7 +373,7 @@ private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlRead
{
string ln = XmlConvert.DecodeName(row.LocalName);
string ns = row.NamespaceURI;
- DataColumn column = table.Columns[ln, ns];
+ DataColumn? column = table.Columns[ln, ns];
if (column == null)
{
@@ -394,13 +391,13 @@ private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlRead
(row.GetAttribute(Keywords.TYPE, Keywords.XSINS) != null));
bool skipped = false;
- if (column.Table.DataSet != null && column.Table.DataSet._udtIsWrapped)
+ if (column.Table!.DataSet != null && column.Table.DataSet._udtIsWrapped)
{
row.Read(); // if UDT is wrapped, skip the wrapper
skipped = true;
}
- XmlRootAttribute xmlAttrib = null;
+ XmlRootAttribute? xmlAttrib = null;
if (!isPolymorphism && !column.ImplementsIXMLSerializable)
{ // THIS CHECK MAY BE IS WRONG think more
diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs
index f7cfd54efe8c7..1094e6ed536e9 100644
--- a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO: Enable after System.Private.Xml is annotated
-#nullable disable
-
using System.Data.Common;
using System.Xml;
using System.Xml.Schema;
@@ -44,14 +41,14 @@ internal static void SetProperties(object instance, XmlAttributeCollection attrs
if (name == "Expression" && instance is DataColumn)
continue;
- PropertyDescriptor pd = TypeDescriptor.GetProperties(instance)[name];
+ PropertyDescriptor? pd = TypeDescriptor.GetProperties(instance)[name];
if (pd != null)
{
// Standard property
Type type = pd.PropertyType;
TypeConverter converter = XMLSchema.GetConverter(type);
- object propValue;
+ object? propValue;
if (converter.CanConvertFrom(typeof(string)))
{
propValue = converter.ConvertFromInvariantString(value);
@@ -74,7 +71,7 @@ internal static void SetProperties(object instance, XmlAttributeCollection attrs
}
}// SetProperties
- internal static bool FEqualIdentity(XmlNode node, string name, string ns)
+ internal static bool FEqualIdentity(XmlNode? node, string name, string ns)
{
if (node != null && node.LocalName == name && node.NamespaceURI == ns)
return true;
@@ -135,26 +132,26 @@ public ConstraintTable(DataTable t, XmlSchemaIdentityConstraint c)
internal sealed class XSDSchema : XMLSchema
{
- private XmlSchemaSet _schemaSet;
- private XmlSchemaElement _dsElement;
- private DataSet _ds;
- private string _schemaName;
- private ArrayList _columnExpressions;
- private Hashtable _constraintNodes;
- private ArrayList _refTables;
- private ArrayList _complexTypes;
- private XmlSchemaObjectCollection _annotations;
- private XmlSchemaObjectCollection _elements;
- private Hashtable _attributes;
- private Hashtable _elementsTable;
- private Hashtable _attributeGroups;
- private Hashtable _schemaTypes;
- private Hashtable _expressions;
- private Dictionary> _tableDictionary;
-
- private Hashtable _udSimpleTypes;
-
- private Hashtable _existingSimpleTypeMap;
+ private XmlSchemaSet? _schemaSet;
+ private XmlSchemaElement? _dsElement;
+ private DataSet? _ds;
+ private string? _schemaName;
+ private ArrayList? _columnExpressions;
+ private Hashtable? _constraintNodes;
+ private ArrayList? _refTables;
+ private ArrayList? _complexTypes;
+ private XmlSchemaObjectCollection? _annotations;
+ private XmlSchemaObjectCollection? _elements;
+ private Hashtable? _attributes;
+ private Hashtable? _elementsTable;
+ private Hashtable? _attributeGroups;
+ private Hashtable? _schemaTypes;
+ private Hashtable? _expressions;
+ private Dictionary>? _tableDictionary;
+
+ private Hashtable? _udSimpleTypes;
+
+ private Hashtable? _existingSimpleTypeMap;
private bool _fromInference;
@@ -189,38 +186,38 @@ private void CollectElementsAnnotations(XmlSchema schema, ArrayList schemaList)
{
if (item is XmlSchemaAnnotation)
{
- _annotations.Add((XmlSchemaAnnotation)item);
+ _annotations!.Add((XmlSchemaAnnotation)item);
}
if (item is XmlSchemaElement)
{
XmlSchemaElement elem = (XmlSchemaElement)item;
- _elements.Add(elem);
- _elementsTable[elem.QualifiedName] = elem;
+ _elements!.Add(elem);
+ _elementsTable![elem.QualifiedName] = elem;
}
if (item is XmlSchemaAttribute)
{
XmlSchemaAttribute attr = (XmlSchemaAttribute)item;
- _attributes[attr.QualifiedName] = attr;
+ _attributes![attr.QualifiedName] = attr;
}
if (item is XmlSchemaAttributeGroup)
{
XmlSchemaAttributeGroup attr = (XmlSchemaAttributeGroup)item;
- _attributeGroups[attr.QualifiedName] = attr;
+ _attributeGroups![attr.QualifiedName] = attr;
}
if (item is XmlSchemaType)
{
- string MSDATATargetNamespace = null;
+ string? MSDATATargetNamespace = null;
if (item is XmlSchemaSimpleType)
{
MSDATATargetNamespace = XSDSchema.GetMsdataAttribute((XmlSchemaType)item, Keywords.TARGETNAMESPACE);
}
XmlSchemaType type = (XmlSchemaType)item;
- _schemaTypes[type.QualifiedName] = type;
+ _schemaTypes![type.QualifiedName] = type;
// if we have a User Defined simple type, cache it so later we may need for mapping
// meanwhile more convinient solution would be to directly use schemaTypes, but it would be more complex to handle
- XmlSchemaSimpleType xmlSimpleType = (item as XmlSchemaSimpleType);
+ XmlSchemaSimpleType? xmlSimpleType = (item as XmlSchemaSimpleType);
if (xmlSimpleType != null)
{
if (_udSimpleTypes == null)
@@ -229,9 +226,9 @@ private void CollectElementsAnnotations(XmlSchema schema, ArrayList schemaList)
}
_udSimpleTypes[type.QualifiedName.ToString()] = xmlSimpleType;
- DataColumn dc = (DataColumn)_existingSimpleTypeMap[type.QualifiedName.ToString()];
+ DataColumn? dc = (DataColumn?)_existingSimpleTypeMap![type.QualifiedName.ToString()];
// Assumption is that our simple type qualified name ihas the same output as XmlSchemaSimpleType type.QualifiedName.ToString()
- SimpleType tmpSimpleType = (dc != null) ? dc.SimpleType : null;
+ SimpleType? tmpSimpleType = (dc != null) ? dc.SimpleType : null;
if (tmpSimpleType != null)
{
@@ -239,7 +236,7 @@ private void CollectElementsAnnotations(XmlSchema schema, ArrayList schemaList)
string errorStr = tmpSimpleType.HasConflictingDefinition(tmpDataSimpleType);
if (errorStr.Length != 0)
{
- throw ExceptionBuilder.InvalidDuplicateNamedSimpleTypeDelaration(tmpDataSimpleType.SimpleTypeQualifiedName, errorStr);
+ throw ExceptionBuilder.InvalidDuplicateNamedSimpleTypeDelaration(tmpDataSimpleType.SimpleTypeQualifiedName!, errorStr);
}
}
}
@@ -265,7 +262,7 @@ internal static string QualifiedName(string name)
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- internal static void SetProperties(object instance, XmlAttribute[] attrs)
+ internal static void SetProperties(object instance, XmlAttribute[]? attrs)
{
// This is called from both XSD and XDR schemas.
// Do we realy need it in XSD ???
@@ -286,7 +283,7 @@ internal static void SetProperties(object instance, XmlAttribute[] attrs)
if (name == "DataType")
{
- DataColumn col = instance as DataColumn;
+ DataColumn? col = instance as DataColumn;
if (col != null)
{
col.DataType = DataStorage.GetType(value);
@@ -295,14 +292,14 @@ internal static void SetProperties(object instance, XmlAttribute[] attrs)
continue;
}
- PropertyDescriptor pd = TypeDescriptor.GetProperties(instance)[name];
+ PropertyDescriptor? pd = TypeDescriptor.GetProperties(instance)[name];
if (pd != null)
{
// Standard property
Type type = pd.PropertyType;
TypeConverter converter = XMLSchema.GetConverter(type);
- object propValue;
+ object? propValue;
if (converter.CanConvertFrom(typeof(string)))
{
propValue = converter.ConvertFromInvariantString(value);
@@ -326,9 +323,9 @@ internal static void SetProperties(object instance, XmlAttribute[] attrs)
}// SetProperties
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- private static void SetExtProperties(object instance, XmlAttribute[] attrs)
+ private static void SetExtProperties(object instance, XmlAttribute[]? attrs)
{
- PropertyCollection props = null;
+ PropertyCollection? props = null;
if (attrs == null)
return;
for (int i = 0; i < attrs.Length; i++)
@@ -337,7 +334,7 @@ private static void SetExtProperties(object instance, XmlAttribute[] attrs)
{
if (props == null)
{
- object val = TypeDescriptor.GetProperties(instance)["ExtendedProperties"].GetValue(instance);
+ object? val = TypeDescriptor.GetProperties(instance)["ExtendedProperties"]!.GetValue(instance);
Debug.Assert(val is PropertyCollection, "We can set values only for classes that have ExtendedProperties");
props = (PropertyCollection)val;
}
@@ -364,11 +361,11 @@ private static void SetExtProperties(object instance, XmlAttribute[] attrs)
}
}// SetExtProperties
- private void HandleColumnExpression(object instance, XmlAttribute[] attrs)
+ private void HandleColumnExpression(object instance, XmlAttribute[]? attrs)
{
if (attrs == null)
return;
- DataColumn dc = instance as DataColumn;
+ DataColumn? dc = instance as DataColumn;
Debug.Assert(dc != null, "HandleColumnExpression is supposed to be called for DataColumn");
if (dc != null)
{
@@ -381,7 +378,7 @@ private void HandleColumnExpression(object instance, XmlAttribute[] attrs)
if (_expressions == null)
_expressions = new Hashtable();
_expressions[dc] = attrs[i].Value;
- _columnExpressions.Add(dc);
+ _columnExpressions!.Add(dc);
break;
}
}
@@ -389,9 +386,9 @@ private void HandleColumnExpression(object instance, XmlAttribute[] attrs)
}
}
- internal static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
+ internal static string? GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
{
- XmlAttribute[] nodeAttributes = node.UnhandledAttributes;
+ XmlAttribute[]? nodeAttributes = node.UnhandledAttributes;
if (nodeAttributes != null)
for (int i = 0; i < nodeAttributes.Length; i++)
if (nodeAttributes[i].LocalName == ln && nodeAttributes[i].NamespaceURI == Keywords.MSDNS)
@@ -402,14 +399,14 @@ internal static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private static void SetExtProperties(object instance, XmlAttributeCollection attrs)
{
- PropertyCollection props = null;
+ PropertyCollection? props = null;
for (int i = 0; i < attrs.Count; i++)
{
if (attrs[i].NamespaceURI == Keywords.MSPROPNS)
{
if (props == null)
{
- object val = TypeDescriptor.GetProperties(instance)["ExtendedProperties"].GetValue(instance);
+ object? val = TypeDescriptor.GetProperties(instance)["ExtendedProperties"]!.GetValue(instance);
Debug.Assert(val is PropertyCollection, "We can set values only for classes that have ExtendedProperties");
props = (PropertyCollection)val;
}
@@ -423,7 +420,7 @@ private static void SetExtProperties(object instance, XmlAttributeCollection att
internal void HandleRefTableProperties(ArrayList RefTables, XmlSchemaElement element)
{
string typeName = GetInstanceName(element);
- DataTable table = _ds.Tables.GetTable(XmlConvert.DecodeName(typeName), element.QualifiedName.Namespace);
+ DataTable? table = _ds!.Tables.GetTable(XmlConvert.DecodeName(typeName), element.QualifiedName.Namespace);
Debug.Assert(table != null, "ref table should have been already created");
SetProperties(table, element.UnhandledAttributes);
@@ -441,12 +438,12 @@ internal void HandleRelation(XmlElement node, bool fNested)
string value;
bool fCreateConstraints = false; //if we have a relation,
//we do not have constraints
- DataRelationCollection rels = _ds.Relations;
+ DataRelationCollection rels = _ds!.Relations;
DataRelation relation;
DataColumn[] parentKey;
DataColumn[] childKey;
- DataTable parent;
- DataTable child;
+ DataTable? parent;
+ DataTable? child;
int keyLength;
strName = XmlConvert.DecodeName(node.GetAttribute(Keywords.NAME));
@@ -499,10 +496,10 @@ internal void HandleRelation(XmlElement node, bool fNested)
for (int i = 0; i < keyLength; i++)
{
- parentKey[i] = parent.Columns[XmlConvert.DecodeName(parentNames[i])];
+ parentKey[i] = parent.Columns[XmlConvert.DecodeName(parentNames[i])]!;
if (parentKey[i] == null)
throw ExceptionBuilder.ElementTypeNotFound(parentNames[i]);
- childKey[i] = child.Columns[XmlConvert.DecodeName(childNames[i])];
+ childKey[i] = child.Columns[XmlConvert.DecodeName(childNames[i])]!;
if (childKey[i] == null)
throw ExceptionBuilder.ElementTypeNotFound(childNames[i]);
}
@@ -512,7 +509,7 @@ internal void HandleRelation(XmlElement node, bool fNested)
_ds.Relations.Add(relation);
if (FromInference && relation.Nested)
{
- _tableDictionary[relation.ParentTable].Add(relation.ChildTable);
+ _tableDictionary![relation.ParentTable].Add(relation.ChildTable);
}
}
@@ -538,7 +535,7 @@ private bool HasAttributes(XmlSchemaObjectCollection attributes)
private bool IsDatasetParticle(XmlSchemaParticle pt)
{
- XmlSchemaObjectCollection items = GetParticleItems(pt);
+ XmlSchemaObjectCollection? items = GetParticleItems(pt);
if (items == null)
return false; // empty element, threat it as table
@@ -590,7 +587,7 @@ private int DatasetElementCount(XmlSchemaObjectCollection elements)
return nCount;
}
- private XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements)
+ private XmlSchemaElement? FindDatasetElement(XmlSchemaObjectCollection elements)
{
foreach (XmlSchemaElement XmlElement in elements)
{
@@ -603,7 +600,7 @@ private XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements)
if (!GetBooleanAttribute(node, Keywords.MSD_ISDATASET, /*default:*/ true))
return null;
- XmlSchemaComplexType ct = node.SchemaType as XmlSchemaComplexType;
+ XmlSchemaComplexType? ct = node.SchemaType as XmlSchemaComplexType;
if (ct == null)
return null;
@@ -614,7 +611,7 @@ private XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements)
if (ct.ContentModel is XmlSchemaSimpleContent)
{
- XmlSchemaAnnotated cContent = ((XmlSchemaSimpleContent)(ct.ContentModel)).Content;
+ XmlSchemaAnnotated? cContent = ((XmlSchemaSimpleContent)(ct.ContentModel)).Content;
if (cContent is XmlSchemaSimpleContentExtension)
{
XmlSchemaSimpleContentExtension ccExtension = ((XmlSchemaSimpleContentExtension)cContent);
@@ -623,14 +620,14 @@ private XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements)
}
else
{
- XmlSchemaSimpleContentRestriction ccRestriction = ((XmlSchemaSimpleContentRestriction)cContent);
+ XmlSchemaSimpleContentRestriction ccRestriction = ((XmlSchemaSimpleContentRestriction)cContent!);
if (HasAttributes(ccRestriction.Attributes))
return null;
}
}
- XmlSchemaParticle particle = GetParticle(ct);
+ XmlSchemaParticle? particle = GetParticle(ct);
if (particle != null)
{
if (!IsDatasetParticle(particle))
@@ -682,7 +679,7 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
_schemaName = "NewDataSet";
}
ds.DataSetName = XmlConvert.DecodeName(_schemaName);
- string ns = schemaRoot.TargetNamespace;
+ string? ns = schemaRoot.TargetNamespace;
if (ds._namespaceURI == null || ds._namespaceURI.Length == 0)
{// set just one time, for backward compatibility
ds._namespaceURI = (ns == null) ? string.Empty : ns; // see fx\Data\XDO\ReadXml\SchemaM2.xml for more info
@@ -753,15 +750,15 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
throw ExceptionBuilder.TooManyIsDataSetAttributesInSchema();
}
- XmlSchemaComplexType ct = (XmlSchemaComplexType)FindTypeNode(_dsElement);
+ XmlSchemaComplexType ct = (XmlSchemaComplexType)FindTypeNode(_dsElement!)!;
if (ct.Particle != null)
{
- XmlSchemaObjectCollection items = GetParticleItems(ct.Particle);
+ XmlSchemaObjectCollection? items = GetParticleItems(ct.Particle);
if (items != null)
{
foreach (XmlSchemaAnnotated el in items)
{
- XmlSchemaElement sel = el as XmlSchemaElement;
+ XmlSchemaElement? sel = el as XmlSchemaElement;
if (null != sel)
{
if (sel.RefName.Name.Length != 0)
@@ -812,11 +809,11 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
//just add Expressions, at this point and if ColumnExpressions.Count > 0, this.expressions should not be null
for (int i = 0; i < _columnExpressions.Count; i++)
{
- DataColumn dc = ((DataColumn)(_columnExpressions[i]));
- dc.Expression = (string)_expressions[dc];
+ DataColumn dc = ((DataColumn)(_columnExpressions[i])!);
+ dc.Expression = (string)_expressions![dc]!;
}
- foreach (DataTable dt in ds.Tables)
+ foreach (DataTable dt in ds!.Tables)
{
if (dt.NestedParentRelations.Length == 0 && dt.Namespace == ds.Namespace)
{
@@ -834,14 +831,14 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
}
}
- DataTable tmpTable = ds.Tables[ds.DataSetName, ds.Namespace];
+ DataTable? tmpTable = ds.Tables[ds.DataSetName, ds.Namespace];
if (tmpTable != null) // this fix is done to support round-trip problem in case if there is one table with same name and NS
tmpTable._fNestedInDataset = true;
// this fix is for backward compatability with old inference engine
if (FromInference && ds.Tables.Count == 0 && string.Equals(ds.DataSetName, "NewDataSet", StringComparison.Ordinal))
- ds.DataSetName = XmlConvert.DecodeName(((XmlSchemaElement)_elements[0]).Name);
+ ds.DataSetName = XmlConvert.DecodeName(((XmlSchemaElement)_elements[0]).Name)!;
ds._fIsSchemaLoading = false; //reactivate column computations
@@ -872,14 +869,14 @@ private void HandleRelations(XmlSchemaAnnotation ann, bool fNested)
foreach (object __items in ann.Items)
if (__items is XmlSchemaAppInfo)
{
- XmlNode[] relations = ((XmlSchemaAppInfo)__items).Markup;
+ XmlNode[] relations = ((XmlSchemaAppInfo)__items).Markup!;
for (int i = 0; i < relations.Length; i++)
if (FEqualIdentity(relations[i], Keywords.MSD_RELATION, Keywords.MSDNS))
HandleRelation((XmlElement)relations[i], fNested);
}
}
- internal XmlSchemaObjectCollection GetParticleItems(XmlSchemaParticle pt)
+ internal XmlSchemaObjectCollection? GetParticleItems(XmlSchemaParticle? pt)
{
if (pt is XmlSchemaSequence)
return ((XmlSchemaSequence)pt).Items;
@@ -905,21 +902,21 @@ internal XmlSchemaObjectCollection GetParticleItems(XmlSchemaParticle pt)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, bool isBase)
{
- XmlSchemaObjectCollection items = GetParticleItems(pt);
+ XmlSchemaObjectCollection? items = GetParticleItems(pt);
if (items == null)
return;
foreach (XmlSchemaAnnotated item in items)
{
- XmlSchemaElement el = item as XmlSchemaElement;
+ XmlSchemaElement? el = item as XmlSchemaElement;
if (el != null)
{
if (FromInference && pt is XmlSchemaChoice && pt.MaxOccurs > decimal.One && (el.SchemaType is XmlSchemaComplexType))
el.MaxOccurs = pt.MaxOccurs;
- DataTable child = null;
+ DataTable? child = null;
// to decide if element is our table, we need to match both name and ns
// 286043 - SQL BU Defect Tracking
if (((el.Name == null) && (el.RefName.Name == table.EncodedTableName && el.RefName.Namespace == table.Namespace)) ||
@@ -953,7 +950,7 @@ internal void HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList ta
}
else
{
- DataRelation relation = null;
+ DataRelation? relation = null;
if (el.Annotation != null)
HandleRelations(el.Annotation, true);
@@ -1002,8 +999,8 @@ internal void HandleAttributes(XmlSchemaObjectCollection attributes, DataTable t
}
else
{ // XmlSchemaAttributeGroupRef
- XmlSchemaAttributeGroupRef groupRef = so as XmlSchemaAttributeGroupRef;
- XmlSchemaAttributeGroup schemaGroup = _attributeGroups[groupRef.RefName] as XmlSchemaAttributeGroup;
+ XmlSchemaAttributeGroupRef? groupRef = so as XmlSchemaAttributeGroupRef;
+ XmlSchemaAttributeGroup? schemaGroup = _attributeGroups![groupRef!.RefName] as XmlSchemaAttributeGroup;
if (schemaGroup != null)
{
HandleAttributeGroup(schemaGroup, table, isBase);
@@ -1024,14 +1021,14 @@ private void HandleAttributeGroup(XmlSchemaAttributeGroup attributeGroup, DataTa
else
{ // XmlSchemaAttributeGroupRef
XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)obj;
- XmlSchemaAttributeGroup attributeGroupResolved;
+ XmlSchemaAttributeGroup? attributeGroupResolved;
if (attributeGroup.RedefinedAttributeGroup != null && attributeGroupRef.RefName == new XmlQualifiedName(attributeGroup.Name, attributeGroupRef.RefName.Namespace))
{
attributeGroupResolved = attributeGroup.RedefinedAttributeGroup;
}
else
{
- attributeGroupResolved = (XmlSchemaAttributeGroup)_attributeGroups[attributeGroupRef.RefName];
+ attributeGroupResolved = (XmlSchemaAttributeGroup?)_attributeGroups![attributeGroupRef.RefName];
}
if (attributeGroupResolved != null)
{
@@ -1044,8 +1041,8 @@ private void HandleAttributeGroup(XmlSchemaAttributeGroup attributeGroup, DataTa
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, bool isNillable)
{
- if (_complexTypes.Contains(ct))
- throw ExceptionBuilder.CircularComplexType(ct.Name);
+ if (_complexTypes!.Contains(ct))
+ throw ExceptionBuilder.CircularComplexType(ct.Name!);
bool isBase = false;
_complexTypes.Add(ct);
@@ -1062,7 +1059,7 @@ internal void HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayL
if (ct.ContentModel is XmlSchemaComplexContent)
{
- XmlSchemaAnnotated cContent = ((XmlSchemaComplexContent)(ct.ContentModel)).Content;
+ XmlSchemaAnnotated? cContent = ((XmlSchemaComplexContent)(ct.ContentModel)).Content;
if (cContent is XmlSchemaComplexContentExtension)
{
XmlSchemaComplexContentExtension ccExtension = ((XmlSchemaComplexContentExtension)cContent);
@@ -1106,7 +1103,7 @@ internal void HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayL
else
{
Debug.Assert(ct.ContentModel is XmlSchemaSimpleContent, "expected simpleContent or complexContent");
- XmlSchemaAnnotated cContent = ((XmlSchemaSimpleContent)(ct.ContentModel)).Content;
+ XmlSchemaAnnotated cContent = ((XmlSchemaSimpleContent)(ct.ContentModel)).Content!;
if (cContent is XmlSchemaSimpleContentExtension)
{
XmlSchemaSimpleContentExtension ccExtension = ((XmlSchemaSimpleContentExtension)cContent);
@@ -1147,13 +1144,13 @@ internal void HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayL
_complexTypes.Remove(ct);
}
- internal XmlSchemaParticle GetParticle(XmlSchemaComplexType ct)
+ internal XmlSchemaParticle? GetParticle(XmlSchemaComplexType ct)
{
if (ct.ContentModel != null)
{
if (ct.ContentModel is XmlSchemaComplexContent)
{
- XmlSchemaAnnotated cContent = ((XmlSchemaComplexContent)(ct.ContentModel)).Content;
+ XmlSchemaAnnotated cContent = ((XmlSchemaComplexContent)(ct.ContentModel)).Content!;
if (cContent is XmlSchemaComplexContentExtension)
{
return ((XmlSchemaComplexContentExtension)cContent).Particle;
@@ -1191,7 +1188,7 @@ internal DataColumn FindField(DataTable table, string field)
colName = split[split.Length - 1];
colName = XmlConvert.DecodeName(colName);
- DataColumn col = table.Columns[colName];
+ DataColumn? col = table.Columns[colName];
if (col == null)
throw ExceptionBuilder.InvalidField(field);
@@ -1209,7 +1206,7 @@ internal DataColumn[] BuildKey(XmlSchemaIdentityConstraint keyNode, DataTable ta
foreach (XmlSchemaXPath node in keyNode.Fields)
{
- keyColumns.Add(FindField(table, node.XPath));
+ keyColumns.Add(FindField(table, node.XPath!));
}
DataColumn[] key = new DataColumn[keyColumns.Count];
@@ -1220,7 +1217,7 @@ internal DataColumn[] BuildKey(XmlSchemaIdentityConstraint keyNode, DataTable ta
internal bool GetBooleanAttribute(XmlSchemaAnnotated element, string attrName, bool defVal)
{
- string value = GetMsdataAttribute(element, attrName);
+ string? value = GetMsdataAttribute(element, attrName);
if (value == null || value.Length == 0)
{
return defVal;
@@ -1239,7 +1236,7 @@ internal bool GetBooleanAttribute(XmlSchemaAnnotated element, string attrName, b
internal string GetStringAttribute(XmlSchemaAnnotated element, string attrName, string defVal)
{
- string value = GetMsdataAttribute(element, attrName);
+ string? value = GetMsdataAttribute(element, attrName);
if (value == null || value.Length == 0)
{
return defVal;
@@ -1258,7 +1255,7 @@ internal string GetStringAttribute(XmlSchemaAnnotated element, string attrName,
*/
- internal static AcceptRejectRule TranslateAcceptRejectRule(string strRule)
+ internal static AcceptRejectRule TranslateAcceptRejectRule(string? strRule)
{
if (strRule == "Cascade")
return AcceptRejectRule.Cascade;
@@ -1286,16 +1283,16 @@ internal static Rule TranslateRule(string strRule)
internal void HandleKeyref(XmlSchemaKeyref keyref)
{
string refer = XmlConvert.DecodeName(keyref.Refer.Name); // check here!!!
- string name = XmlConvert.DecodeName(keyref.Name);
+ string name = XmlConvert.DecodeName(keyref.Name)!;
name = GetStringAttribute(keyref, "ConstraintName", /*default:*/ name);
// we do not process key defined outside the current node
string tableName = GetTableName(keyref);
- string tableNs = GetMsdataAttribute(keyref, Keywords.MSD_TABLENS);
+ string? tableNs = GetMsdataAttribute(keyref, Keywords.MSD_TABLENS);
- DataTable table = _ds.Tables.GetTableSmart(tableName, tableNs);
+ DataTable? table = _ds!.Tables.GetTableSmart(tableName, tableNs);
if (table == null)
return;
@@ -1303,7 +1300,7 @@ internal void HandleKeyref(XmlSchemaKeyref keyref)
if (refer == null || refer.Length == 0)
throw ExceptionBuilder.MissingRefer(name);
- ConstraintTable key = (ConstraintTable)_constraintNodes[refer];
+ ConstraintTable? key = (ConstraintTable?)_constraintNodes![refer];
if (key == null)
{
@@ -1313,57 +1310,57 @@ internal void HandleKeyref(XmlSchemaKeyref keyref)
DataColumn[] pKey = BuildKey(key.constraint, key.table);
DataColumn[] fKey = BuildKey(keyref, table);
- ForeignKeyConstraint fkc = null;
+ ForeignKeyConstraint? fkc = null;
if (GetBooleanAttribute(keyref, Keywords.MSD_CONSTRAINTONLY, /*default:*/ false))
{
- int iExisting = fKey[0].Table.Constraints.InternalIndexOf(name);
+ int iExisting = fKey[0].Table!.Constraints.InternalIndexOf(name);
if (iExisting > -1)
{
- if (fKey[0].Table.Constraints[iExisting].ConstraintName != name)
+ if (fKey[0].Table!.Constraints[iExisting].ConstraintName != name)
iExisting = -1;
}
if (iExisting < 0)
{
fkc = new ForeignKeyConstraint(name, pKey, fKey);
- fKey[0].Table.Constraints.Add(fkc);
+ fKey[0].Table!.Constraints.Add(fkc);
}
}
else
{
- string relName = XmlConvert.DecodeName(GetStringAttribute(keyref, Keywords.MSD_RELATIONNAME, keyref.Name));
+ string relName = XmlConvert.DecodeName(GetStringAttribute(keyref, Keywords.MSD_RELATIONNAME, keyref.Name!));
if (relName == null || relName.Length == 0)
relName = name;
- int iExisting = fKey[0].Table.DataSet.Relations.InternalIndexOf(relName);
+ int iExisting = fKey[0].Table!.DataSet!.Relations.InternalIndexOf(relName);
if (iExisting > -1)
{
- if (fKey[0].Table.DataSet.Relations[iExisting].RelationName != relName)
+ if (fKey[0].Table!.DataSet!.Relations[iExisting].RelationName != relName)
iExisting = -1;
}
- DataRelation relation = null;
+ DataRelation? relation = null;
if (iExisting < 0)
{
relation = new DataRelation(relName, pKey, fKey);
SetExtProperties(relation, keyref.UnhandledAttributes);
- pKey[0].Table.DataSet.Relations.Add(relation);
+ pKey[0].Table!.DataSet!.Relations.Add(relation);
if (FromInference && relation.Nested)
{
- if (_tableDictionary.ContainsKey(relation.ParentTable))
+ if (_tableDictionary!.ContainsKey(relation.ParentTable))
{
_tableDictionary[relation.ParentTable].Add(relation.ChildTable);
}
}
- fkc = relation.ChildKeyConstraint;
+ fkc = relation.ChildKeyConstraint!;
fkc.ConstraintName = name;
}
else
{
- relation = fKey[0].Table.DataSet.Relations[iExisting];
+ relation = fKey[0].Table!.DataSet!.Relations[iExisting];
}
if (GetBooleanAttribute(keyref, Keywords.MSD_ISNESTED, /*default:*/ false))
{
@@ -1371,9 +1368,9 @@ internal void HandleKeyref(XmlSchemaKeyref keyref)
}
}
- string acceptRejectRule = GetMsdataAttribute(keyref, Keywords.MSD_ACCEPTREJECTRULE);
- string updateRule = GetMsdataAttribute(keyref, Keywords.MSD_UPDATERULE);
- string deleteRule = GetMsdataAttribute(keyref, Keywords.MSD_DELETERULE);
+ string? acceptRejectRule = GetMsdataAttribute(keyref, Keywords.MSD_ACCEPTREJECTRULE);
+ string? updateRule = GetMsdataAttribute(keyref, Keywords.MSD_UPDATERULE);
+ string? deleteRule = GetMsdataAttribute(keyref, Keywords.MSD_DELETERULE);
if (fkc != null)
{
@@ -1393,20 +1390,20 @@ internal void HandleKeyref(XmlSchemaKeyref keyref)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleConstraint(XmlSchemaIdentityConstraint keyNode)
{
- string name = null;
+ string? name = null;
name = XmlConvert.DecodeName(keyNode.Name);
if (name == null || name.Length == 0)
throw ExceptionBuilder.MissingAttribute(Keywords.NAME);
- if (_constraintNodes.ContainsKey(name))
+ if (_constraintNodes!.ContainsKey(name))
throw ExceptionBuilder.DuplicateConstraintRead(name);
// we do not process key defined outside the current node
string tableName = GetTableName(keyNode);
- string tableNs = GetMsdataAttribute(keyNode, Keywords.MSD_TABLENS);
+ string? tableNs = GetMsdataAttribute(keyNode, Keywords.MSD_TABLENS);
- DataTable table = _ds.Tables.GetTableSmart(tableName, tableNs);
+ DataTable? table = _ds!.Tables.GetTableSmart(tableName, tableNs);
if (table == null)
return;
@@ -1422,19 +1419,19 @@ internal void HandleConstraint(XmlSchemaIdentityConstraint keyNode)
if (0 < key.Length)
{
- UniqueConstraint found = (UniqueConstraint)key[0].Table.Constraints.FindConstraint(new UniqueConstraint(name, key));
+ UniqueConstraint? found = (UniqueConstraint?)key[0].Table!.Constraints.FindConstraint(new UniqueConstraint(name, key));
if (found == null)
{
- key[0].Table.Constraints.Add(name, key, fPrimaryKey);
- SetExtProperties(key[0].Table.Constraints[name], keyNode.UnhandledAttributes);
+ key[0].Table!.Constraints.Add(name, key, fPrimaryKey);
+ SetExtProperties(key[0].Table!.Constraints[name]!, keyNode.UnhandledAttributes);
}
else
{
key = found.ColumnsReference;
SetExtProperties(found, keyNode.UnhandledAttributes);
if (fPrimaryKey)
- key[0].Table.PrimaryKey = key;
+ key[0].Table!.PrimaryKey = key;
}
if (keyNode is XmlSchemaKey)
{
@@ -1447,12 +1444,12 @@ internal void HandleConstraint(XmlSchemaIdentityConstraint keyNode)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal DataTable InstantiateSimpleTable(XmlSchemaElement node)
{
- DataTable table;
+ DataTable? table;
string typeName = XmlConvert.DecodeName(GetInstanceName(node));
string _TableUri;
_TableUri = node.QualifiedName.Namespace;
- table = _ds.Tables.GetTable(typeName, _TableUri);
+ table = _ds!.Tables.GetTable(typeName, _TableUri);
if (!FromInference && table != null)
{
@@ -1473,7 +1470,7 @@ internal DataTable InstantiateSimpleTable(XmlSchemaElement node)
}
else
{
- string prefix = GetPrefix(_TableUri);
+ string? prefix = GetPrefix(_TableUri);
if (prefix != null)
table.Prefix = prefix;
}
@@ -1483,10 +1480,10 @@ internal DataTable InstantiateSimpleTable(XmlSchemaElement node)
}
- XmlSchemaComplexType ct = node.SchemaType as XmlSchemaComplexType;
+ XmlSchemaComplexType? ct = node.SchemaType as XmlSchemaComplexType;
// We assume node.ElementSchemaType.BaseSchemaType to be null for
// and not null for
- bool isSimpleContent = ((node.ElementSchemaType.BaseXmlSchemaType != null) || (ct != null && ct.ContentModel is XmlSchemaSimpleContent));
+ bool isSimpleContent = ((node.ElementSchemaType!.BaseXmlSchemaType != null) || (ct != null && ct.ContentModel is XmlSchemaSimpleContent));
if (!FromInference || (isSimpleContent && table.Columns.Count == 0))
{// for inference backward compatability
@@ -1514,7 +1511,7 @@ internal DataTable InstantiateSimpleTable(XmlSchemaElement node)
_ds.Tables.Add(table);
if (FromInference)
{
- _tableDictionary.Add(table, new List());
+ _tableDictionary!.Add(table, new List());
}
}
@@ -1538,7 +1535,7 @@ internal DataTable InstantiateSimpleTable(XmlSchemaElement node)
internal string GetInstanceName(XmlSchemaAnnotated node)
{
- string instanceName = null;
+ string? instanceName = null;
Debug.Assert((node is XmlSchemaElement) || (node is XmlSchemaAttribute), "GetInstanceName should only be called on attribute or elements");
@@ -1562,7 +1559,7 @@ internal string GetInstanceName(XmlSchemaAnnotated node)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, bool isRef)
{
- DataTable table;
+ DataTable? table;
string typeName = GetInstanceName(node);
ArrayList tableChildren = new ArrayList();
@@ -1570,7 +1567,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
_TableUri = node.QualifiedName.Namespace;
- table = _ds.Tables.GetTable(XmlConvert.DecodeName(typeName), _TableUri);
+ table = _ds!.Tables.GetTable(XmlConvert.DecodeName(typeName), _TableUri);
// TOD: Do not do this fix
// if (table == null && node.RefName.IsEmpty && !IsTopLevelElement(node) && _TableUri != null && _TableUri.Length > 0) {
// _TableUri = null; // it means form="qualified", so child element inherits namespace. amirhmy
@@ -1587,7 +1584,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
}
if (isRef)
- _refTables.Add(_TableUri + ":" + typeName);
+ _refTables!.Add(_TableUri + ":" + typeName);
table = new DataTable(XmlConvert.DecodeName(typeName));
table.TypeName = node.SchemaTypeName;
@@ -1596,7 +1593,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
table.Namespace = GetStringAttribute(node, "targetNamespace", _TableUri);
//table.Prefix = node.Prefix;
- string value = GetStringAttribute(typeNode, Keywords.MSD_CASESENSITIVE, "");
+ string? value = GetStringAttribute(typeNode, Keywords.MSD_CASESENSITIVE, "");
if (value.Length == 0)
{
value = GetStringAttribute(node, Keywords.MSD_CASESENSITIVE, "");
@@ -1632,7 +1629,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
}
else
{
- string prefix = GetPrefix(_TableUri);
+ string? prefix = GetPrefix(_TableUri);
if (prefix != null)
table.Prefix = prefix;
}
@@ -1640,13 +1637,13 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
_ds.Tables.Add(table);
if (FromInference)
{
- _tableDictionary.Add(table, new List());
+ _tableDictionary!.Add(table, new List());
}
}
- HandleComplexType(typeNode, table, tableChildren, node.IsNillable);
+ HandleComplexType(typeNode, table!, tableChildren, node.IsNillable);
- for (int i = 0; i < table.Columns.Count; i++)
+ for (int i = 0; i < table!.Columns.Count; i++)
table.Columns[i].SetOrdinalInternal(i);
/*
@@ -1691,7 +1688,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
{
foreach (XmlSchemaIdentityConstraint key in _dsElement.Constraints)
{
- XmlSchemaKeyref keyref = key as XmlSchemaKeyref;
+ XmlSchemaKeyref? keyref = key as XmlSchemaKeyref;
if (keyref == null)
continue;
@@ -1700,7 +1697,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
continue;
if (GetTableName(keyref) == _tableChild.TableName)
{
- if (_tableChild.DataSet.Tables.InternalIndexOf(_tableChild.TableName) < -1)
+ if (_tableChild.DataSet!.Tables.InternalIndexOf(_tableChild.TableName) < -1)
{ // if we have multiple tables with the same name
if (GetTableNamespace(keyref) == _tableChild.Namespace)
{
@@ -1715,7 +1712,7 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
}
}
- DataRelation relation = null;
+ DataRelation? relation = null;
DataRelationCollection childRelations = table.ChildRelations;
for (int j = 0; j < childRelations.Count; j++)
@@ -1762,17 +1759,17 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType
// setup relationship between parent and this table
relation = new DataRelation(table.TableName + "_" + _tableChild.TableName, parentKey, childKey, true);
relation.Nested = true;
- _tableChild.DataSet.Relations.Add(relation);
+ _tableChild.DataSet!.Relations.Add(relation);
if (FromInference && relation.Nested)
{
- if (_tableDictionary.ContainsKey(relation.ParentTable))
+ if (_tableDictionary!.ContainsKey(relation.ParentTable))
{
_tableDictionary[relation.ParentTable].Add(relation.ChildTable);
}
}
}
- return (table);
+ return table;
}
private sealed class NameType : IComparable
@@ -1785,7 +1782,7 @@ public NameType(string n, [DynamicallyAccessedMembers(DynamicallyAccessedMemberT
name = n;
type = t;
}
- public int CompareTo(object obj) { return string.Compare(name, (string)obj, StringComparison.Ordinal); }
+ public int CompareTo(object? obj) { return string.Compare(name, (string?)obj, StringComparison.Ordinal); }
};
public static Type XsdtoClr(string xsdTypeName)
@@ -1878,7 +1875,7 @@ private Type ParseDataType(string dt)
{
if (_udSimpleTypes != null)
{
- XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)_udSimpleTypes[dt];
+ XmlSchemaSimpleType? simpleType = (XmlSchemaSimpleType?)_udSimpleTypes[dt];
if (simpleType == null)
{ // it is not named simple type, it is not XSD type, it should be unsupported type like xs:token
throw ExceptionBuilder.UndefinedDatatype(dt);
@@ -1889,7 +1886,7 @@ private Type ParseDataType(string dt)
rootType = rootType.BaseSimpleType;
}
- return ParseDataType(rootType.BaseType);
+ return ParseDataType(rootType.BaseType!);
}
}
NameType nt = FindNameType(dt);
@@ -1927,39 +1924,39 @@ internal static bool IsXsdType(string name)
}
- internal XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node)
+ internal XmlSchemaAnnotated? FindTypeNode(XmlSchemaAnnotated node)
{
// this function is returning null
// if the typeNode for node is in the XSD namespace.
- XmlSchemaAttribute attr = node as XmlSchemaAttribute;
- XmlSchemaElement el = node as XmlSchemaElement;
+ XmlSchemaAttribute? attr = node as XmlSchemaAttribute;
+ XmlSchemaElement? el = node as XmlSchemaElement;
bool isAttr = false;
if (attr != null)
{
isAttr = true;
}
- string _type = isAttr ? attr.SchemaTypeName.Name : el.SchemaTypeName.Name;
- string _typeNs = isAttr ? attr.SchemaTypeName.Namespace : el.SchemaTypeName.Namespace;
+ string _type = isAttr ? attr!.SchemaTypeName.Name : el!.SchemaTypeName.Name;
+ string _typeNs = isAttr ? attr!.SchemaTypeName.Namespace : el!.SchemaTypeName.Namespace;
if (_typeNs == Keywords.XSDNS)
return null;
- XmlSchemaAnnotated typeNode;
+ XmlSchemaAnnotated? typeNode;
if (_type == null || _type.Length == 0)
{
- _type = isAttr ? attr.RefName.Name : el.RefName.Name;
+ _type = isAttr ? attr!.RefName.Name : el!.RefName.Name;
if (_type == null || _type.Length == 0)
- typeNode = isAttr ? attr.SchemaType : el.SchemaType;
+ typeNode = isAttr ? attr!.SchemaType : el!.SchemaType;
else
- typeNode = isAttr ? FindTypeNode((XmlSchemaAnnotated)_attributes[attr.RefName]) : FindTypeNode((XmlSchemaAnnotated)_elementsTable[el.RefName]);
+ typeNode = isAttr ? FindTypeNode((XmlSchemaAnnotated)_attributes![attr!.RefName]!) : FindTypeNode((XmlSchemaAnnotated)_elementsTable![el!.RefName]!);
}
else
- typeNode = (XmlSchemaAnnotated)_schemaTypes[isAttr ? ((XmlSchemaAttribute)node).SchemaTypeName : ((XmlSchemaElement)node).SchemaTypeName];
+ typeNode = (XmlSchemaAnnotated?)_schemaTypes![isAttr ? ((XmlSchemaAttribute)node).SchemaTypeName : ((XmlSchemaElement)node).SchemaTypeName];
return typeNode;
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode, string strType, DataTable table, bool isBase, XmlAttribute[] attrs, bool isNillable)
+ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode, string strType, DataTable table, bool isBase, XmlAttribute[]? attrs, bool isNillable)
{
// disallow multiple simple content columns for the table
if (FromInference && table.XmlText != null)
@@ -1967,8 +1964,8 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
return;
}
- Type type = null;
- SimpleType xsdType = null;
+ Type? type = null;
+ SimpleType? xsdType = null;
// if (typeNode.QualifiedName.Namespace != Keywords.XSDNS) { // this means UDSimpleType
if (typeNode.QualifiedName.Name != null && typeNode.QualifiedName.Name.Length != 0 && typeNode.QualifiedName.Namespace != Keywords.XSDNS)
@@ -1979,7 +1976,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
}
else
{// previous code V 1.1
- XmlSchemaSimpleType ancestor = typeNode.BaseXmlSchemaType as XmlSchemaSimpleType;
+ XmlSchemaSimpleType? ancestor = typeNode.BaseXmlSchemaType as XmlSchemaSimpleType;
if ((ancestor != null) && (ancestor.QualifiedName.Namespace != Keywords.XSDNS))
{
xsdType = new SimpleType(typeNode);
@@ -1989,8 +1986,8 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
{
rootType = rootType.BaseSimpleType;
}
- type = ParseDataType(rootType.BaseType);
- strType = xsdType.Name;
+ type = ParseDataType(rootType.BaseType!);
+ strType = xsdType.Name!;
}
else
{
@@ -2018,7 +2015,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
bool isToAdd = true;
if ((!isBase) && (table.Columns.Contains(columnName, true)))
{
- column = table.Columns[columnName];
+ column = table.Columns[columnName]!;
isToAdd = false;
}
else
@@ -2031,7 +2028,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
SetExtProperties(column, attrs);
string tmp = (-1).ToString(CultureInfo.CurrentCulture);
- string defValue = null;
+ string? defValue = null;
//try to see if attributes contain allownull
column.AllowDBNull = isNillable;
@@ -2053,7 +2050,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
if ((column.Expression != null) && (column.Expression.Length != 0))
{
- _columnExpressions.Add(column);
+ _columnExpressions!.Add(column);
}
// Update XSD type to point to simple types actual namespace instead of normalized default namespace in case of remoting
@@ -2096,7 +2093,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode,
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- internal void HandleSimpleContentColumn(string strType, DataTable table, bool isBase, XmlAttribute[] attrs, bool isNillable)
+ internal void HandleSimpleContentColumn(string strType, DataTable table, bool isBase, XmlAttribute[]? attrs, bool isNillable)
{
// for Named Simple type support : We should not recieved anything here other than string.
// there can not be typed simple content
@@ -2104,7 +2101,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is
if (FromInference && table.XmlText != null) // backward compatability for inference
return;
- Type type = null;
+ Type? type = null;
if (strType == null)
{
return;
@@ -2131,7 +2128,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is
if ((!isBase) && (table.Columns.Contains(columnName, true)))
{
- column = table.Columns[columnName];
+ column = table.Columns[columnName]!;
isToAdd = false;
}
else
@@ -2144,7 +2141,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is
SetExtProperties(column, attrs);
string tmp = (-1).ToString(CultureInfo.CurrentCulture);
- string defValue = null;
+ string? defValue = null;
//try to see if attributes contain allownull
column.AllowDBNull = isNillable;
@@ -2166,7 +2163,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is
if ((column.Expression != null) && (column.Expression.Length != 0))
{
- _columnExpressions.Add(column);
+ _columnExpressions!.Add(column);
}
column.XmlDataType = strType;
@@ -2199,13 +2196,13 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table, bool isBase)
{
- Type type = null;
- XmlSchemaAttribute attr = attrib.Name != null ? attrib : (XmlSchemaAttribute)_attributes[attrib.RefName];
+ Type? type = null;
+ XmlSchemaAttribute? attr = attrib.Name != null ? attrib : (XmlSchemaAttribute)_attributes![attrib.RefName]!;
- XmlSchemaAnnotated typeNode = FindTypeNode(attr);
- string strType = null;
- SimpleType xsdType = null;
+ XmlSchemaAnnotated? typeNode = FindTypeNode(attr);
+ string? strType = null;
+ SimpleType? xsdType = null;
if (typeNode == null)
{
@@ -2225,7 +2222,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
}
else if (typeNode is XmlSchemaSimpleType)
{
- XmlSchemaSimpleType node = typeNode as XmlSchemaSimpleType;
+ XmlSchemaSimpleType node = (typeNode as XmlSchemaSimpleType)!;
xsdType = new SimpleType(node);
if (node.QualifiedName.Name != null && node.QualifiedName.Name.Length != 0 && node.QualifiedName.Namespace != Keywords.XSDNS)
{
@@ -2235,7 +2232,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
}
else
{
- type = ParseDataType(xsdType.BaseType);
+ type = ParseDataType(xsdType.BaseType!);
strType = xsdType.Name;
if (xsdType.Length == 1 && type == typeof(string))
{
@@ -2262,7 +2259,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
if ((!isBase || FromInference) && (table.Columns.Contains(columnName, true)))
{
- column = table.Columns[columnName];
+ column = table.Columns[columnName]!;
isToAdd = false;
if (FromInference)
@@ -2294,12 +2291,12 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
if ((column.Expression != null) && (column.Expression.Length != 0))
{
- _columnExpressions.Add(column);
+ _columnExpressions!.Add(column);
}
if (xsdType != null && xsdType.Name != null && xsdType.Name.Length > 0)
{
- if (XSDSchema.GetMsdataAttribute(typeNode, Keywords.TARGETNAMESPACE) != null)
+ if (XSDSchema.GetMsdataAttribute(typeNode!, Keywords.TARGETNAMESPACE) != null)
{
column.XmlDataType = xsdType.SimpleTypeQualifiedName;
}
@@ -2330,7 +2327,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
column.ColumnMapping = MappingType.Hidden;
column.AllowDBNull = GetBooleanAttribute(attr, Keywords.MSD_ALLOWDBNULL, true);
- string defValue = GetMsdataAttribute(attr, Keywords.MSD_DEFAULTVALUE);
+ string? defValue = GetMsdataAttribute(attr, Keywords.MSD_DEFAULTVALUE);
if (defValue != null)
try
{
@@ -2344,7 +2341,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
// XDR March change
- string strDefault = (attrib.Use == XmlSchemaUse.Required) ? GetMsdataAttribute(attr, Keywords.MSD_DEFAULTVALUE) : attr.DefaultValue;
+ string? strDefault = (attrib.Use == XmlSchemaUse.Required) ? GetMsdataAttribute(attr, Keywords.MSD_DEFAULTVALUE) : attr.DefaultValue;
if ((attr.Use == XmlSchemaUse.Optional) && (strDefault == null))
strDefault = attr.FixedValue;
@@ -2362,15 +2359,15 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table,
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool isBase)
{
- Type type = null;
- XmlSchemaElement el = elem.Name != null ? elem : (XmlSchemaElement)_elementsTable[elem.RefName];
+ Type? type = null;
+ XmlSchemaElement? el = elem.Name != null ? elem : (XmlSchemaElement?)_elementsTable![elem.RefName];
if (el == null) // it's possible due to some XSD compiler optimizations
return; // do nothing
- XmlSchemaAnnotated typeNode = FindTypeNode(el);
- string strType = null;
- SimpleType xsdType = null;
+ XmlSchemaAnnotated? typeNode = FindTypeNode(el);
+ string? strType = null;
+ SimpleType? xsdType = null;
if (typeNode == null)
{
@@ -2387,11 +2384,11 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
}
else if (typeNode is XmlSchemaSimpleType)
{
- XmlSchemaSimpleType simpleTypeNode = typeNode as XmlSchemaSimpleType;
- xsdType = new SimpleType(simpleTypeNode);
+ XmlSchemaSimpleType? simpleTypeNode = typeNode as XmlSchemaSimpleType;
+ xsdType = new SimpleType(simpleTypeNode!);
// ((XmlSchemaSimpleType)typeNode).Name != null && ((XmlSchemaSimpleType)typeNode).Name.Length != 0 check is for annonymos simple type,
// it should be user defined Named simple type
- if (((XmlSchemaSimpleType)typeNode).Name != null && ((XmlSchemaSimpleType)typeNode).Name.Length != 0 && ((XmlSchemaSimpleType)typeNode).QualifiedName.Namespace != Keywords.XSDNS)
+ if (((XmlSchemaSimpleType)typeNode).Name != null && ((XmlSchemaSimpleType)typeNode).Name!.Length != 0 && ((XmlSchemaSimpleType)typeNode).QualifiedName.Namespace != Keywords.XSDNS)
{
strType = ((XmlSchemaSimpleType)typeNode).QualifiedName.ToString(); // use qualifed name
type = ParseDataType(strType);
@@ -2399,17 +2396,17 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
else
{
simpleTypeNode = (xsdType.XmlBaseType != null && xsdType.XmlBaseType.Namespace != Keywords.XSDNS) ?
- _schemaTypes[xsdType.XmlBaseType] as XmlSchemaSimpleType :
+ _schemaTypes![xsdType.XmlBaseType] as XmlSchemaSimpleType :
null;
while (simpleTypeNode != null)
{
xsdType.LoadTypeValues(simpleTypeNode);
simpleTypeNode = (xsdType.XmlBaseType != null && xsdType.XmlBaseType.Namespace != Keywords.XSDNS) ?
- _schemaTypes[xsdType.XmlBaseType] as XmlSchemaSimpleType :
+ _schemaTypes![xsdType.XmlBaseType] as XmlSchemaSimpleType :
null;
}
- type = ParseDataType(xsdType.BaseType);
+ type = ParseDataType(xsdType.BaseType!);
strType = xsdType.Name;
if (xsdType.Length == 1 && type == typeof(string))
@@ -2448,7 +2445,7 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
if (((!isBase) || FromInference) && (table.Columns.Contains(columnName, true)))
{
- column = table.Columns[columnName];
+ column = table.Columns[columnName]!;
isToAdd = false;
if (FromInference)
@@ -2479,13 +2476,13 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
if (!string.IsNullOrEmpty(column.Expression))
{
- _columnExpressions.Add(column);
+ _columnExpressions!.Add(column);
}
// Update XSD type to point to simple types actual namespace instead of normalized default namespace in case of remoting
if (xsdType != null && xsdType.Name != null && xsdType.Name.Length > 0)
{
- if (XSDSchema.GetMsdataAttribute(typeNode, Keywords.TARGETNAMESPACE) != null)
+ if (XSDSchema.GetMsdataAttribute(typeNode!, Keywords.TARGETNAMESPACE) != null)
{
column.XmlDataType = xsdType.SimpleTypeQualifiedName;
}
@@ -2512,7 +2509,7 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
}
else if (elem.Form == XmlSchemaForm.None)
{
- XmlSchemaObject e = elem.Parent;
+ XmlSchemaObject e = elem.Parent!;
while (e.Parent != null)
{
e = e.Parent;
@@ -2548,7 +2545,7 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
column.Prefix = GetPrefix(column.Namespace); // it can inherit its NS from DataTable, if it is null
}
- string strDefault = el.DefaultValue;
+ string? strDefault = el.DefaultValue;
if (strDefault != null)
try
{
@@ -2563,22 +2560,22 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
{
- string dsName = node.Name;
+ string? dsName = node.Name;
string dsNamespace = node.QualifiedName.Namespace;
List tableSequenceList = new List();
- string value = GetMsdataAttribute(node, Keywords.MSD_LOCALE);
+ string? value = GetMsdataAttribute(node, Keywords.MSD_LOCALE);
if (null != value)
{ // set by user
if (0 != value.Length)
{
// <... msdata:Locale="en-US"/>
- _ds.Locale = new CultureInfo(value);
+ _ds!.Locale = new CultureInfo(value);
}
else
{
- _ds.Locale = CultureInfo.InvariantCulture;
+ _ds!.Locale = CultureInfo.InvariantCulture;
}
}
else
@@ -2586,12 +2583,12 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
// MSD_LOCALE overrides MSD_USECURRENTLOCALE
if (GetBooleanAttribute(node, Keywords.MSD_USECURRENTLOCALE, false))
{
- _ds.SetLocaleValue(CultureInfo.CurrentCulture, false);
+ _ds!.SetLocaleValue(CultureInfo.CurrentCulture, false);
}
else
{
// Everett behavior before <... msdata:UseCurrentLocale="true"/>
- _ds.SetLocaleValue(new CultureInfo(0x409), false);
+ _ds!.SetLocaleValue(new CultureInfo(0x409), false);
}
}
@@ -2621,10 +2618,10 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
if (FromInference)
_ds.Prefix = GetPrefix(_ds.Namespace);
- XmlSchemaComplexType ct = (XmlSchemaComplexType)FindTypeNode(node);
+ XmlSchemaComplexType ct = (XmlSchemaComplexType)FindTypeNode(node)!;
if (ct.Particle != null)
{
- XmlSchemaObjectCollection items = GetParticleItems(ct.Particle);
+ XmlSchemaObjectCollection? items = GetParticleItems(ct.Particle);
if (items == null)
{
@@ -2643,7 +2640,7 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
}
else
{
- DataTable tempTable = _ds.Tables.GetTable(XmlConvert.DecodeName(GetInstanceName((XmlSchemaElement)el)), node.QualifiedName.Namespace);
+ DataTable? tempTable = _ds.Tables.GetTable(XmlConvert.DecodeName(GetInstanceName((XmlSchemaElement)el)), node.QualifiedName.Namespace);
if (tempTable != null)
{
tableSequenceList.Add(tempTable); // if ref table is created, add it
@@ -2661,14 +2658,14 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
}
}
- DataTable child = HandleTable((XmlSchemaElement)el);
+ DataTable? child = HandleTable((XmlSchemaElement)el);
if (child != null)
{
child._fNestedInDataset = true;
}
if (FromInference)
{
- tableSequenceList.Add(child);
+ tableSequenceList.Add(child!);
}
}
else if (el is XmlSchemaChoice)
@@ -2685,7 +2682,7 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
if ((((XmlSchemaElement)choiceEl).RefName.Name.Length != 0) && (!FromInference && ((XmlSchemaElement)choiceEl).MaxOccurs != decimal.One && !(((XmlSchemaElement)choiceEl).SchemaType is XmlSchemaComplexType)))
continue;
- DataTable child = HandleTable((XmlSchemaElement)choiceEl);
+ DataTable child = HandleTable((XmlSchemaElement)choiceEl)!;
if (FromInference)
{
tableSequenceList.Add(child);
@@ -2705,7 +2702,7 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
{
foreach (XmlSchemaIdentityConstraint key in node.Constraints)
{
- XmlSchemaKeyref keyref = key as XmlSchemaKeyref;
+ XmlSchemaKeyref? keyref = key as XmlSchemaKeyref;
if (keyref == null)
continue;
@@ -2732,18 +2729,18 @@ private void AddTablesToList(List tableList, DataTable dt)
if (!tableList.Contains(dt))
{
tableList.Add(dt);
- foreach (DataTable childTable in _tableDictionary[dt])
+ foreach (DataTable childTable in _tableDictionary![dt])
{
AddTablesToList(tableList, childTable);
}
}
}
- private string GetPrefix(string ns)
+ private string? GetPrefix(string ns)
{
if (ns == null)
return null;
- foreach (XmlSchema schemaRoot in _schemaSet.Schemas())
+ foreach (XmlSchema schemaRoot in _schemaSet!.Schemas())
{
XmlQualifiedName[] qualifiedNames = schemaRoot.Namespaces.ToArray();
for (int i = 0; i < qualifiedNames.Length; i++)
@@ -2755,11 +2752,11 @@ private string GetPrefix(string ns)
return null;
}
- private string GetNamespaceFromPrefix(string prefix)
+ private string? GetNamespaceFromPrefix(string? prefix)
{
if ((prefix == null) || (prefix.Length == 0))
return null;
- foreach (XmlSchema schemaRoot in _schemaSet.Schemas())
+ foreach (XmlSchema schemaRoot in _schemaSet!.Schemas())
{
XmlQualifiedName[] qualifiedNames = schemaRoot.Namespaces.ToArray();
for (int i = 0; i < qualifiedNames.Length; i++)
@@ -2772,9 +2769,9 @@ private string GetNamespaceFromPrefix(string prefix)
}
- private string GetTableNamespace(XmlSchemaIdentityConstraint key)
+ private string? GetTableNamespace(XmlSchemaIdentityConstraint key)
{
- string xpath = key.Selector.XPath;
+ string xpath = key.Selector!.XPath!;
string[] split = xpath.Split('/');
string prefix = string.Empty;
@@ -2795,7 +2792,7 @@ private string GetTableNamespace(XmlSchemaIdentityConstraint key)
private string GetTableName(XmlSchemaIdentityConstraint key)
{
- string xpath = key.Selector.XPath;
+ string xpath = key.Selector!.XPath!;
string[] split = xpath.Split('/', ':');
string tableName = split[split.Length - 1]; //get the last string after '/' and ':'
@@ -2811,7 +2808,7 @@ internal bool IsTable(XmlSchemaElement node)
if (node.MaxOccurs == decimal.Zero)
return false;
- XmlAttribute[] attribs = node.UnhandledAttributes;
+ XmlAttribute[]? attribs = node.UnhandledAttributes;
if (attribs != null)
{
for (int i = 0; i < attribs.Length; i++)
@@ -2824,7 +2821,7 @@ internal bool IsTable(XmlSchemaElement node)
}
}
- object typeNode = FindTypeNode(node);
+ object? typeNode = FindTypeNode(node);
if ((node.MaxOccurs > decimal.One) && typeNode == null)
{
@@ -2840,7 +2837,7 @@ internal bool IsTable(XmlSchemaElement node)
XmlSchemaComplexType ctNode = (XmlSchemaComplexType)typeNode;
if (ctNode.IsAbstract)
- throw ExceptionBuilder.CannotInstantiateAbstract(node.Name);
+ throw ExceptionBuilder.CannotInstantiateAbstract(node.Name!);
return true;
}
@@ -2849,19 +2846,19 @@ internal bool IsTable(XmlSchemaElement node)
// return (elements.IndexOf(node) != -1);
// }
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- internal DataTable HandleTable(XmlSchemaElement node)
+ internal DataTable? HandleTable(XmlSchemaElement node)
{
if (!IsTable(node))
return null;
- object typeNode = FindTypeNode(node);
+ object? typeNode = FindTypeNode(node);
if ((node.MaxOccurs > decimal.One) && typeNode == null)
{
return InstantiateSimpleTable(node);
}
- DataTable table = InstantiateTable(node, (XmlSchemaComplexType)typeNode, (node.RefName != null)); // this is wrong , correct check should be node.RefName.IsEmpty
+ DataTable table = InstantiateTable(node, (XmlSchemaComplexType)typeNode!, (node.RefName != null)); // this is wrong , correct check should be node.RefName.IsEmpty
table._fNestedInDataset = false;
return table;
diff --git a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs
index b5f5eb009801e..3f80ecdf1cbee 100644
--- a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO: Enable after System.Private.Xml is annotated
-#nullable disable
-
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
@@ -18,17 +15,17 @@ namespace System.Data
{
internal sealed class XmlDataLoader
{
- private readonly DataSet _dataSet;
- private XmlToDatasetMap _nodeToSchemaMap;
+ private readonly DataSet? _dataSet;
+ private XmlToDatasetMap? _nodeToSchemaMap;
private readonly Hashtable _nodeToRowMap;
- private readonly Stack _childRowsStack;
+ private readonly Stack? _childRowsStack;
private readonly bool _fIsXdr;
internal bool _isDiffgram;
- private XmlElement _topMostNode;
+ private XmlElement? _topMostNode;
private readonly bool _ignoreSchema;
- private readonly DataTable _dataTable;
+ private readonly DataTable? _dataTable;
private readonly bool _isTableLevel;
private bool _fromInference;
@@ -96,17 +93,17 @@ internal bool FromInference
// after loading, all detached DataRows are attached to their tables
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- private void AttachRows(DataRow parentRow, XmlNode parentElement)
+ private void AttachRows(DataRow? parentRow, XmlNode parentElement)
{
if (parentElement == null)
return;
- for (XmlNode n = parentElement.FirstChild; n != null; n = n.NextSibling)
+ for (XmlNode? n = parentElement.FirstChild; n != null; n = n.NextSibling)
{
if (n.NodeType == XmlNodeType.Element)
{
XmlElement e = (XmlElement)n;
- DataRow r = GetRowFromElement(e);
+ DataRow? r = GetRowFromElement(e);
if (r != null && r.RowState == DataRowState.Detached)
{
if (parentRow != null)
@@ -129,7 +126,7 @@ private void AttachRows(DataRow parentRow, XmlNode parentElement)
private int CountNonNSAttributes(XmlNode node)
{
int count = 0;
- for (int i = 0; i < node.Attributes.Count; i++)
+ for (int i = 0; i < node.Attributes!.Count; i++)
{
if (!FExcludedNamespace(node.Attributes[i].NamespaceURI))
count++;
@@ -137,9 +134,9 @@ private int CountNonNSAttributes(XmlNode node)
return count;
}
- private string GetValueForTextOnlyColums(XmlNode n)
+ private string GetValueForTextOnlyColums(XmlNode? n)
{
- string value = null;
+ string? value = null;
// don't consider whitespace
while (n != null && (n.NodeType == XmlNodeType.Whitespace || !IsTextLikeNode(n.NodeType)))
@@ -173,15 +170,15 @@ private string GetValueForTextOnlyColums(XmlNode n)
return value;
}
- private string GetInitialTextFromNodes(ref XmlNode n)
+ private string GetInitialTextFromNodes(ref XmlNode? n)
{
- string value = null;
+ string? value = null;
if (n != null)
{
// don't consider whitespace
while (n.NodeType == XmlNodeType.Whitespace)
- n = n.NextSibling;
+ n = n.NextSibling!;
if (IsTextLikeNode(n.NodeType) && (n.NextSibling == null || !IsTextLikeNode(n.NodeType)))
{
@@ -207,7 +204,7 @@ private string GetInitialTextFromNodes(ref XmlNode n)
return value;
}
- private DataColumn GetTextOnlyColumn(DataRow row)
+ private DataColumn? GetTextOnlyColumn(DataRow row)
{
DataColumnCollection columns = row.Table.Columns;
int cCols = columns.Count;
@@ -220,20 +217,20 @@ private DataColumn GetTextOnlyColumn(DataRow row)
return null;
}
- internal DataRow GetRowFromElement(XmlElement e)
+ internal DataRow? GetRowFromElement(XmlElement e)
{
- return (DataRow)_nodeToRowMap[e];
+ return (DataRow?)_nodeToRowMap[e];
}
internal bool FColumnElement(XmlElement e)
{
- if (_nodeToSchemaMap.GetColumnSchema(e, FIgnoreNamespace(e)) == null)
+ if (_nodeToSchemaMap!.GetColumnSchema(e, FIgnoreNamespace(e)) == null)
return false;
if (CountNonNSAttributes(e) > 0)
return false;
- for (XmlNode tabNode = e.FirstChild; tabNode != null; tabNode = tabNode.NextSibling)
+ for (XmlNode? tabNode = e.FirstChild; tabNode != null; tabNode = tabNode.NextSibling)
if (tabNode is XmlElement)
return false;
@@ -247,11 +244,11 @@ private bool FExcludedNamespace(string ns)
private bool FIgnoreNamespace(XmlNode node)
{
- XmlNode ownerNode;
+ XmlNode? ownerNode;
if (!_fIsXdr)
return false;
if (node is XmlAttribute)
- ownerNode = ((XmlAttribute)node).OwnerElement;
+ ownerNode = ((XmlAttribute)node).OwnerElement!;
else
ownerNode = node;
if (ownerNode.NamespaceURI.StartsWith("x-schema:#", StringComparison.Ordinal))
@@ -304,23 +301,23 @@ internal void LoadData(XmlDocument xdoc)
if (_isTableLevel)
{
- saveEnforce = _dataTable.EnforceConstraints;
+ saveEnforce = _dataTable!.EnforceConstraints;
_dataTable.EnforceConstraints = false;
}
else
{
- saveEnforce = _dataSet.EnforceConstraints;
+ saveEnforce = _dataSet!.EnforceConstraints;
_dataSet.EnforceConstraints = false;
_dataSet._fInReadXml = true;
}
if (_isTableLevel)
{
- _nodeToSchemaMap = new XmlToDatasetMap(_dataTable, xdoc.NameTable);
+ _nodeToSchemaMap = new XmlToDatasetMap(_dataTable!, xdoc.NameTable);
}
else
{
- _nodeToSchemaMap = new XmlToDatasetMap(_dataSet, xdoc.NameTable);
+ _nodeToSchemaMap = new XmlToDatasetMap(_dataSet!, xdoc.NameTable);
}
/*
// Top level table or dataset ?
@@ -341,11 +338,11 @@ internal void LoadData(XmlDocument xdoc)
}
}
*/
- DataRow topRow = null;
+ DataRow? topRow = null;
if (_isTableLevel || (_dataSet != null && _dataSet._fTopLevelTable))
{
XmlElement e = xdoc.DocumentElement;
- DataTable topTable = (DataTable)_nodeToSchemaMap.GetSchemaForNode(e, FIgnoreNamespace(e));
+ DataTable? topTable = (DataTable?)_nodeToSchemaMap.GetSchemaForNode(e, FIgnoreNamespace(e));
if (topTable != null)
{
topRow = topTable.CreateEmptyRow(); //enzol perf
@@ -363,11 +360,11 @@ internal void LoadData(XmlDocument xdoc)
if (_isTableLevel)
{
- _dataTable.EnforceConstraints = saveEnforce;
+ _dataTable!.EnforceConstraints = saveEnforce;
}
else
{
- _dataSet._fInReadXml = false;
+ _dataSet!._fInReadXml = false;
_dataSet.EnforceConstraints = saveEnforce;
}
}
@@ -375,7 +372,7 @@ internal void LoadData(XmlDocument xdoc)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private void LoadRowData(DataRow row, XmlElement rowElement)
{
- XmlNode n;
+ XmlNode? n;
DataTable table = row.Table;
if (FromInference)
table.Prefix = rowElement.Prefix;
@@ -389,7 +386,7 @@ private void LoadRowData(DataRow row, XmlElement rowElement)
n = rowElement.FirstChild;
// Look for data to fill the TextOnly column
- DataColumn column = GetTextOnlyColumn(row);
+ DataColumn? column = GetTextOnlyColumn(row);
if (column != null)
{
foundColumns[column] = column;
@@ -407,7 +404,7 @@ private void LoadRowData(DataRow row, XmlElement rowElement)
{
XmlElement e = (XmlElement)n;
- object schema = _nodeToSchemaMap.GetSchemaForNode(e, FIgnoreNamespace(e));
+ object? schema = _nodeToSchemaMap!.GetSchemaForNode(e, FIgnoreNamespace(e));
if (schema is DataTable)
{
if (FColumnElement(e))
@@ -447,7 +444,7 @@ private void LoadRowData(DataRow row, XmlElement rowElement)
}
// if no more siblings, ascend back toward original element (rowElement)
- while (n != rowElement && n.NextSibling == null)
+ while (n != rowElement && n!.NextSibling == null)
{
n = n.ParentNode;
}
@@ -461,7 +458,7 @@ private void LoadRowData(DataRow row, XmlElement rowElement)
//
foreach (XmlAttribute attr in rowElement.Attributes)
{
- object schema = _nodeToSchemaMap.GetColumnSchema(attr, FIgnoreNamespace(attr));
+ object? schema = _nodeToSchemaMap!.GetColumnSchema(attr, FIgnoreNamespace(attr));
if (schema != null && schema is DataColumn)
{
DataColumn c = (DataColumn)schema;
@@ -504,7 +501,7 @@ private void LoadRowData(DataRow row, XmlElement rowElement)
// load all data from tree structre into datarows
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
- private void LoadRows(DataRow parentRow, XmlNode parentElement)
+ private void LoadRows(DataRow? parentRow, XmlNode parentElement)
{
if (parentElement == null)
return;
@@ -515,16 +512,16 @@ private void LoadRows(DataRow parentRow, XmlNode parentElement)
parentElement.LocalName == Keywords.XDR_SCHEMA && parentElement.NamespaceURI == Keywords.XDRNS)
return;
- for (XmlNode n = parentElement.FirstChild; n != null; n = n.NextSibling)
+ for (XmlNode? n = parentElement.FirstChild; n != null; n = n.NextSibling)
{
if (n is XmlElement)
{
XmlElement e = (XmlElement)n;
- object schema = _nodeToSchemaMap.GetSchemaForNode(e, FIgnoreNamespace(e));
+ object? schema = _nodeToSchemaMap!.GetSchemaForNode(e, FIgnoreNamespace(e));
if (schema != null && schema is DataTable)
{
- DataRow r = GetRowFromElement(e);
+ DataRow? r = GetRowFromElement(e);
if (r == null)
{
// skip columns which has the same name as another table
@@ -556,24 +553,24 @@ private void SetRowValueFromXmlText(DataRow row, DataColumn col, string xmlText)
row[col] = col.ConvertXmlToObject(xmlText);
}
- private XmlReader _dataReader;
- private object _XSD_XMLNS_NS;
- private object _XDR_SCHEMA;
- private object _XDRNS;
- private object _SQL_SYNC;
- private object _UPDGNS;
- private object _XSD_SCHEMA;
- private object _XSDNS;
-
- private object _DFFNS;
- private object _MSDNS;
- private object _DIFFID;
- private object _HASCHANGES;
- private object _ROWORDER;
+ private XmlReader? _dataReader;
+ private object? _XSD_XMLNS_NS;
+ private object? _XDR_SCHEMA;
+ private object? _XDRNS;
+ private object? _SQL_SYNC;
+ private object? _UPDGNS;
+ private object? _XSD_SCHEMA;
+ private object? _XSDNS;
+
+ private object? _DFFNS;
+ private object? _MSDNS;
+ private object? _DIFFID;
+ private object? _HASCHANGES;
+ private object? _ROWORDER;
private void InitNameTable()
{
- XmlNameTable nameTable = _dataReader.NameTable;
+ XmlNameTable nameTable = _dataReader!.NameTable;
_XSD_XMLNS_NS = nameTable.Add(Keywords.XSD_XMLNS_NS);
_XDR_SCHEMA = nameTable.Add(Keywords.XDR_SCHEMA);
@@ -597,23 +594,23 @@ internal void LoadData(XmlReader reader)
int entryDepth = _dataReader.Depth; // Store current XML element depth so we'll read
// correct portion of the XML and no more
- bool fEnforce = _isTableLevel ? _dataTable.EnforceConstraints : _dataSet.EnforceConstraints;
+ bool fEnforce = _isTableLevel ? _dataTable!.EnforceConstraints : _dataSet!.EnforceConstraints;
// Keep constraints status for datataset/table
InitNameTable(); // Adds DataSet namespaces to reader's nametable
if (_nodeToSchemaMap == null)
{ // Create XML to dataset map
- _nodeToSchemaMap = _isTableLevel ? new XmlToDatasetMap(_dataReader.NameTable, _dataTable) :
- new XmlToDatasetMap(_dataReader.NameTable, _dataSet);
+ _nodeToSchemaMap = _isTableLevel ? new XmlToDatasetMap(_dataReader.NameTable, _dataTable!) :
+ new XmlToDatasetMap(_dataReader.NameTable, _dataSet!);
}
if (_isTableLevel)
{
- _dataTable.EnforceConstraints = false; // Disable constraints
+ _dataTable!.EnforceConstraints = false; // Disable constraints
}
else
{
- _dataSet.EnforceConstraints = false; // Disable constraints
+ _dataSet!.EnforceConstraints = false; // Disable constraints
_dataSet._fInReadXml = true; // We're in ReadXml now
}
@@ -621,7 +618,7 @@ internal void LoadData(XmlReader reader)
{ // Do we have top node?
if (!_isDiffgram && !_isTableLevel)
{ // Not a diffgram and not DataSet?
- DataTable table = _nodeToSchemaMap.GetSchemaForNode(_topMostNode, FIgnoreNamespace(_topMostNode)) as DataTable;
+ DataTable? table = _nodeToSchemaMap.GetSchemaForNode(_topMostNode, FIgnoreNamespace(_topMostNode)) as DataTable;
// Try to match table in the dataset to this node
if (table != null)
{ // Got the table ?
@@ -642,7 +639,7 @@ internal void LoadData(XmlReader reader)
_dataReader.Read();
continue;
}
- DataTable table = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
+ DataTable? table = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
// Try to get table for node
if (table == null)
{ // Read till table is found
@@ -658,11 +655,11 @@ internal void LoadData(XmlReader reader)
if (_isTableLevel)
{
- _dataTable.EnforceConstraints = fEnforce; // Restore constraints and return
+ _dataTable!.EnforceConstraints = fEnforce; // Restore constraints and return
}
else
{
- _dataSet._fInReadXml = false; // We're done.
+ _dataSet!._fInReadXml = false; // We're done.
_dataSet.EnforceConstraints = fEnforce; // Restore constraints and return
}
}
@@ -701,35 +698,35 @@ private void LoadTopMostTable(DataTable table)
Debug.Assert(_topMostNode != null, "topMostNode is null on LoadTopMostTable() entry");
Debug.Assert(!_isDiffgram, "Diffgram mode is on while we have topMostNode table. This is bad.");
- bool topNodeIsTable = _isTableLevel || (_dataSet.DataSetName != table.TableName);
+ bool topNodeIsTable = _isTableLevel || (_dataSet!.DataSetName != table.TableName);
// If table name we have matches dataset
// name top node could be a DataSet OR a table.
// It's a table overwise.
- DataRow row = null; // Data row we're going to add to this table
+ DataRow? row = null; // Data row we're going to add to this table
bool matchFound = false; // Assume we found no matching elements
- int entryDepth = _dataReader.Depth - 1; // Store current reader depth so we know when to stop reading
+ int entryDepth = _dataReader!.Depth - 1; // Store current reader depth so we know when to stop reading
// Adjust depth by one as we've read top most element
// outside this method.
string textNodeValue; // Value of a text node we might have
Debug.Assert(entryDepth >= 0, "Wrong entry Depth for top most element.");
- int entryChild = _childRowsStack.Count; // Memorize child stack level on entry
+ int entryChild = _childRowsStack!.Count; // Memorize child stack level on entry
- DataColumn c; // Hold column here
+ DataColumn? c; // Hold column here
DataColumnCollection collection = table.Columns; // Hold column collectio here
object[] foundColumns = new object[collection.Count];
// This is the columns data we might find
- XmlNode n; // Need this to pass by reference
+ XmlNode? n; // Need this to pass by reference
foreach (XmlAttribute attr in _topMostNode.Attributes)
{
// Check all attributes in this node
- c = _nodeToSchemaMap.GetColumnSchema(attr, FIgnoreNamespace(attr)) as DataColumn;
+ c = _nodeToSchemaMap!.GetColumnSchema(attr, FIgnoreNamespace(attr)) as DataColumn;
// Try to match attribute to column
if ((c != null) && (c.ColumnMapping == MappingType.Attribute))
{
@@ -752,7 +749,7 @@ private void LoadTopMostTable(DataTable table)
switch (_dataReader.NodeType)
{ // Process nodes based on type
case XmlNodeType.Element: // It's an element
- object o = _nodeToSchemaMap.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader));
+ object? o = _nodeToSchemaMap!.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader));
// Get dataset element for this XML element
c = o as DataColumn; // Perhaps, it's a column?
@@ -773,7 +770,7 @@ private void LoadTopMostTable(DataTable table)
}
else
{
- DataTable nestedTable = o as DataTable;
+ DataTable? nestedTable = o as DataTable;
// Perhaps, it's a nested table ?
if (nestedTable != null)
{ // Do we have matched table in DataSet ?
@@ -883,12 +880,12 @@ private void LoadTable(DataTable table, bool isNested)
Debug.Assert(table != null, "Table to be loaded is null on LoadTable() entry");
- DataRow row = null; // Data row we're going to add to this table
+ DataRow? row = null; // Data row we're going to add to this table
- int entryDepth = _dataReader.Depth; // Store current reader depth so we know when to stop reading
- int entryChild = _childRowsStack.Count; // Memorize child stack level on entry
+ int entryDepth = _dataReader!.Depth; // Store current reader depth so we know when to stop reading
+ int entryChild = _childRowsStack!.Count; // Memorize child stack level on entry
- DataColumn c; // Hold column here
+ DataColumn? c; // Hold column here
DataColumnCollection collection = table.Columns; // Hold column collectio here
object[] foundColumns = new object[collection.Count];
@@ -897,7 +894,7 @@ private void LoadTable(DataTable table, bool isNested)
int rowOrder = -1; // Row to insert data to
string diffId = string.Empty; // Diffgram ID string
- string hasChanges = null; // Changes string
+ string? hasChanges = null; // Changes string
bool hasErrors = false; // Set this in case of problem
string textNodeValue; // Value of a text node we might have
@@ -909,7 +906,7 @@ private void LoadTable(DataTable table, bool isNested)
// Check all attributes one by one
_dataReader.MoveToAttribute(i); // Get this attribute
- c = _nodeToSchemaMap.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader)) as DataColumn;
+ c = _nodeToSchemaMap!.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader)) as DataColumn;
// Try to get column for this attribute
if ((c != null) && (c.ColumnMapping == MappingType.Attribute))
@@ -980,7 +977,7 @@ private void LoadTable(DataTable table, bool isNested)
switch (_dataReader.NodeType)
{ // Process nodes based on type
case XmlNodeType.Element: // It's an element
- object o = _nodeToSchemaMap.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader));
+ object? o = _nodeToSchemaMap!.GetColumnSchema(table, _dataReader, FIgnoreNamespace(_dataReader));
// Get dataset element for this XML element
c = o as DataColumn; // Perhaps, it's a column?
@@ -1000,7 +997,7 @@ private void LoadTable(DataTable table, bool isNested)
}
else
{
- DataTable nestedTable = o as DataTable;
+ DataTable? nestedTable = o as DataTable;
// Perhaps, it's a nested table ?
if (nestedTable != null)
{ // Do we have matched nested table in DataSet ?
@@ -1019,7 +1016,7 @@ private void LoadTable(DataTable table, bool isNested)
// but we'll try to load it so we could keep compatibility.
// We won't try to match to columns as we have no idea
// which table this potential column might belong to.
- DataTable misplacedTable = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
+ DataTable? misplacedTable = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
// Try to get table for node
if (misplacedTable != null)
@@ -1153,9 +1150,9 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
// This is how .NET Framework works
string text = string.Empty; // Column text. Assume empty string
- string xsiNilString = null; // Possible NIL attribute string
+ string? xsiNilString = null; // Possible NIL attribute string
- int entryDepth = _dataReader.Depth; // Store depth so we won't read too much
+ int entryDepth = _dataReader!.Depth; // Store depth so we won't read too much
if (_dataReader.AttributeCount > 0) // If have attributes
xsiNilString = _dataReader.GetAttribute(Keywords.XSI_NIL, Keywords.XSINS);
@@ -1163,12 +1160,12 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
// We have to do it before we move to the next element
if (column.IsCustomType)
{ // Custom type column
- object columnValue = null; // Column value we're after. Assume no value.
+ object? columnValue = null; // Column value we're after. Assume no value.
- string xsiTypeString = null; // XSI type name from TYPE attribute
- string typeName = null; // Type name from MSD_INSTANCETYPE attribute
+ string? xsiTypeString = null; // XSI type name from TYPE attribute
+ string? typeName = null; // Type name from MSD_INSTANCETYPE attribute
- XmlRootAttribute xmlAttrib = null; // Might need this attribute for XmlSerializer
+ XmlRootAttribute? xmlAttrib = null; // Might need this attribute for XmlSerializer
if (_dataReader.AttributeCount > 0)
{ // If have attributes, get attributes we'll need
@@ -1209,7 +1206,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
{ // No NIL attribute. Get value
bool skipped = false;
- if (column.Table.DataSet != null && column.Table.DataSet._udtIsWrapped)
+ if (column.Table!.DataSet != null && column.Table.DataSet._udtIsWrapped)
{
_dataReader.Read(); // if UDT is wrapped, skip the wrapper
skipped = true;
@@ -1257,7 +1254,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
text = _dataReader.Value; // Get value.
// See if we have other text nodes near. In most cases this loop will not be executed.
- StringBuilder builder = null;
+ StringBuilder? builder = null;
while (_dataReader.Read() && entryDepth < _dataReader.Depth && IsTextLikeNode(_dataReader.NodeType))
{
if (builder == null)
@@ -1291,9 +1288,9 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
// We've got element which is not supposed to he here.
// That might be table which was misplaced.
// Or it might be a column inside column (also misplaced).
- object o = _nodeToSchemaMap.GetColumnSchema(column.Table, _dataReader, FIgnoreNamespace(_dataReader));
+ object? o = _nodeToSchemaMap!.GetColumnSchema(column.Table!, _dataReader, FIgnoreNamespace(_dataReader));
// Get dataset element for this XML element
- DataColumn c = o as DataColumn; // Perhaps, it's a column?
+ DataColumn? c = o as DataColumn; // Perhaps, it's a column?
if (c != null)
{ // Do we have matched column in this table?
@@ -1312,7 +1309,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
}
else
{
- DataTable nestedTable = o as DataTable;
+ DataTable? nestedTable = o as DataTable;
// Perhaps, it's a nested table ?
if (nestedTable != null)
{
@@ -1324,7 +1321,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
{ // Not a nested column nor nested table.
// Let's try other tables in the DataSet
- DataTable misplacedTable = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
+ DataTable? misplacedTable = _nodeToSchemaMap.GetTableForNode(_dataReader, FIgnoreNamespace(_dataReader));
// Try to get table for node
if (misplacedTable != null)
{
@@ -1370,7 +1367,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private bool ProcessXsdSchema()
{
- if (((object)_dataReader.LocalName == _XSD_SCHEMA && (object)_dataReader.NamespaceURI == _XSDNS))
+ if (((object)_dataReader!.LocalName == _XSD_SCHEMA && (object)_dataReader.NamespaceURI == _XSDNS))
{
// Found XSD schema
if (_ignoreSchema)
@@ -1381,12 +1378,12 @@ private bool ProcessXsdSchema()
{ // Have to load schema.
if (_isTableLevel)
{ // Loading into the DataTable ?
- _dataTable.ReadXSDSchema(_dataReader, false); // Invoke ReadXSDSchema on a table
+ _dataTable!.ReadXSDSchema(_dataReader, false); // Invoke ReadXSDSchema on a table
_nodeToSchemaMap = new XmlToDatasetMap(_dataReader.NameTable, _dataTable);
} // Rebuild XML to DataSet map with new schema.
else
{ // Loading into the DataSet ?
- _dataSet.ReadXSDSchema(_dataReader, false); // Invoke ReadXSDSchema on a DataSet
+ _dataSet!.ReadXSDSchema(_dataReader, false); // Invoke ReadXSDSchema on a DataSet
_nodeToSchemaMap = new XmlToDatasetMap(_dataReader.NameTable, _dataSet);
} // Rebuild XML to DataSet map with new schema.
}
diff --git a/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs b/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs
index f74bf3799fabd..1c042b2102993 100644
--- a/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs
+++ b/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs
@@ -1,12 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// TODO: Enable after System.Private.Xml is annotated
-#nullable disable
-
using System.Xml;
using System.Collections;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
namespace System.Data
{
@@ -18,8 +16,8 @@ internal sealed class XmlToDatasetMap
private sealed class XmlNodeIdentety
{
public string LocalName;
- public string NamespaceURI;
- public XmlNodeIdentety(string localName, string namespaceURI)
+ public string? NamespaceURI;
+ public XmlNodeIdentety(string localName, string? namespaceURI)
{
LocalName = localName;
NamespaceURI = namespaceURI;
@@ -28,9 +26,9 @@ public override int GetHashCode()
{
return LocalName.GetHashCode();
}
- public override bool Equals(object obj)
+ public override bool Equals([NotNullWhen(true)] object? obj)
{
- XmlNodeIdentety id = (XmlNodeIdentety)obj;
+ XmlNodeIdentety id = (XmlNodeIdentety)obj!;
return (
(string.Equals(LocalName, id.LocalName, StringComparison.OrdinalIgnoreCase)) &&
(string.Equals(NamespaceURI, id.NamespaceURI, StringComparison.OrdinalIgnoreCase))
@@ -46,7 +44,7 @@ internal sealed class XmlNodeIdHashtable : Hashtable
public XmlNodeIdHashtable(int capacity)
: base(capacity)
{ }
- public object this[XmlNode node]
+ public object? this[XmlNode node]
{
get
{
@@ -56,7 +54,7 @@ public object this[XmlNode node]
}
}
- public object this[XmlReader dataReader]
+ public object? this[XmlReader dataReader]
{
get
{
@@ -66,7 +64,7 @@ public object this[XmlReader dataReader]
}
}
- public object this[DataTable table]
+ public object? this[DataTable table]
{
get
{
@@ -76,7 +74,7 @@ public object this[DataTable table]
}
}
- public object this[string name]
+ public object? this[string name]
{
get
{
@@ -100,7 +98,7 @@ public TableSchemaInfo(DataTable tableSchema)
private XmlNodeIdHashtable _tableSchemaMap; // Holds all the tables information
- private TableSchemaInfo _lastTableSchemaInfo;
+ private TableSchemaInfo? _lastTableSchemaInfo;
// Used to infer schema
@@ -144,7 +142,7 @@ internal static bool IsMappedColumn(DataColumn c)
// Used to infere schema
- private TableSchemaInfo AddTableSchema(DataTable table, XmlNameTable nameTable)
+ private TableSchemaInfo? AddTableSchema(DataTable table, XmlNameTable nameTable)
{
// SDUB: Because in our case reader already read the document all names that we can meet in the
// document already has an entry in NameTable.
@@ -153,8 +151,8 @@ private TableSchemaInfo AddTableSchema(DataTable table, XmlNameTable nameTable)
// First case deals with decoded names; Second one with encoded names.
// We decided encoded names in first case (instead of decoding them in second)
// because it save us time in LoadRows(). We have, as usual, more data them schemas
- string tableLocalName = nameTable.Get(table.EncodedTableName);
- string tableNamespace = nameTable.Get(table.Namespace);
+ string? tableLocalName = nameTable.Get(table.EncodedTableName);
+ string? tableNamespace = nameTable.Get(table.Namespace);
if (tableLocalName == null)
{
// because name of this table isn't present in XML we don't need mapping for it.
@@ -178,7 +176,7 @@ private TableSchemaInfo AddTableSchema(XmlNameTable nameTable, DataTable table)
string _tableLocalName = table.EncodedTableName; // Table name
- string tableLocalName = nameTable.Get(_tableLocalName); // Look it up in nametable
+ string? tableLocalName = nameTable.Get(_tableLocalName); // Look it up in nametable
if (tableLocalName == null)
{ // If not found
@@ -187,7 +185,7 @@ private TableSchemaInfo AddTableSchema(XmlNameTable nameTable, DataTable table)
table._encodedTableName = tableLocalName; // And set it back
- string tableNamespace = nameTable.Get(table.Namespace); // Look ip table namespace
+ string? tableNamespace = nameTable.Get(table.Namespace); // Look ip table namespace
if (tableNamespace == null)
{ // If not found
@@ -211,8 +209,8 @@ private TableSchemaInfo AddTableSchema(XmlNameTable nameTable, DataTable table)
private bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns)
{
- string columnLocalName = nameTable.Get(col.EncodedColumnName);
- string columnNamespace = nameTable.Get(col.Namespace);
+ string? columnLocalName = nameTable.Get(col.EncodedColumnName);
+ string? columnNamespace = nameTable.Get(col.Namespace);
if (columnLocalName == null)
{
return false;
@@ -233,7 +231,7 @@ private bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHa
private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns)
{
string _columnLocalName = XmlConvert.EncodeLocalName(col.ColumnName);
- string columnLocalName = nameTable.Get(_columnLocalName); // Look it up in a name table
+ string? columnLocalName = nameTable.Get(_columnLocalName); // Look it up in a name table
if (columnLocalName == null)
{ // Not found?
@@ -242,7 +240,7 @@ private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHa
col._encodedColumnName = columnLocalName; // And set it back
- string columnNamespace = nameTable.Get(col.Namespace); // Get column namespace from nametable
+ string? columnNamespace = nameTable.Get(col.Namespace); // Get column namespace from nametable
if (columnNamespace == null)
{ // Not found ?
@@ -266,13 +264,14 @@ private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHa
return true;
}
+ [MemberNotNull(nameof(_tableSchemaMap))]
private void BuildIdentityMap(DataSet dataSet, XmlNameTable nameTable)
{
_tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count);
foreach (DataTable t in dataSet.Tables)
{
- TableSchemaInfo tableSchemaInfo = AddTableSchema(t, nameTable);
+ TableSchemaInfo? tableSchemaInfo = AddTableSchema(t, nameTable);
if (tableSchemaInfo != null)
{
foreach (DataColumn c in t.Columns)
@@ -288,7 +287,7 @@ private void BuildIdentityMap(DataSet dataSet, XmlNameTable nameTable)
}
// This one is used while reading data with preloaded schema
-
+ [MemberNotNull(nameof(_tableSchemaMap))]
private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet)
{
_tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count);
@@ -298,7 +297,7 @@ private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet)
// Hash tables with columns schema maps
// and child tables schema maps
- string dsNamespace = nameTable.Get(dataSet.Namespace); // Attept to look up DataSet namespace
+ string? dsNamespace = nameTable.Get(dataSet.Namespace); // Attept to look up DataSet namespace
// in the name table
if (dsNamespace == null)
@@ -335,14 +334,14 @@ private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet)
// Handle namespaces and names as usuall
string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName);
- string tableLocalName = nameTable.Get(_tableLocalName);
+ string? tableLocalName = nameTable.Get(_tableLocalName);
if (tableLocalName == null)
{
tableLocalName = nameTable.Add(_tableLocalName);
}
- string tableNamespace = nameTable.Get(r.ChildTable.Namespace);
+ string? tableNamespace = nameTable.Get(r.ChildTable.Namespace);
if (tableNamespace == null)
{
@@ -358,12 +357,12 @@ private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet)
}
// Used for inference
-
+ [MemberNotNull(nameof(_tableSchemaMap))]
private void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable)
{
_tableSchemaMap = new XmlNodeIdHashtable(1);
- TableSchemaInfo tableSchemaInfo = AddTableSchema(dataTable, nameTable);
+ TableSchemaInfo? tableSchemaInfo = AddTableSchema(dataTable, nameTable);
if (tableSchemaInfo != null)
{
foreach (DataColumn c in dataTable.Columns)
@@ -378,7 +377,7 @@ private void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable)
}
// This one is used while reading data with preloaded schema
-
+ [MemberNotNull(nameof(_tableSchemaMap))]
private void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable)
{
ArrayList tableList = GetSelfAndDescendants(dataTable); // Get list of tables we're loading
@@ -413,14 +412,14 @@ private void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable)
// Handle namespaces and names as usuall
string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName);
- string tableLocalName = nameTable.Get(_tableLocalName);
+ string? tableLocalName = nameTable.Get(_tableLocalName);
if (tableLocalName == null)
{
tableLocalName = nameTable.Add(_tableLocalName);
}
- string tableNamespace = nameTable.Get(r.ChildTable.Namespace);
+ string? tableNamespace = nameTable.Get(r.ChildTable.Namespace);
if (tableNamespace == null)
{
@@ -443,7 +442,7 @@ private ArrayList GetSelfAndDescendants(DataTable dt)
while (nCounter < tableList.Count)
{
- foreach (DataRelation childRelations in ((DataTable)tableList[nCounter]).ChildRelations)
+ foreach (DataRelation childRelations in ((DataTable)tableList[nCounter]!).ChildRelations)
{
if (!tableList.Contains(childRelations.ChildTable))
tableList.Add(childRelations.ChildTable);
@@ -455,12 +454,12 @@ private ArrayList GetSelfAndDescendants(DataTable dt)
}
// Used to infer schema and top most node
- public object GetColumnSchema(XmlNode node, bool fIgnoreNamespace)
+ public object? GetColumnSchema(XmlNode node, bool fIgnoreNamespace)
{
Debug.Assert(node != null, "Argument validation");
- TableSchemaInfo tableSchemaInfo = null;
+ TableSchemaInfo? tableSchemaInfo = null;
- XmlNode nodeRegion = (node.NodeType == XmlNodeType.Attribute) ? ((XmlAttribute)node).OwnerElement : node.ParentNode;
+ XmlNode? nodeRegion = (node.NodeType == XmlNodeType.Attribute) ? ((XmlAttribute)node).OwnerElement : node.ParentNode;
do
{
@@ -468,7 +467,7 @@ public object GetColumnSchema(XmlNode node, bool fIgnoreNamespace)
{
return null;
}
- tableSchemaInfo = (TableSchemaInfo)(fIgnoreNamespace ? _tableSchemaMap[nodeRegion.LocalName] : _tableSchemaMap[nodeRegion]);
+ tableSchemaInfo = (TableSchemaInfo?)(fIgnoreNamespace ? _tableSchemaMap[nodeRegion.LocalName] : _tableSchemaMap[nodeRegion]);
nodeRegion = nodeRegion.ParentNode;
} while (tableSchemaInfo == null);
@@ -480,11 +479,11 @@ public object GetColumnSchema(XmlNode node, bool fIgnoreNamespace)
}
- public object GetColumnSchema(DataTable table, XmlReader dataReader, bool fIgnoreNamespace)
+ public object? GetColumnSchema(DataTable table, XmlReader dataReader, bool fIgnoreNamespace)
{
if ((_lastTableSchemaInfo == null) || (_lastTableSchemaInfo.TableSchema != table))
{
- _lastTableSchemaInfo = (TableSchemaInfo)(fIgnoreNamespace ? _tableSchemaMap[table.EncodedTableName] : _tableSchemaMap[table]);
+ _lastTableSchemaInfo = (TableSchemaInfo)(fIgnoreNamespace ? _tableSchemaMap[table.EncodedTableName]! : _tableSchemaMap[table]!);
}
if (fIgnoreNamespace)
@@ -494,13 +493,13 @@ public object GetColumnSchema(DataTable table, XmlReader dataReader, bool fIgnor
// Used to infer schema
- public object GetSchemaForNode(XmlNode node, bool fIgnoreNamespace)
+ public object? GetSchemaForNode(XmlNode node, bool fIgnoreNamespace)
{
- TableSchemaInfo tableSchemaInfo = null;
+ TableSchemaInfo? tableSchemaInfo = null;
if (node.NodeType == XmlNodeType.Element)
{ // If element
- tableSchemaInfo = (TableSchemaInfo)(fIgnoreNamespace ? _tableSchemaMap[node.LocalName] : _tableSchemaMap[node]);
+ tableSchemaInfo = (TableSchemaInfo?)(fIgnoreNamespace ? _tableSchemaMap[node.LocalName] : _tableSchemaMap[node]);
} // Look up table schema info for it
if (tableSchemaInfo != null)
@@ -511,9 +510,9 @@ public object GetSchemaForNode(XmlNode node, bool fIgnoreNamespace)
return GetColumnSchema(node, fIgnoreNamespace); // Attempt to locate column
}
- public DataTable GetTableForNode(XmlReader node, bool fIgnoreNamespace)
+ public DataTable? GetTableForNode(XmlReader node, bool fIgnoreNamespace)
{
- TableSchemaInfo tableSchemaInfo = (TableSchemaInfo)(fIgnoreNamespace ? _tableSchemaMap[node.LocalName] : _tableSchemaMap[node]);
+ TableSchemaInfo? tableSchemaInfo = (TableSchemaInfo?)(fIgnoreNamespace ? _tableSchemaMap[node.LocalName] : _tableSchemaMap[node]);
if (tableSchemaInfo != null)
{
_lastTableSchemaInfo = tableSchemaInfo;
@@ -543,7 +542,7 @@ private void HandleSpecialColumn(DataColumn col, XmlNameTable nameTable, XmlNode
{
nameTable.Add(tempColumnName);
}
- string columnNamespace = nameTable.Get(col.Namespace);
+ string? columnNamespace = nameTable.Get(col.Namespace);
XmlNodeIdentety idColumn = new XmlNodeIdentety(tempColumnName, columnNamespace);
columns[idColumn] = col;
}