Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure <Nullable>enable<Nullable> on System.IO.Packaging and S.Resources.Extensions #41731

Merged
merged 11 commits into from
Sep 9, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CompareAttribute(string otherProperty) { }
public string? OtherPropertyDisplayName { get { throw null; } }
public override bool RequiresValidationContext { get { throw null; } }
public override string FormatErrorMessage(string name) { throw null; }
protected override System.ComponentModel.DataAnnotations.ValidationResult IsValid(object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { throw null; }
protected override System.ComponentModel.DataAnnotations.ValidationResult? IsValid(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
public sealed partial class ConcurrencyCheckAttribute : System.Attribute
Expand Down Expand Up @@ -103,7 +103,7 @@ public DisplayAttribute() { }
public string? ShortName { get { throw null; } set { } }
public bool? GetAutoGenerateField() { throw null; }
public bool? GetAutoGenerateFilter() { throw null; }
public string GetDescription() { throw null; }
public string? GetDescription() { throw null; }
public string? GetGroupName() { throw null; }
public string? GetName() { throw null; }
public int? GetOrder() { throw null; }
Expand Down Expand Up @@ -166,8 +166,8 @@ public sealed partial class FilterUIHintAttribute : System.Attribute
{
public FilterUIHintAttribute(string filterUIHint) { }
public FilterUIHintAttribute(string filterUIHint, string? presentationLayer) { }
public FilterUIHintAttribute(string filterUIHint, string? presentationLayer, params object[] controlParameters) { }
public System.Collections.Generic.IDictionary<string, object> ControlParameters { get { throw null; } }
public FilterUIHintAttribute(string filterUIHint, string? presentationLayer, params object?[] controlParameters) { }
public System.Collections.Generic.IDictionary<string, object?> ControlParameters { get { throw null; } }
public string FilterUIHint { get { throw null; } }
public string? PresentationLayer { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
Expand Down Expand Up @@ -292,14 +292,14 @@ protected ValidationAttribute(string errorMessage) { }
public virtual string FormatErrorMessage(string name) { throw null; }
public System.ComponentModel.DataAnnotations.ValidationResult? GetValidationResult(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { throw null; }
public virtual bool IsValid(object? value) { throw null; }
protected virtual System.ComponentModel.DataAnnotations.ValidationResult IsValid(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { throw null; }
protected virtual System.ComponentModel.DataAnnotations.ValidationResult? IsValid(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { throw null; }
public void Validate(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext) { }
public void Validate(object? value, string name) { }
}
public sealed partial class ValidationContext : System.IServiceProvider
{
public ValidationContext(object instance) { }
public ValidationContext(object instance, System.Collections.Generic.IDictionary<object, object>? items) { }
public ValidationContext(object instance, System.Collections.Generic.IDictionary<object, object?>? items) { }
public ValidationContext(object instance, System.IServiceProvider? serviceProvider, System.Collections.Generic.IDictionary<object, object?>? items) { }
public string DisplayName { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<object, object?> Items { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UIHintAttribute(string uiHint)
/// </summary>
/// <param name="uiHint">The name of the control to use</param>
/// <param name="presentationLayer">The name of the presentation layer that supports this control</param>
public UIHintAttribute(string uiHint, string presentationLayer)
public UIHintAttribute(string uiHint, string? presentationLayer)
: this(uiHint, presentationLayer, Array.Empty<object>())
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace System.ComponentModel
{
public delegate void ProgressChangedEventHandler(object sender, ProgressChangedEventArgs e);
public delegate void ProgressChangedEventHandler(object? sender, ProgressChangedEventArgs e);

public class ProgressChangedEventArgs : EventArgs
{
Expand Down
23 changes: 12 additions & 11 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,13 @@ public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { }
public void WriteXml(System.Xml.XmlWriter? writer) { }
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { }
public void WriteXmlSchema(System.IO.Stream? stream) { }
public void WriteXmlSchema(System.IO.Stream? stream, System.Converter<System.Type, string>? multipleTargetConverter) { }
public void WriteXmlSchema(System.IO.Stream? stream, System.Converter<System.Type, string> multipleTargetConverter) { }
public void WriteXmlSchema(System.IO.TextWriter? writer) { }
public void WriteXmlSchema(System.IO.TextWriter? writer, System.Converter<System.Type, string>? multipleTargetConverter) { }
public void WriteXmlSchema(System.IO.TextWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
public void WriteXmlSchema(string fileName) { }
public void WriteXmlSchema(string fileName, System.Converter<System.Type, string>? multipleTargetConverter) { }
public void WriteXmlSchema(string fileName, System.Converter<System.Type, string> multipleTargetConverter) { }
public void WriteXmlSchema(System.Xml.XmlWriter? writer) { }
public void WriteXmlSchema(System.Xml.XmlWriter? writer, System.Converter<System.Type, string>? multipleTargetConverter) { }
public void WriteXmlSchema(System.Xml.XmlWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
}
public enum DataSetDateTime
{
Expand Down Expand Up @@ -706,7 +706,7 @@ public void EndLoadData() { }
public System.Data.DataRow[] GetErrors() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Type GetRowType() { throw null; }
protected virtual System.Xml.Schema.XmlSchema GetSchema() { throw null; }
protected virtual System.Xml.Schema.XmlSchema? GetSchema() { throw null; }
public void ImportRow(System.Data.DataRow? row) { }
public void Load(System.Data.IDataReader reader) { }
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption) { }
Expand Down Expand Up @@ -807,7 +807,7 @@ public void Clear() { }
public bool Contains(string? name) { throw null; }
public bool Contains(string name, string tableNamespace) { throw null; }
public void CopyTo(System.Data.DataTable[] array, int index) { }
public int IndexOf(System.Data.DataTable table) { throw null; }
public int IndexOf(System.Data.DataTable? table) { throw null; }
public int IndexOf(string? tableName) { throw null; }
public int IndexOf(string tableName, string tableNamespace) { throw null; }
public void Remove(System.Data.DataTable table) { }
Expand Down Expand Up @@ -903,7 +903,8 @@ public DataView(System.Data.DataTable table, string? RowFilter, string? Sort, Sy
[System.ComponentModel.DefaultValueAttribute(System.Data.DataViewRowState.CurrentRows)]
public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
public string? Sort { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Sort { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
Expand Down Expand Up @@ -1598,7 +1599,7 @@ public UniqueConstraint(string? name, System.Data.DataColumn column, bool isPrim
public UniqueConstraint(string? name, System.Data.DataColumn[] columns) { }
public UniqueConstraint(string? name, System.Data.DataColumn[] columns, bool isPrimaryKey) { }
[System.ComponentModel.BrowsableAttribute(false)]
public UniqueConstraint(string name, string[]? columnNames, bool isPrimaryKey) { }
public UniqueConstraint(string? name, string[]? columnNames, bool isPrimaryKey) { }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] Columns { get { throw null; } }
public bool IsPrimaryKey { get { throw null; } }
Expand Down Expand Up @@ -1711,7 +1712,7 @@ public DataColumnMapping(string? sourceColumn, string? dataSetColumn) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataColumn? GetDataColumnBySchemaAction(System.Data.DataTable dataTable, System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.DataColumn GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, System.Data.DataTable dataTable, System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
public static System.Data.DataColumn? GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, System.Data.DataTable dataTable, System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
object System.ICloneable.Clone() { throw null; }
public override string ToString() { throw null; }
}
Expand Down Expand Up @@ -2558,8 +2559,8 @@ public partial interface INullable
public sealed partial class SqlAlreadyFilledException : System.Data.SqlTypes.SqlTypeException
{
public SqlAlreadyFilledException() { }
public SqlAlreadyFilledException(string message) { }
public SqlAlreadyFilledException(string message, System.Exception e) { }
public SqlAlreadyFilledException(string? message) { }
public SqlAlreadyFilledException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlBinary : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public partial class DataView
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.TypeConverter(typeof(DataTableTypeConverter))]
public System.Data.DataTable Table { get { throw null; } set { } }
public System.Data.DataTable? Table { get { throw null; } set { } }
}
internal class DataTableTypeConverter { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ private static void ThrowDataException(string error, Exception? innerException)
//

public static Exception CannotModifyCollection() => _Argument(SR.Data_CannotModifyCollection);
public static Exception CaseInsensitiveNameConflict(string name) => _Argument(SR.Format(SR.Data_CaseInsensitiveNameConflict, name));
public static Exception NamespaceNameConflict(string name) => _Argument(SR.Format(SR.Data_NamespaceNameConflict, name));
public static Exception CaseInsensitiveNameConflict(string? name) => _Argument(SR.Format(SR.Data_CaseInsensitiveNameConflict, name));
public static Exception NamespaceNameConflict(string? name) => _Argument(SR.Format(SR.Data_NamespaceNameConflict, name));
public static Exception InvalidOffsetLength() => _Argument(SR.Data_InvalidOffsetLength);

//
Expand Down
13 changes: 5 additions & 8 deletions src/libraries/System.Data.Common/src/System/Data/DataSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,9 +1962,9 @@ private void WriteXmlSchema(XmlWriter? writer, SchemaFormat schemaFormat, Conver
}
#endregion

public XmlReadMode ReadXml(XmlReader reader) => ReadXml(reader, false);
public XmlReadMode ReadXml(XmlReader? reader) => ReadXml(reader, false);

internal XmlReadMode ReadXml(XmlReader reader, bool denyResolving)
internal XmlReadMode ReadXml(XmlReader? reader, bool denyResolving)
{
IDisposable? restrictedScope = null;
long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.ReadXml|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
Expand Down Expand Up @@ -2243,7 +2243,7 @@ internal XmlReadMode ReadXml(XmlReader reader, bool denyResolving)
}
}

public XmlReadMode ReadXml(Stream stream)
public XmlReadMode ReadXml(Stream? stream)
{
if (stream == null)
{
Expand All @@ -2258,7 +2258,7 @@ public XmlReadMode ReadXml(Stream stream)
return ReadXml(xr, false);
}

public XmlReadMode ReadXml(TextReader reader)
public XmlReadMode ReadXml(TextReader? reader)
{
if (reader == null)
{
Expand Down Expand Up @@ -3355,7 +3355,7 @@ protected virtual void ReadXmlSerializable(XmlReader reader)

protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() => null;

public static XmlSchemaComplexType GetDataSetSchema(XmlSchemaSet schemaSet)
public static XmlSchemaComplexType GetDataSetSchema(XmlSchemaSet? schemaSet)
{
// For performance reasons we are exploiting the fact that config files content is constant
// for a given appdomain so we can safely cache the prepared schema complex type and reuse it
Expand Down Expand Up @@ -3387,8 +3387,6 @@ public static XmlSchemaComplexType GetDataSetSchema(XmlSchemaSet schemaSet)

private static bool PublishLegacyWSDL() => false;

// TODO: Enable after System.Private.Xml is annotated
#nullable disable
#pragma warning disable 8632
XmlSchema? IXmlSerializable.GetSchema()
{
Expand Down Expand Up @@ -3446,7 +3444,6 @@ void IXmlSerializable.WriteXml(XmlWriter writer)
WriteXml(writer, XmlWriteMode.DiffGram);
}
#pragma warning restore 8632
#nullable enable

public virtual void Load(IDataReader reader, LoadOption loadOption, FillErrorEventHandler? errorHandler, params DataTable[] tables)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public DataTable this[int index]
/// <summary>
/// Gets the table in the collection with the given name (not case-sensitive).
/// </summary>
public DataTable? this[string name]
public DataTable? this[string? name]
{
get
{
Expand All @@ -85,7 +85,7 @@ public DataTable? this[string name]
}
}

public DataTable? this[string name, string tableNamespace]
public DataTable? this[string? name, string tableNamespace]
{
get
{
Expand Down Expand Up @@ -197,7 +197,7 @@ public void AddRange(DataTable?[]? tables)
/// <summary>
/// Creates a table with the given name and adds it to the collection.
/// </summary>
public DataTable? Add(string? name)
public DataTable Add(string? name)
{
DataTable table = new DataTable(name);
Add(table);
Expand Down Expand Up @@ -662,7 +662,7 @@ internal int InternalIndexOf(string? tableName)
// >= 0: find the match
// -1: No match
// -2: At least two matches with different cases
internal int InternalIndexOf(string tableName, string tableNamespace)
internal int InternalIndexOf(string? tableName, string tableNamespace)
{
int cachedI = -1;
if ((null != tableName) && (0 < tableName.Length))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public override void Close()
_isOpen = false;
}

public override DataTable GetSchemaTable()
public override DataTable? GetSchemaTable()
{
ValidateOpen(nameof(GetSchemaTable));
ValidateReader();
Expand Down
6 changes: 4 additions & 2 deletions src/libraries/System.Data.Common/src/System/Data/DataView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text;
Expand Down Expand Up @@ -414,6 +415,7 @@ public DataViewRowState RowStateFilter
/// <summary>
/// Gets or sets the sort column or columns, and sort order for the table.
/// </summary>
[AllowNull]
[DefaultValue("")]
public string Sort
{
Expand Down Expand Up @@ -722,11 +724,11 @@ protected override void Dispose(bool disposing)
/// <summary>
/// Finds a row in the <see cref='System.Data.DataView'/> by the specified primary key value.
/// </summary>
public int Find(object key) => FindByKey(key);
public int Find(object? key) => FindByKey(key);

/// <summary>Find index of a DataRowView instance that matches the specified primary key value.</summary>
// TODO: This will throw NRE if _index isn't set (e.g. default ctor)
internal virtual int FindByKey(object key) => _index!.FindRecordByKey(key);
internal virtual int FindByKey(object? key) => _index!.FindRecordByKey(key);

/// <summary>
/// Finds a row in the <see cref='System.Data.DataView'/> by the specified primary key values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public override string? RowFilter
/// </summary>
/// <param name="key">Value of the key to find</param>
/// <returns>Index of the first match of input key</returns>
internal override int FindByKey(object key)
internal override int FindByKey(object? key)
{
Debug.Assert(base.Sort != null);
Debug.Assert(!(!string.IsNullOrEmpty(base.Sort) && base.SortComparison != null),
Expand All @@ -128,7 +128,7 @@ internal override int FindByKey(object key)
Index.ComparisonBySelector<object, DataRow> compareDelg =
new Index.ComparisonBySelector<object, DataRow>(comparerKeyRow!);

List<object> keyList = new List<object>();
List<object?> keyList = new List<object?>();
keyList.Add(key);
Range range = FindRecords<object, DataRow>(compareDelg, keyList);

Expand Down
Loading