Skip to content

Commit

Permalink
Nullable annotations for the remainder of System.Data.Common (#55409)
Browse files Browse the repository at this point in the history
  • Loading branch information
krwq authored Jul 10, 2021
1 parent bea4304 commit a54e25b
Show file tree
Hide file tree
Showing 23 changed files with 442 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public virtual object? GetPropertyOwner(PropertyDescriptor pd) => _parent?.GetPropertyOwner(pd);
public virtual object? GetPropertyOwner(PropertyDescriptor? pd) => _parent?.GetPropertyOwner(pd);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ public interface ICustomTypeDescriptor
/// <summary>
/// Gets the object that directly depends on this value being edited.
/// </summary>
object? GetPropertyOwner(PropertyDescriptor pd);
object? GetPropertyOwner(PropertyDescriptor? pd);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ private static IExtenderProvider[] GetExtenders(ICollection components, object i
/// <summary>
/// Retrieves the owner for a property.
/// </summary>
internal object GetExtendedPropertyOwner(object instance, PropertyDescriptor pd)
internal object GetExtendedPropertyOwner(object instance, PropertyDescriptor? pd)
{
return GetPropertyOwner(instance.GetType(), instance, pd);
}
Expand Down Expand Up @@ -873,7 +873,7 @@ internal PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(
/// <summary>
/// Retrieves the owner for a property.
/// </summary>
internal object GetPropertyOwner(Type type, object instance, PropertyDescriptor pd)
internal object GetPropertyOwner(Type type, object instance, PropertyDescriptor? pd)
{
return TypeDescriptor.GetAssociation(type, instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -3121,7 +3121,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
object? ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
return _primary.GetPropertyOwner(pd) ?? _secondary.GetPropertyOwner(pd);
}
Expand Down Expand Up @@ -3570,7 +3570,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
/// ICustomTypeDescriptor implementation.
/// </summary>
[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
Expand Down Expand Up @@ -3915,7 +3915,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
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
Expand Down
6 changes: 3 additions & 3 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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; }
}
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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));
}
Expand All @@ -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))
{
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -840,6 +837,6 @@ private static int GenerateUniqueName(Dictionary<string, int> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
return _propertyDescriptors;
}

object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)
{
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit a54e25b

Please sign in to comment.