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 eadaf5c0501fa..a4bc1f651f202 100644 --- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs +++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs @@ -96,13 +96,16 @@ public ConstraintException(string? message, System.Exception? innerException) { [System.ComponentModel.DesignTimeVisibleAttribute(false)] [System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataColumnEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [System.ComponentModel.ToolboxItemAttribute(false)] + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public partial class DataColumn : System.ComponentModel.MarshalByValueComponent { public DataColumn() { } public DataColumn(string? columnName) { } - public DataColumn(string? columnName, System.Type dataType) { } - public DataColumn(string? columnName, System.Type dataType, string? expr) { } - public DataColumn(string? columnName, System.Type dataType, string? expr, System.Data.MappingType type) { } + public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")] + public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")] + public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr, System.Data.MappingType type) { } [System.ComponentModel.DefaultValueAttribute(true)] public bool AllowDBNull { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(false)] @@ -126,7 +129,7 @@ public DataColumn(string? columnName, System.Type dataType, string? expr, System [System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] [System.Diagnostics.CodeAnalysis.AllowNullAttribute] - public string Expression { get { throw null; } set { } } + public string Expression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } } [System.ComponentModel.BrowsableAttribute(false)] public System.Data.PropertyCollection ExtendedProperties { get { throw null; } } [System.ComponentModel.DefaultValueAttribute(-1)] @@ -174,8 +177,9 @@ public event System.ComponentModel.CollectionChangeEventHandler? CollectionChang public System.Data.DataColumn Add() { throw null; } public void Add(System.Data.DataColumn column) { } public System.Data.DataColumn Add(string? columnName) { throw null; } - public System.Data.DataColumn Add(string? columnName, System.Type type) { throw null; } - public System.Data.DataColumn Add(string? columnName, System.Type type, string expression) { throw null; } + public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members might be trimmed for some data types or expressions.")] + public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type, string expression) { throw null; } public void AddRange(System.Data.DataColumn[] columns) { } public bool CanRemove(System.Data.DataColumn? column) { throw null; } public void Clear() { } @@ -465,20 +469,20 @@ public void EndEdit() { } System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; } System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; } - [System.Diagnostics.CodeAnalysis.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.")] + [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; } #nullable enable @@ -488,10 +492,13 @@ public void EndEdit() { } [System.ComponentModel.ToolboxItemAttribute("Microsoft.VSDesigner.Data.VS.DataSetToolboxItem, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [System.Xml.Serialization.XmlRootAttribute("DataSet")] [System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataSetSchema")] + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)] public partial class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable { public DataSet() { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { } public DataSet(string dataSetName) { } [System.ComponentModel.DefaultValueAttribute(false)] @@ -547,14 +554,21 @@ public void EndInit() { } public static System.Xml.Schema.XmlSchemaComplexType GetDataSetSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; } public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected void GetSerializationData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public string GetXml() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public string GetXmlSchema() { throw null; } public bool HasChanges() { throw null; } public bool HasChanges(System.Data.DataRowState rowStates) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void InferXmlSchema(System.IO.Stream? stream, string[]? nsArray) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void InferXmlSchema(System.IO.TextReader? reader, string[]? nsArray) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void InferXmlSchema(string fileName, string[]? nsArray) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void InferXmlSchema(System.Xml.XmlReader? reader, string[]? nsArray) { } protected virtual void InitializeDerivedDataSet() { } protected bool IsBinarySerialized(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { throw null; } @@ -572,18 +586,31 @@ protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedE protected virtual void OnRemoveRelation(System.Data.DataRelation relation) { } protected internal virtual void OnRemoveTable(System.Data.DataTable table) { } protected internal void RaisePropertyChanging(string name) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream, System.Data.XmlReadMode mode) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader, System.Data.XmlReadMode mode) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(string fileName) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(string fileName, System.Data.XmlReadMode mode) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader, System.Data.XmlReadMode mode) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.IO.TextReader? reader) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.Xml.XmlReader? reader) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected virtual void ReadXmlSerializable(System.Xml.XmlReader reader) { } public virtual void RejectChanges() { } public virtual void Reset() { } @@ -595,21 +622,37 @@ public virtual void Reset() { } void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { } void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { } #nullable enable + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.Stream? stream, System.Converter multipleTargetConverter) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.TextWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.TextWriter? writer, System.Converter multipleTargetConverter) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(string fileName, System.Converter multipleTargetConverter) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.Xml.XmlWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.Xml.XmlWriter? writer, System.Converter multipleTargetConverter) { } } public enum DataSetDateTime @@ -637,6 +680,7 @@ public partial class DataTable : System.ComponentModel.MarshalByValueComponent, { protected internal bool fInitInProgress; public DataTable() { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DataTable(string? tableName) { } public DataTable(string? tableName, string? tableNamespace) { } @@ -655,7 +699,7 @@ public DataTable(string? tableName, string? tableNamespace) { } public System.Data.DataView DefaultView { get { throw null; } } [System.ComponentModel.DefaultValueAttribute("")] [System.Diagnostics.CodeAnalysis.AllowNullAttribute] - public string DisplayExpression { get { throw null; } set { } } + public string DisplayExpression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } } [System.ComponentModel.BrowsableAttribute(false)] public System.Data.PropertyCollection ExtendedProperties { get { throw null; } } [System.ComponentModel.BrowsableAttribute(false)] @@ -702,6 +746,7 @@ public virtual void BeginInit() { } public void BeginLoadData() { } public void Clear() { } public virtual System.Data.DataTable Clone() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter or expression might be trimmed.")] public object Compute(string? expression, string? filter) { throw null; } public System.Data.DataTable Copy() { throw null; } public System.Data.DataTableReader CreateDataReader() { throw null; } @@ -738,20 +783,31 @@ protected virtual void OnRowDeleting(System.Data.DataRowChangeEventArgs e) { } protected virtual void OnTableCleared(System.Data.DataTableClearEventArgs e) { } protected virtual void OnTableClearing(System.Data.DataTableClearEventArgs e) { } protected virtual void OnTableNewRow(System.Data.DataTableNewRowEventArgs e) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(string fileName) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.IO.TextReader? reader) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void ReadXmlSchema(System.Xml.XmlReader? reader) { } protected virtual void ReadXmlSerializable(System.Xml.XmlReader? reader) { } public void RejectChanges() { } public virtual void Reset() { } public System.Data.DataRow[] Select() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] public System.Data.DataRow[] Select(string? filterExpression) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] public System.Data.DataRow[] Select(string? filterExpression, string? sort) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] public System.Data.DataRow[] Select(string? filterExpression, string? sort, System.Data.DataViewRowState recordStates) { throw null; } System.Collections.IList System.ComponentModel.IListSource.GetList() { throw null; } System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; } @@ -760,29 +816,53 @@ void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader read void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { } #nullable enable public override string ToString() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(string fileName, System.Data.XmlWriteMode mode, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.Stream? stream) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.Stream? stream, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.TextWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.IO.TextWriter? writer, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(string fileName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(string fileName, bool writeHierarchy) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.Xml.XmlWriter? writer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] public void WriteXmlSchema(System.Xml.XmlWriter? writer, bool writeHierarchy) { } } public sealed partial class DataTableClearEventArgs : System.EventArgs @@ -887,6 +967,7 @@ public partial class DataView : System.ComponentModel.MarshalByValueComponent, S { public DataView() { } public DataView(System.Data.DataTable? table) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] public DataView(System.Data.DataTable table, string? RowFilter, string? Sort, System.Data.DataViewRowState RowState) { } [System.ComponentModel.DefaultValueAttribute(true)] public bool AllowDelete { get { throw null; } set { } } @@ -907,7 +988,7 @@ public DataView(System.Data.DataTable table, string? RowFilter, string? Sort, Sy protected bool IsOpen { get { throw null; } } public System.Data.DataRowView this[int recordIndex] { get { throw null; } } [System.ComponentModel.DefaultValueAttribute("")] - public virtual string? RowFilter { get { throw null; } set { } } + public virtual string? RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } } [System.ComponentModel.DefaultValueAttribute(System.Data.DataViewRowState.CurrentRows)] public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute("")] @@ -987,7 +1068,7 @@ public DataViewManager(System.Data.DataSet? dataSet) { } [System.ComponentModel.DefaultValueAttribute(null)] [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] public System.Data.DataSet? DataSet { get { throw null; } set { } } - public string DataViewSettingCollectionString { get { throw null; } set { } } + public string DataViewSettingCollectionString { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members of types used in the RowFilter expression might be trimmed.")] set { } } [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)] public System.Data.DataViewSettingCollection DataViewSettings { get { throw null; } } int System.Collections.ICollection.Count { get { throw null; } } @@ -1053,7 +1134,7 @@ internal DataViewSetting() { } [System.ComponentModel.BrowsableAttribute(false)] public System.Data.DataViewManager? DataViewManager { get { throw null; } } [System.Diagnostics.CodeAnalysis.AllowNullAttribute] - public string RowFilter { get { throw null; } set { } } + public string RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } } public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } } [System.Diagnostics.CodeAnalysis.AllowNullAttribute] public string Sort { get { throw null; } set { } } @@ -1589,6 +1670,7 @@ public static partial class TypedTableBaseExtensions public abstract partial class TypedTableBase : System.Data.DataTable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable where T : System.Data.DataRow { protected TypedTableBase() { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Data.EnumerableRowCollection Cast() { throw null; } public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } @@ -1718,9 +1800,9 @@ public DataColumnMapping(string? sourceColumn, string? dataSetColumn) { } [System.Diagnostics.CodeAnalysis.AllowNullAttribute] public string SourceColumn { get { throw null; } set { } } [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; } + public System.Data.DataColumn? GetDataColumnBySchemaAction(System.Data.DataTable dataTable, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] 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.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; } object System.ICloneable.Clone() { throw null; } public override string ToString() { throw null; } } @@ -1755,7 +1837,7 @@ public void CopyTo(System.Data.Common.DataColumnMapping[] array, int index) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] public static System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Data.DataColumn? GetDataColumn(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; } + public static System.Data.DataColumn? GetDataColumn(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; } public System.Collections.IEnumerator GetEnumerator() { throw null; } public int IndexOf(object? value) { throw null; } public int IndexOf(string? sourceColumn) { throw null; } @@ -1786,7 +1868,7 @@ public DataTableMapping(string? sourceTable, string? dataSetTable, System.Data.C [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] public System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public System.Data.DataColumn? GetDataColumn(string sourceColumn, System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; } + public System.Data.DataColumn? GetDataColumn(string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] public System.Data.DataTable? GetDataTableBySchemaAction(System.Data.DataSet dataSet, System.Data.MissingSchemaAction schemaAction) { throw null; } object System.ICloneable.Clone() { throw null; } @@ -2060,20 +2142,20 @@ void System.Collections.IDictionary.Remove(object keyword) { } System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; } System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; } - [System.Diagnostics.CodeAnalysis.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.")] + [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; } public override string ToString() { throw null; } @@ -2242,20 +2324,20 @@ protected DbDataRecord() { } System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; } string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")] System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")] object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; } System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")] System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")] System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; } - [System.Diagnostics.CodeAnalysis.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.")] + [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; } #nullable enable @@ -2430,16 +2512,19 @@ protected DbParameterCollection() { } public static partial class DbProviderFactories { public static System.Data.Common.DbProviderFactory? GetFactory(System.Data.Common.DbConnection connection) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Provider type and its members might be trimmed if not referenced directly.")] public static System.Data.Common.DbProviderFactory GetFactory(System.Data.DataRow providerRow) { throw null; } public static System.Data.Common.DbProviderFactory GetFactory(string providerInvariantName) { throw null; } public static System.Data.DataTable GetFactoryClasses() { throw null; } public static System.Collections.Generic.IEnumerable GetProviderInvariantNames() { throw null; } public static void RegisterFactory(string providerInvariantName, System.Data.Common.DbProviderFactory factory) { } - public static void RegisterFactory(string providerInvariantName, string factoryTypeAssemblyQualifiedName) { } - public static void RegisterFactory(string providerInvariantName, System.Type providerFactoryClass) { } + public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] string factoryTypeAssemblyQualifiedName) { } + public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type providerFactoryClass) { } public static bool TryGetFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Data.Common.DbProviderFactory? factory) { throw null; } public static bool UnregisterFactory(string providerInvariantName) { throw null; } } + + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] public abstract partial class DbProviderFactory { protected DbProviderFactory() { } @@ -2454,7 +2539,7 @@ protected DbProviderFactory() { } public virtual System.Data.Common.DbDataSourceEnumerator? CreateDataSourceEnumerator() { throw null; } public virtual System.Data.Common.DbParameter? CreateParameter() { throw null; } } - [System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)] + [System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public sealed partial class DbProviderSpecificTypePropertyAttribute : System.Attribute { public DbProviderSpecificTypePropertyAttribute(bool isProviderSpecificTypeProperty) { } @@ -2610,11 +2695,11 @@ public partial struct SqlBinary : System.Data.SqlTypes.INullable, System.ICompar public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBinary operator +(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } - public static explicit operator byte[]? (System.Data.SqlTypes.SqlBinary x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBinary (System.Data.SqlTypes.SqlGuid x) { throw null; } + public static explicit operator byte[]?(System.Data.SqlTypes.SqlBinary x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlGuid x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlBinary (byte[] x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlBinary(byte[] x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } @@ -2657,20 +2742,20 @@ public partial struct SqlBoolean : System.Data.SqlTypes.INullable, System.ICompa public static System.Data.SqlTypes.SqlBoolean operator |(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ^(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } - public static explicit operator bool (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlByte x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBoolean (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator bool(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlByte x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlString x) { throw null; } public static bool operator false(System.Data.SqlTypes.SqlBoolean x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlBoolean (bool x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlBoolean(bool x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } @@ -2730,19 +2815,19 @@ public partial struct SqlByte : System.Data.SqlTypes.INullable, System.IComparab public static System.Data.SqlTypes.SqlByte operator /(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlByte operator ^(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator byte (System.Data.SqlTypes.SqlByte x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlByte (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator byte(System.Data.SqlTypes.SqlByte x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlByte (byte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlByte(byte x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } @@ -2784,8 +2869,8 @@ public SqlBytes(System.IO.Stream? s) { } public System.IO.Stream Stream { get { throw null; } set { } } public byte[] Value { get { throw null; } } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBytes (System.Data.SqlTypes.SqlBinary value) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlBinary (System.Data.SqlTypes.SqlBytes value) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBytes(System.Data.SqlTypes.SqlBinary value) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlBytes value) { throw null; } public long Read(long offset, byte[] buffer, int offsetInBuffer, int count) { throw null; } public void SetLength(long value) { } public void SetNull() { } @@ -2811,8 +2896,8 @@ public SqlChars(System.Data.SqlTypes.SqlString value) { } public System.Data.SqlTypes.StorageState Storage { get { throw null; } } public char[] Value { get { throw null; } } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlChars value) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlChars (System.Data.SqlTypes.SqlString value) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlChars value) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlChars(System.Data.SqlTypes.SqlString value) { throw null; } public long Read(long offset, char[] buffer, int offsetInBuffer, int count) { throw null; } public void SetLength(long value) { } public void SetNull() { } @@ -2868,11 +2953,11 @@ public partial struct SqlDateTime : System.Data.SqlTypes.INullable, System.IComp public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } public static System.Data.SqlTypes.SqlDateTime operator +(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } - public static explicit operator System.DateTime (System.Data.SqlTypes.SqlDateTime x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDateTime (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.DateTime(System.Data.SqlTypes.SqlDateTime x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDateTime(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDateTime (System.DateTime value) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDateTime(System.DateTime value) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } @@ -2929,21 +3014,21 @@ public partial struct SqlDecimal : System.Data.SqlTypes.INullable, System.ICompa public static System.Data.SqlTypes.SqlDecimal operator +(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlDecimal operator /(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator decimal (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlString x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDecimal (double x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator decimal(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDecimal(double x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (decimal x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDecimal (long x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(decimal x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDecimal(long x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } @@ -2999,19 +3084,19 @@ public partial struct SqlDouble : System.Data.SqlTypes.INullable, System.ICompar public static System.Data.SqlTypes.SqlDouble operator +(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlDouble operator /(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator double (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator double(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlDouble (double x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlDouble(double x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } @@ -3058,12 +3143,12 @@ public partial struct SqlGuid : System.Data.SqlTypes.INullable, System.IComparab public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlGuid (System.Data.SqlTypes.SqlBinary x) { throw null; } - public static explicit operator System.Guid (System.Data.SqlTypes.SqlGuid x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlGuid (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlBinary x) { throw null; } + public static explicit operator System.Guid(System.Data.SqlTypes.SqlGuid x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlGuid (System.Guid x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlGuid(System.Guid x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } @@ -3112,19 +3197,19 @@ public partial struct SqlInt16 : System.Data.SqlTypes.INullable, System.ICompara public static System.Data.SqlTypes.SqlInt16 operator /(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlInt16 operator ^(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator short (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator short(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt16 (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt16 (short x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt16(short x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } @@ -3186,19 +3271,19 @@ public partial struct SqlInt32 : System.Data.SqlTypes.INullable, System.ICompara public static System.Data.SqlTypes.SqlInt32 operator /(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlInt32 operator ^(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator int (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator int(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt32 (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt32 (int x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt32(int x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } @@ -3260,19 +3345,19 @@ public partial struct SqlInt64 : System.Data.SqlTypes.INullable, System.ICompara public static System.Data.SqlTypes.SqlInt64 operator /(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlInt64 operator ^(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator long (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator long(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt64 (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlInt64 (long x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlInt64(long x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } @@ -3329,21 +3414,21 @@ public partial struct SqlMoney : System.Data.SqlTypes.INullable, System.ICompara public static System.Data.SqlTypes.SqlMoney operator +(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlMoney operator /(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator decimal (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlString x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlMoney (double x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator decimal(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlMoney(double x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (decimal x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlMoney (long x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(decimal x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlMoney(long x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } @@ -3411,19 +3496,19 @@ public partial struct SqlSingle : System.Data.SqlTypes.INullable, System.ICompar public static System.Data.SqlTypes.SqlSingle operator +(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlSingle operator /(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator float (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator float(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlByte x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlSingle (float x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlByte x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlSingle(float x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } @@ -3490,21 +3575,21 @@ public partial struct SqlString : System.Data.SqlTypes.INullable, System.ICompar public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlString operator +(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlBoolean x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlByte x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlDateTime x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlDecimal x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlDouble x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlGuid x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlInt16 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlInt32 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlInt64 x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlMoney x) { throw null; } - public static explicit operator System.Data.SqlTypes.SqlString (System.Data.SqlTypes.SqlSingle x) { throw null; } - public static explicit operator string (System.Data.SqlTypes.SqlString x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlBoolean x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlByte x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDateTime x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDecimal x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDouble x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlGuid x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt16 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt32 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt64 x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlMoney x) { throw null; } + public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlSingle x) { throw null; } + public static explicit operator string(System.Data.SqlTypes.SqlString x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } - public static implicit operator System.Data.SqlTypes.SqlString (string x) { throw null; } + public static implicit operator System.Data.SqlTypes.SqlString(string x) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } @@ -3564,7 +3649,9 @@ namespace System.Xml [System.ObsoleteAttribute("XmlDataDocument class will be removed in a future release.")] public partial class XmlDataDocument : System.Xml.XmlDocument { + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")] public XmlDataDocument() { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")] public XmlDataDocument(System.Data.DataSet dataset) { } public System.Data.DataSet DataSet { get { throw null; } } public override System.Xml.XmlNode CloneNode(bool deep) { throw null; } diff --git a/src/libraries/System.Data.Common/src/ILLink/ILLink.Suppressions.xml b/src/libraries/System.Data.Common/src/ILLink/ILLink.Suppressions.xml index a0aae1367cb5f..ffcb7d78381c4 100644 --- a/src/libraries/System.Data.Common/src/ILLink/ILLink.Suppressions.xml +++ b/src/libraries/System.Data.Common/src/ILLink/ILLink.Suppressions.xml @@ -7,317 +7,155 @@ member M:System.Data.ColumnTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type) - - ILLink - IL2057 - member - M:System.Data.Common.DataStorage.GetType(System.String) - - - ILLink - IL2057 - member - M:System.Data.Common.DbProviderFactories.GetProviderTypeFromTypeName(System.String) - - - ILLink - IL2057 - member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.String) - - - ILLink - IL2057 - member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2057 - member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2057 - member - M:System.Data.DataTable.DeserializeTableSchema(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext,System.Boolean) - - - ILLink - IL2057 - member - M:System.Data.FunctionNode.GetDataType(System.Data.ExpressionNode) - - - ILLink - IL2057 - member - M:System.Data.XSDSchema.SetProperties(System.Object,System.Xml.XmlAttribute[]) - ILLink IL2060 member M:System.Data.DataRowExtensions.UnboxT`1.Create - - ILLink - IL2070 - member - M:System.Data.Common.DbProviderFactories.GetFactoryInstance(System.Type) - ILLink IL2072 member M:System.Data.Common.DataAdapter.CloneInternals - - ILLink - IL2072 - member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2072 - member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2072 - member - M:System.Data.DataColumn.Clone - - - ILLink - IL2072 - member - M:System.Data.DataSet.Clone - - - ILLink - IL2072 - member - M:System.Data.DataTable.CreateInstance - - - ILLink - IL2077 - member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.String) - - - ILLink - IL2077 - member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2077 - member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.String) - - - ILLink - IL2077 - member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) - - - ILLink - IL2080 - member - T:System.Data.Common.SqlUdtStorage - - - ILLink - IL2080 - member - M:System.Data.DataColumn.get_DefaultValue - - - ILLink - IL2026 - member - M:System.Data.DataSet.DeserializeDataSetSchema(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext,System.Data.SerializationFormat,System.Data.SchemaSerializationMode) - ILLink IL2026 member - M:System.Data.DataSet.SerializeDataSet(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext,System.Data.SerializationFormat) + M:System.Data.DataSet.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) ILLink IL2026 member - M:System.Data.Common.DbConnectionStringBuilder.GetProperties(System.Collections.Hashtable) - - - ILLink - IL2026 - member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetAttributes - - - ILLink - IL2026 - member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetClassName + M:System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.GetSchema() ILLink IL2026 member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetComponentName + M:System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader) ILLink IL2026 member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetConverter + M:System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter) ILLink IL2026 member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultEvent + M:System.Data.DataTable.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) ILLink - IL2026 - member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultProperty - - - ILLink - IL2026 - member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEditor(System.Type) - - - ILLink - IL2026 - member - M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEvents - - - ILLink - IL2026 + IL2072 member - M:System.Data.XMLSchema.SetProperties(System.Object,System.Xml.XmlAttributeCollection) + M:System.Data.DataTable.CreateInstance() ILLink IL2026 member - M:System.Data.XmlTreeGen.AddXdoProperties(System.Object,System.Xml.XmlElement,System.Xml.XmlDocument) + M:System.Data.DataTable.GetSchema() ILLink IL2026 member - M:System.Data.XmlTreeGen.AddXdoProperty(System.ComponentModel.PropertyDescriptor,System.Object,System.Xml.XmlElement,System.Xml.XmlDocument) + M:System.Data.DataTable.ReadXml(System.Xml.XmlReader,System.Data.XmlReadMode,System.Boolean) ILLink IL2026 member - M:System.Data.XSDSchema.SetExtProperties(System.Object,System.Xml.XmlAttribute[]) + M:System.Data.DataTable.WriteXmlCore(System.Xml.XmlWriter) ILLink IL2026 member - M:System.Data.XSDSchema.SetExtProperties(System.Object,System.Xml.XmlAttributeCollection) + M:System.Data.DataView.SetRowFilter(System.String) ILLink IL2026 member - M:System.Data.XSDSchema.SetProperties(System.Object,System.Xml.XmlAttribute[]) + M:System.Data.DataView.System.ComponentModel.IBindingListView.set_Filter(System.String) ILLink - IL2067 - member - M:System.Data.XMLSchema.GetConverter(System.Type) - - - ILLink - IL2026 + IL2072 member - M:System.Data.Common.ObjectStorage.ConvertObjectToXml(System.Object) + M:System.Data.ProviderBase.SchemaMapping.SetupSchemaWithKeyInfo(System.Data.MissingMappingAction,System.Data.MissingSchemaAction,System.Boolean,System.Data.DataColumn,System.Object) ILLink IL2026 member - M:System.Data.Common.ObjectStorage.ConvertObjectToXml(System.Object,System.Xml.XmlWriter,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.ProviderBase.SchemaMapping.SetupSchemaWithKeyInfo(System.Data.MissingMappingAction,System.Data.MissingSchemaAction,System.Boolean,System.Data.DataColumn,System.Object) ILLink - IL2026 + IL2072 member - M:System.Data.Common.ObjectStorage.ConvertObjectToXml(System.Object,System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.ProviderBase.SchemaMapping.SetupSchemaWithoutKeyInfo(System.Data.MissingMappingAction,System.Data.MissingSchemaAction,System.Boolean,System.Data.DataColumn,System.Object) ILLink IL2026 member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.Common.DbConnectionStringBuilder.GetProperties(System.Collections.Hashtable) ILLink IL2026 member - M:System.Data.Common.SqlUdtStorage.ConvertObjectToXml(System.Object) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetAttributes ILLink IL2026 member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.Object) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetClassName ILLink IL2026 member - M:System.Data.Common.ObjectStorage.ConvertXmlToObject(System.String) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetComponentName ILLink IL2026 member - M:System.Data.Common.SqlUdtStorage.ConvertObjectToXml(System.Object,System.Xml.XmlWriter,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetConverter ILLink IL2026 member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.String) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultEvent ILLink IL2026 member - M:System.Data.Common.SqlUdtStorage.ConvertXmlToObject(System.Xml.XmlReader,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultProperty ILLink IL2026 member - M:System.Data.Common.ObjectStorage.GetXmlSerializer(System.Type) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEditor(System.Type) ILLink IL2026 member - M:System.Data.Common.ObjectStorage.GetXmlSerializer(System.Type,System.Xml.Serialization.XmlRootAttribute) + M:System.Data.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEvents diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/BigIntegerStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/BigIntegerStorage.cs index fdff3ed6ab990..2aa92e1044583 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/BigIntegerStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/BigIntegerStorage.cs @@ -4,6 +4,7 @@ using System.Numerics; using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -149,11 +150,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return BigInteger.Parse(s, System.Globalization.CultureInfo.InvariantCulture); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return ((BigInteger)value).ToString("D", System.Globalization.CultureInfo.InvariantCulture); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/BooleanStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/BooleanStorage.cs index 99e6ce414dab3..3ccb79e49d6fc 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/BooleanStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/BooleanStorage.cs @@ -4,6 +4,7 @@ using System.Xml; using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -169,11 +170,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToBoolean(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((bool)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs index 1fd8b9dbc7667..c8a777db67b6b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs @@ -4,6 +4,7 @@ using System.Xml; using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -241,11 +242,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToByte(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((byte)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/CharStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/CharStorage.cs index 72027fea73c3a..a8d9a78d87b0d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/CharStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/CharStorage.cs @@ -4,6 +4,7 @@ using System.Xml; using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -173,11 +174,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToChar(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((char)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs index 7472c15a749fd..827f442ab2c1e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs @@ -1318,6 +1318,7 @@ public DbCommand GetInsertCommand(bool useColumnsForParameterNames) { return GetInsertCommand(null, useColumnsForParameterNames); } + internal DbCommand GetInsertCommand(DataRow? dataRow, bool useColumnsForParameterNames) { BuildCache(true, dataRow, useColumnsForParameterNames); @@ -1329,10 +1330,12 @@ public DbCommand GetUpdateCommand() { return GetUpdateCommand(null, false); } + public DbCommand GetUpdateCommand(bool useColumnsForParameterNames) { return GetUpdateCommand(null, useColumnsForParameterNames); } + internal DbCommand GetUpdateCommand(DataRow? dataRow, bool useColumnsForParameterNames) { BuildCache(true, dataRow, useColumnsForParameterNames); @@ -1344,10 +1347,12 @@ public DbCommand GetDeleteCommand() { return GetDeleteCommand(null, false); } + public DbCommand GetDeleteCommand(bool useColumnsForParameterNames) { return GetDeleteCommand(null, useColumnsForParameterNames); } + internal DbCommand GetDeleteCommand(DataRow? dataRow, bool useColumnsForParameterNames) { BuildCache(true, dataRow, useColumnsForParameterNames); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DBSchemaRow.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DBSchemaRow.cs index 438433e3b4a9e..544ef90481dde 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DBSchemaRow.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DBSchemaRow.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace System.Data.Common @@ -27,8 +28,8 @@ internal static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool retu }; DbSchemaTable schemaTable = new DbSchemaTable(dataTable, returnProviderSpecificTypes); - const DataViewRowState rowStates = DataViewRowState.Unchanged | DataViewRowState.Added | DataViewRowState.ModifiedCurrent; - DataRow[] dataRows = dataTable.Select(null, "ColumnOrdinal ASC", rowStates); + + DataRow[] dataRows = SelectRows(dataTable, returnProviderSpecificTypes); Debug.Assert(null != dataRows, "GetSchemaRows: unexpected null dataRows"); DbSchemaRow[] schemaRows = new DbSchemaRow[dataRows.Length]; @@ -40,6 +41,14 @@ internal static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool retu return schemaRows; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Filter expression is null.")] + private static DataRow[] SelectRows(DataTable dataTable, bool returnProviderSpecificTypes) + { + const DataViewRowState rowStates = DataViewRowState.Unchanged | DataViewRowState.Added | DataViewRowState.ModifiedCurrent; + return dataTable.Select(null, "ColumnOrdinal ASC", rowStates); + } + internal DbSchemaRow(DbSchemaTable schemaTable, DataRow dataRow) { _schemaTable = schemaTable; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMapping.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMapping.cs index 7f53c995836c4..6c896aae0c564 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMapping.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMapping.cs @@ -71,13 +71,13 @@ object ICloneable.Clone() } [EditorBrowsable(EditorBrowsableState.Advanced)] - public DataColumn? GetDataColumnBySchemaAction(DataTable dataTable, Type? dataType, MissingSchemaAction schemaAction) + public DataColumn? GetDataColumnBySchemaAction(DataTable dataTable, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type? dataType, MissingSchemaAction schemaAction) { return GetDataColumnBySchemaAction(SourceColumn, DataSetColumn, dataTable, dataType, schemaAction); } [EditorBrowsable(EditorBrowsableState.Advanced)] - public static DataColumn? GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, DataTable dataTable, Type? dataType, MissingSchemaAction schemaAction) + public static DataColumn? GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, DataTable dataTable, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type? dataType, MissingSchemaAction schemaAction) { if (null == dataTable) { @@ -112,7 +112,7 @@ object ICloneable.Clone() return CreateDataColumnBySchemaAction(sourceColumn, dataSetColumn, dataTable, dataType, schemaAction); } - internal static DataColumn? CreateDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, DataTable dataTable, Type? dataType, MissingSchemaAction schemaAction) + internal static DataColumn? CreateDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, DataTable dataTable, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type? dataType, MissingSchemaAction schemaAction) { Debug.Assert(dataTable != null, "Should not call with a null DataTable"); if (string.IsNullOrEmpty(dataSetColumn)) diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMappingCollection.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMappingCollection.cs index 7c6776d35db68..a929eb679faf6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMappingCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataColumnMappingCollection.cs @@ -442,7 +442,7 @@ internal void ValidateSourceColumn(int index, string? value) } [EditorBrowsable(EditorBrowsableState.Advanced)] - public static DataColumn? GetDataColumn(DataColumnMappingCollection? columnMappings, string sourceColumn, Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction) + public static DataColumn? GetDataColumn(DataColumnMappingCollection? columnMappings, string sourceColumn, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction) { if (null != columnMappings) { 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 55cec5acc9737..1a8b361c17f7d 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 @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Data.SqlTypes; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Xml; using System.Xml.Serialization; @@ -269,19 +270,25 @@ public virtual void SetCapacity(int capacity) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public abstract object ConvertXmlToObject(string s); + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public virtual object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib) { return ConvertXmlToObject(xmlReader.Value); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public abstract string ConvertObjectToXml(object value); + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public virtual void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRootAttribute? xmlAttrib) { xmlWriter.WriteString(ConvertObjectToXml(value)); // should it be NO OP? } - public static DataStorage CreateStorage(DataColumn column, Type dataType, StorageType typeCode) + public static DataStorage CreateStorage(DataColumn column, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type dataType, StorageType typeCode) { Debug.Assert(typeCode == GetStorageType(dataType), "Incorrect storage type specified"); if ((StorageType.Empty == typeCode) && (null != dataType)) @@ -557,6 +564,7 @@ protected void SetNullStorage(BitArray nullbits) /// Types like "System.Data.SqlTypes.SqlString" will load because they are in the same assembly as this code /// Types like "System.Numerics.BigInteger" won't load because they are not special and not same assembly as this code /// + [RequiresUnreferencedCode("Calls Type.GetType")] internal static Type GetType(string value) { Type? dataType = Type.GetType(value); // throwOnError=false, ignoreCase=fase diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataTableMapping.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataTableMapping.cs index cbf3743a207f5..5d89922c19a9a 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataTableMapping.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataTableMapping.cs @@ -112,7 +112,7 @@ object ICloneable.Clone() } [EditorBrowsable(EditorBrowsableState.Advanced)] - public DataColumn? GetDataColumn(string sourceColumn, Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction) + public DataColumn? GetDataColumn(string sourceColumn, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction) { return DataColumnMappingCollection.GetDataColumn(_columnMappings, sourceColumn, dataType, dataTable, mappingAction, schemaAction); } diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeOffsetStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeOffsetStorage.cs index aca975ea779e8..72b9db7e9e6e6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeOffsetStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeOffsetStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -176,11 +177,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToDateTimeOffset(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((DateTimeOffset)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeStorage.cs index 30337abccad75..47feb27cf0010 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DateTimeStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -215,6 +216,7 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { object retValue; @@ -229,6 +231,7 @@ public override object ConvertXmlToObject(string s) return retValue; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { string retValue; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs index b1e417ec7d14c..1579d01e143e3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Data.ProviderBase; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs index 2ad35f787cdee..39ae170ad537f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs @@ -17,12 +17,13 @@ public static partial class DbProviderFactories { private struct ProviderRegistration { - internal ProviderRegistration(string factoryTypeAssemblyQualifiedName, DbProviderFactory? factoryInstance) + internal ProviderRegistration([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] string factoryTypeAssemblyQualifiedName, DbProviderFactory? factoryInstance) { this.FactoryTypeAssemblyQualifiedName = factoryTypeAssemblyQualifiedName; this.FactoryInstance = factoryInstance; } + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] internal string FactoryTypeAssemblyQualifiedName { get; } /// @@ -51,6 +52,7 @@ public static DbProviderFactory GetFactory(string providerInvariantName) return GetFactory(providerInvariantName, throwOnError: true)!; } + [RequiresUnreferencedCode("Provider type and its members might be trimmed if not referenced directly.")] public static DbProviderFactory GetFactory(DataRow providerRow) { ADP.CheckArgumentNull(providerRow, nameof(providerRow)); @@ -105,7 +107,7 @@ public static IEnumerable GetProviderInvariantNames() return _registeredFactories.Keys.ToList(); } - public static void RegisterFactory(string providerInvariantName, string factoryTypeAssemblyQualifiedName) + public static void RegisterFactory(string providerInvariantName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] string factoryTypeAssemblyQualifiedName) { ADP.CheckArgumentLength(providerInvariantName, nameof(providerInvariantName)); ADP.CheckArgumentLength(factoryTypeAssemblyQualifiedName, nameof(factoryTypeAssemblyQualifiedName)); @@ -114,7 +116,7 @@ public static void RegisterFactory(string providerInvariantName, string factoryT _registeredFactories[providerInvariantName] = new ProviderRegistration(factoryTypeAssemblyQualifiedName, null); } - public static void RegisterFactory(string providerInvariantName, Type providerFactoryClass) + public static void RegisterFactory(string providerInvariantName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] Type providerFactoryClass) { RegisterFactory(providerInvariantName, GetFactoryInstance(providerFactoryClass)); } @@ -163,7 +165,7 @@ public static bool UnregisterFactory(string providerInvariantName) return toReturn; } - private static DbProviderFactory GetFactoryInstance(Type providerFactoryClass) + private static DbProviderFactory GetFactoryInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] Type providerFactoryClass) { ADP.CheckArgumentNull(providerFactoryClass, nameof(providerFactoryClass)); if (!providerFactoryClass.IsSubclassOf(typeof(DbProviderFactory))) @@ -188,8 +190,8 @@ private static DbProviderFactory GetFactoryInstance(Type providerFactoryClass) return (DbProviderFactory)factory; } - - private static Type GetProviderTypeFromTypeName(string assemblyQualifiedName) + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] + private static Type GetProviderTypeFromTypeName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] string assemblyQualifiedName) { Type? providerType = Type.GetType(assemblyQualifiedName); if (null == providerType) diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactory.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactory.cs index 70ad0e96c6b92..6065bc6acd8e2 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactory.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactory.cs @@ -1,8 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; + namespace System.Data.Common { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] public abstract partial class DbProviderFactory { private bool? _canCreateDataAdapter; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs index a102ae412be95..5c145272abb93 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -237,11 +238,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToDecimal(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((decimal)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs index e27658bfbf9d1..73f17e241e96f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -241,11 +242,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToDouble(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((double)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs index ba44cf199a829..ceac9585cb383 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -255,11 +256,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToInt16(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((short)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs index 015d46bf7bc24..11da865400b63 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -254,11 +255,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToInt32(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((int)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs index 2a6dbc03caf36..bb0f519ada080 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -246,11 +247,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToInt64(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((long)value); 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 a59749d46aa16..aa06791989d6e 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 @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Dynamic; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -306,6 +307,7 @@ public override void SetCapacity(int capacity) // 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(string s) { Type type = _dataType; // real type of objects in this column @@ -346,6 +348,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) { object? retValue = null; @@ -441,9 +444,11 @@ public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute XmlSerializer deserializerWithRootAttribute = ObjectStorage.GetXmlSerializer(_dataType, xmlAttrib); retValue = deserializerWithRootAttribute.Deserialize(xmlReader); } + return retValue!; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { if ((value == null) || (value == _nullValue))// this case won't happen, this is added in case if code in xml saver changes @@ -484,6 +489,7 @@ public override string ConvertObjectToXml(object value) return strwriter.ToString(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRootAttribute? xmlAttrib) { if (null == xmlAttrib) @@ -551,6 +557,7 @@ internal static void VerifyIDynamicMetaObjectProvider(Type type) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal static XmlSerializer GetXmlSerializer(Type type) { // prevent writing an instance which implements IDynamicMetaObjectProvider and not IXmlSerializable @@ -562,6 +569,7 @@ internal static XmlSerializer GetXmlSerializer(Type type) return serializer; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal static XmlSerializer GetXmlSerializer(Type type, XmlRootAttribute attribute) { XmlSerializer? serializer = null; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs index b6ddd9fad0be5..dc58d20033c06 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -243,11 +244,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToSByte(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((sbyte)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs index ce27245f79a9a..ca43ad5b67379 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -98,6 +99,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlBinary newValue = default; @@ -113,6 +115,7 @@ public override object ConvertXmlToObject(string s) return ((SqlBinary)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we should have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs index 8b15f07739032..85b4ea53891fa 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -208,6 +209,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlByte newValue = default; @@ -223,6 +225,7 @@ public override object ConvertXmlToObject(string s) return ((SqlByte)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs index 76ba3946f7a98..b3744e9a9201d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Data.SqlTypes; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Xml; using System.Xml.Serialization; @@ -96,6 +97,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlBinary newValue = default; @@ -111,6 +113,7 @@ public override object ConvertXmlToObject(string s) return (new SqlBytes((SqlBinary)tmp)); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs index 74dc0329170eb..2910a01853a4f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs @@ -7,6 +7,7 @@ using System.Data.SqlTypes; using System.Diagnostics; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -98,6 +99,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlString newValue = default; @@ -114,6 +116,7 @@ public override object ConvertXmlToObject(string s) return (new SqlChars((SqlString)tmp)); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs index e36e4e03a3ae1..467c856d89f2e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -134,6 +135,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlDateTime newValue = default; @@ -149,6 +151,7 @@ public override object ConvertXmlToObject(string s) return ((SqlDateTime)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs index 9245967133ec6..fb2e0b30c8771 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -206,6 +207,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlDecimal newValue = default; @@ -221,6 +223,7 @@ public override object ConvertXmlToObject(string s) return ((SqlDecimal)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs index df041e6774425..a9e78552afe9f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -207,6 +208,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlDouble newValue = default; @@ -222,6 +224,7 @@ public override object ConvertXmlToObject(string s) return ((SqlDouble)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs index bb91efab77c67..38301908ccb59 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -99,6 +100,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlGuid newValue = default; @@ -114,6 +116,7 @@ public override object ConvertXmlToObject(string s) return ((SqlGuid)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs index 17f1aac7213ca..e210830f4bc90 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -207,6 +208,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlInt16 newValue = default; @@ -222,6 +224,7 @@ public override object ConvertXmlToObject(string s) return ((SqlInt16)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs index dd48d0237f2f1..d2a1b8118f702 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -207,6 +208,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlInt32 newValue = default; @@ -222,6 +224,7 @@ public override object ConvertXmlToObject(string s) return ((SqlInt32)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs index e469f3218b5b1..83d7e548f084c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -208,6 +209,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlInt64 newValue = default; @@ -223,6 +225,7 @@ public override object ConvertXmlToObject(string s) return ((SqlInt64)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs index a036989e6d846..f220e760f4ebb 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -207,6 +208,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlMoney newValue = default; @@ -222,6 +224,7 @@ public override object ConvertXmlToObject(string s) return ((SqlMoney)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs index 7a492b2638205..1250ed55ec495 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -205,6 +206,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlSingle newValue = default; @@ -220,6 +222,7 @@ public override object ConvertXmlToObject(string s) return ((SqlSingle)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we should have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs index 7e8094c93610c..d9413cd0e357d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -160,6 +161,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlString newValue = default; @@ -175,6 +177,7 @@ public override object ConvertXmlToObject(string s) return ((SqlString)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we shouldn't have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs index 4bfadc6eb0857..c8f7cdd257faf 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs @@ -7,6 +7,7 @@ using System.IO; using System.Xml.Serialization; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -132,6 +133,7 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { SqlBoolean newValue = default; @@ -147,6 +149,7 @@ public override object ConvertXmlToObject(string s) return ((SqlBoolean)tmp); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { Debug.Assert(!DataStorage.IsObjectNull(value), "we should have null here"); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs index 3b10386f663dc..d7f0f5884b67c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -242,11 +243,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToSingle(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((float)value); 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 1743d3f667a0e..16aea8a6c0bb2 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 @@ -10,6 +10,7 @@ using System.Runtime.CompilerServices; using System.Collections.Concurrent; using System.Reflection; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -21,7 +22,7 @@ internal sealed class SqlUdtStorage : DataStorage private static readonly ConcurrentDictionary s_typeToNull = new ConcurrentDictionary(); - public SqlUdtStorage(DataColumn column, Type type) + public SqlUdtStorage(DataColumn column, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type) : this(column, type, GetStaticNullForUdtType(type)) { } @@ -34,7 +35,11 @@ private SqlUdtStorage(DataColumn column, Type type, object nullValue) } // to support oracle types and other INUllable types that have static Null as field - internal static object GetStaticNullForUdtType(Type type) => s_typeToNull.GetOrAdd(type, t => + internal static object GetStaticNullForUdtType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type) => s_typeToNull.GetOrAdd(type, t => GetStaticNullForUdtTypeCore(type)); + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", + Justification = "The only callsite is marked with DynamicallyAccessedMembers. Workaround for https://github.com/mono/linker/issues/1981")] + private static object GetStaticNullForUdtTypeCore(Type type) { // TODO: Is it OK for the null value of a UDT to be null? For now annotating is non-nullable. PropertyInfo? propInfo = type.GetProperty("Null", BindingFlags.Public | BindingFlags.Static); @@ -50,7 +55,7 @@ internal static object GetStaticNullForUdtType(Type type) => s_typeToNull.GetOrA } throw ExceptionBuilder.INullableUDTwithoutStaticNull(type.AssemblyQualifiedName!); - }); + } public override bool IsNull(int record) { @@ -143,6 +148,7 @@ public override void SetCapacity(int capacity) // 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(string s) { if (_implementsIXmlSerializable) @@ -166,6 +172,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) { if (null == xmlAttrib) @@ -192,7 +199,7 @@ public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute } } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { StringWriter strwriter = new StringWriter(FormatProvider); @@ -211,6 +218,7 @@ public override string ConvertObjectToXml(object value) return (strwriter.ToString()); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRootAttribute? xmlAttrib) { if (null == xmlAttrib) diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs index fa919b377e891..db06db53dcd33 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -186,11 +187,13 @@ public override void SetCapacity(int capacity) _values = newValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return s; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return (string)value; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/TimeSpanStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/TimeSpanStorage.cs index 5ce9037b61bef..b6fbd8a7ac3d3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/TimeSpanStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/TimeSpanStorage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -261,11 +262,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToTimeSpan(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((TimeSpan)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs index 25d3b7c80d814..a8a75051ef01c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -254,11 +255,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToUInt16(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((ushort)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs index b801841aa1e0f..53a815a262a86 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -253,11 +254,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToUInt32(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((uint)value); diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs index 9dc67b24137cf..fa18cdee966a6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -244,11 +245,13 @@ public override void SetCapacity(int capacity) base.SetCapacity(capacity); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override object ConvertXmlToObject(string s) { return XmlConvert.ToUInt64(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public override string ConvertObjectToXml(object value) { return XmlConvert.ToString((ulong)value); 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 eec4b1d090f54..796ea59699d03 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs @@ -26,11 +26,13 @@ namespace System.Data [DefaultProperty(nameof(ColumnName))] [Editor("Microsoft.VSDesigner.Data.Design.DataColumnEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] // needed by Clone() to preserve derived ctors public class DataColumn : MarshalByValueComponent { private bool _allowNull = true; private string? _caption; private string _columnName; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] private Type _dataType = null!; // Always set in UpdateColumnType private StorageType _storageType; internal object _defaultValue = DBNull.Value; // DefaultValue Converter @@ -76,6 +78,8 @@ public class DataColumn : MarshalByValueComponent /// Initializes a new instance of a /// class. /// + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This is safe because type is string and expression is null.")] public DataColumn() : this(null, typeof(string), null, MappingType.Element) { } @@ -84,6 +88,8 @@ public DataColumn() : this(null, typeof(string), null, MappingType.Element) /// Initializes a new instance of the class /// using the specified column name. /// + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This is safe because type is string and expression is null.")] public DataColumn(string? columnName) : this(columnName, typeof(string), null, MappingType.Element) { } @@ -92,7 +98,9 @@ public DataColumn(string? columnName) : this(columnName, typeof(string), null, M /// Initializes a new instance of the class /// using the specified column name and data type. /// - public DataColumn(string? columnName, Type dataType) : this(columnName, dataType, null, MappingType.Element) + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Expression is null and `dataType` is marked appropriately.")] + public DataColumn(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type dataType) : this(columnName, dataType, null, MappingType.Element) { } @@ -101,7 +109,8 @@ public DataColumn(string? columnName, Type dataType) : this(columnName, dataType /// of the class /// using the specified name, data type, and expression. /// - public DataColumn(string? columnName, Type dataType, string? expr) : this(columnName, dataType, expr, MappingType.Element) + [RequiresUnreferencedCode("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")] + public DataColumn(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type dataType, string? expr) : this(columnName, dataType, expr, MappingType.Element) { } @@ -111,7 +120,8 @@ public DataColumn(string? columnName, Type dataType, string? expr) : this(column /// the specified name, data type, expression, and value that determines whether the /// column is an attribute. /// - public DataColumn(string? columnName, Type dataType, string? expr, MappingType type) + [RequiresUnreferencedCode("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")] + public DataColumn(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type dataType, string? expr, MappingType type) { GC.SuppressFinalize(this); DataCommonEventSource.Log.Trace(" {0}, columnName='{1}', expr='{2}', type={3}", ObjectID, columnName, expr, type); @@ -143,7 +153,7 @@ public DataColumn(string? columnName, Type dataType, string? expr, MappingType t _columnMapping = type; } - private void UpdateColumnType(Type type, StorageType typeCode) + private void UpdateColumnType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type, StorageType typeCode) { TypeLimiter.EnsureTypeIsAllowed(type); _dataType = type; @@ -449,6 +459,7 @@ public string Prefix // If the column type is string and it's value is empty, then the empty string is returned. // If the column type is not string, or the column type is string and the value is not empty string, then a non-empty string is returned // This method does not throw any formatting exceptions, since we can always format the field value to a string. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal string? GetColumnValueAsString(DataRow row, DataRowVersion version) { object objValue = this[row.GetRecordFromVersion(version)]; @@ -479,6 +490,7 @@ public string Prefix [DefaultValue(typeof(string))] [RefreshProperties(RefreshProperties.All)] [TypeConverter(typeof(ColumnTypeConverter))] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] [AllowNull] public Type DataType { @@ -716,6 +728,7 @@ public object DefaultValue public string Expression { get { return (_expression == null ? "" : _expression.Expression); } + [RequiresUnreferencedCode("Members from types used in the expressions may be trimmed if not referenced directly.")] set { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, '{1}'", ObjectID, value); @@ -1777,24 +1790,27 @@ public override string ToString() => _expression == null ? ColumnName : ColumnName + " + " + Expression; + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal object ConvertXmlToObject(string s) { Debug.Assert(s != null, "Caller is resposible for missing element/attribute case"); return InsureStorage().ConvertXmlToObject(s); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib) { return InsureStorage().ConvertXmlToObject(xmlReader, xmlAttrib); } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal string ConvertObjectToXml(object value) { Debug.Assert(value != null && (value != DBNull.Value), "Caller is resposible for checking on DBNull"); return InsureStorage().ConvertObjectToXml(value); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRootAttribute? xmlAttrib) { Debug.Assert(value != null && (value != DBNull.Value), "Caller is resposible for checking on DBNull"); @@ -1812,6 +1828,7 @@ internal void CopyValueIntoStore(int record, object store, BitArray nullbits, in _storage.CopyValueInternal(record, store, nullbits, storeIndex); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SetStorage(object store, BitArray nullbits) { InsureStorage().SetStorageInternal(store, nullbits); @@ -1875,6 +1892,14 @@ internal void HandleDependentColumnList(DataExpression? oldExpression, DataExpre _table.AddDependentColumn(this); } } + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "User has already got warning when creating original column.")] + internal void CopyExpressionFrom(DataColumn source) + { + Expression = source.Expression; + } + } internal abstract class AutoIncrementValue diff --git a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs index 5a8742ae06965..cfe21932b0a1e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs @@ -182,7 +182,7 @@ internal void AddAt(int index, DataColumn column) } if (!_table.fInitInProgress && column != null && column.Computed) { - column.Expression = column.Expression; + column.CopyExpressionFrom(column); } OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, column)); } @@ -211,7 +211,8 @@ public void AddRange(DataColumn[] columns) /// Creates and adds a /// with the specified name, type, and compute expression to the columns collection. /// - public DataColumn Add(string? columnName, Type type, string expression) + [RequiresUnreferencedCode("Members might be trimmed for some data types or expressions.")] + public DataColumn Add(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type, string expression) { var column = new DataColumn(columnName, type, expression); Add(column); @@ -223,7 +224,7 @@ public DataColumn Add(string? columnName, Type type, string expression) /// with the /// specified name and type to the columns collection. /// - public DataColumn Add(string? columnName, Type type) + public DataColumn Add(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type) { var column = new DataColumn(columnName, type); Add(column); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRow.cs b/src/libraries/System.Data.Common/src/System/Data/DataRow.cs index aab6210014ab3..19b725110bb14 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRow.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRow.cs @@ -1360,6 +1360,7 @@ internal void SetParentRowToDBNull(DataRelation relation) parentKeyValues[0] = DBNull.Value; SetKeyValues(relation.ChildKey, parentKeyValues); } + public void SetAdded() { if (RowState == DataRowState.Unchanged) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs index 9e4a168c8822b..7543cb5b3b142 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs @@ -30,8 +30,10 @@ namespace System.Data [XmlSchemaProvider(nameof(GetDataSetSchema))] [XmlRoot(nameof(DataSet))] [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors)] // needed by Clone() to preserve derived ctors public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, ISupportInitializeNotification, ISerializable { + internal const string RequiresUnreferencedCodeMessage = "Members from serialized types may be trimmed if not referenced directly."; private const string KEY_XMLSCHEMA = "XmlSchema"; private const string KEY_XMLDIFFGRAM = "XmlDiffGram"; @@ -203,6 +205,7 @@ protected SchemaSerializationMode DetermineSchemaSerializationMode(XmlReader rea // Deserialize all the tables data of the dataset from binary/xml stream. // 'instance' method that consumes SerializationInfo + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected void GetSerializationData(SerializationInfo info, StreamingContext context) { // mainly for typed DS @@ -223,10 +226,12 @@ protected void GetSerializationData(SerializationInfo info, StreamingContext con // Deserialize all the tables schema and data of the dataset from binary/xml stream. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected DataSet(SerializationInfo info, StreamingContext context) : this(info, context, true) { } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected DataSet(SerializationInfo info, StreamingContext context, bool ConstructSchema) : this() { SerializationFormat remotingFormat = SerializationFormat.Xml; @@ -273,6 +278,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte protected virtual void InitializeDerivedDataSet() { } // Serialize all the tables. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void SerializeDataSet(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat) { Debug.Assert(info != null); @@ -358,6 +364,7 @@ private void SerializeDataSet(SerializationInfo info, StreamingContext context, } // Deserialize all the tables - marked internal so that DataTable can call into this + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal void DeserializeDataSet(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat, SchemaSerializationMode schemaSerializationMode) { // deserialize schema @@ -367,6 +374,7 @@ internal void DeserializeDataSet(SerializationInfo info, StreamingContext contex } // Deserialize schema. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void DeserializeDataSetSchema(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat, SchemaSerializationMode schemaSerializationMode) { if (remotingFormat != SerializationFormat.Xml) @@ -425,6 +433,7 @@ private void DeserializeDataSetSchema(SerializationInfo info, StreamingContext c } // Deserialize all data. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void DeserializeDataSetData(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat) { if (remotingFormat != SerializationFormat.Xml) @@ -1088,6 +1097,13 @@ public void Clear() } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Only parameterless constructors are used here but since nonPublic=true, all non-public constructors are being preserved causing a warning for the serialization constructors. Those constructors won't be used here.")] + private DataSet CreateInstanceOfThisType() + { + return (DataSet)Activator.CreateInstance(GetType(), true)!; + } + /// /// Clones the structure of the , including all schemas, relations, and /// constraints. @@ -1099,7 +1115,7 @@ public virtual DataSet Clone() long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); try { - DataSet ds = (DataSet)Activator.CreateInstance(GetType(), true)!; + DataSet ds = CreateInstanceOfThisType(); if (ds.Tables.Count > 0) // To clean up all the schema in strong typed dataset. { @@ -1173,7 +1189,7 @@ public virtual DataSet Clone() { if (col.Expression.Length != 0) { - ds.Tables[table.TableName, table.Namespace]!.Columns[col.ColumnName]!.Expression = col.Expression; + ds.Tables[table.TableName, table.Namespace]!.Columns[col.ColumnName]!.CopyExpressionFrom(col); } } } @@ -1395,11 +1411,12 @@ private void MarkRelatedRowsAsModified(TableChanges[] bitMatrix, DataRow row) } } -// TODO: Enable after System.ComponentModel.TypeConverter is annotated + // TODO: Enable after System.ComponentModel.TypeConverter is annotated #nullable disable IList IListSource.GetList() => DefaultViewManager; #nullable enable + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal string GetRemotingDiffGram(DataTable table) { StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1411,6 +1428,7 @@ internal string GetRemotingDiffGram(DataTable table) return strWriter.ToString(); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public string GetXml() { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); @@ -1430,6 +1448,7 @@ public string GetXml() } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public string GetXmlSchema() { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); @@ -1448,6 +1467,7 @@ public string GetXmlSchema() } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal string GetXmlSchemaForRemoting(DataTable? table) { StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1520,6 +1540,7 @@ public bool HasChanges(DataRowState rowStates) /// /// Infer the XML schema from the specified into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void InferXmlSchema(XmlReader? reader, string[]? nsArray) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); @@ -1557,6 +1578,7 @@ public void InferXmlSchema(XmlReader? reader, string[]? nsArray) /// /// Infer the XML schema from the specified into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void InferXmlSchema(Stream? stream, string[]? nsArray) { if (stream == null) @@ -1570,6 +1592,7 @@ public void InferXmlSchema(Stream? stream, string[]? nsArray) /// /// Infer the XML schema from the specified into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void InferXmlSchema(TextReader? reader, string[]? nsArray) { if (reader == null) @@ -1583,6 +1606,7 @@ public void InferXmlSchema(TextReader? reader, string[]? nsArray) /// /// Infer the XML schema from the specified file into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void InferXmlSchema(string fileName, string[]? nsArray) { XmlTextReader xr = new XmlTextReader(fileName); @@ -1599,8 +1623,10 @@ public void InferXmlSchema(string fileName, string[]? nsArray) /// /// Reads the XML schema from the specified into the /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(XmlReader? reader) => ReadXmlSchema(reader, false); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal void ReadXmlSchema(XmlReader? reader, bool denyResolving) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, reader, denyResolving={1}", ObjectID, denyResolving); @@ -1745,6 +1771,7 @@ internal void ReadEndElement(XmlReader reader) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal void ReadXSDSchema(XmlReader reader, bool denyResolving) { XmlSchemaSet sSet = new XmlSchemaSet(); @@ -1784,6 +1811,7 @@ internal void ReadXSDSchema(XmlReader reader, bool denyResolving) schema.LoadSchema(sSet, this); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal void ReadXDRSchema(XmlReader reader) { XmlDocument xdoc = new XmlDocument(); // we may need this to infer the schema @@ -1798,6 +1826,7 @@ internal void ReadXDRSchema(XmlReader reader) /// Reads the XML schema from the specified into the /// . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(Stream? stream) { if (stream == null) @@ -1811,6 +1840,7 @@ public void ReadXmlSchema(Stream? stream) /// /// Reads the XML schema from the specified into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(TextReader? reader) { if (reader == null) @@ -1824,6 +1854,7 @@ public void ReadXmlSchema(TextReader? reader) /// /// Reads the XML schema from the specified file into the . /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(string fileName) { XmlTextReader xr = new XmlTextReader(fileName); @@ -1840,11 +1871,13 @@ public void ReadXmlSchema(string fileName) #region WriteXmlSchema /// Writes the structure as an XML schema to using the specified object. /// A object used to write to a file. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(Stream? stream) => WriteXmlSchema(stream, SchemaFormat.Public, null); /// Writes the structure as an XML schema to using the specified object. /// A object used to write to a file. /// A delegate used to convert into string. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(Stream? stream, Converter multipleTargetConverter) { ADP.CheckArgumentNull(multipleTargetConverter, nameof(multipleTargetConverter)); @@ -1853,11 +1886,13 @@ public void WriteXmlSchema(Stream? stream, Converter multipleTarge /// Writes the structure as an XML schema to a file. /// The file name (including the path) to which to write. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(string fileName) => WriteXmlSchema(fileName, SchemaFormat.Public, null); /// Writes the structure as an XML schema to a file. /// The file name (including the path) to which to write. /// A delegate used to convert into string. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(string fileName, Converter multipleTargetConverter) { ADP.CheckArgumentNull(multipleTargetConverter, nameof(multipleTargetConverter)); @@ -1866,11 +1901,13 @@ public void WriteXmlSchema(string fileName, Converter multipleTarg /// Writes the structure as an XML schema to a object. /// The object with which to write. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(TextWriter? writer) => WriteXmlSchema(writer, SchemaFormat.Public, null); /// Writes the structure as an XML schema to a object. /// The object with which to write. /// A delegate used to convert into string. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(TextWriter? writer, Converter multipleTargetConverter) { ADP.CheckArgumentNull(multipleTargetConverter, nameof(multipleTargetConverter)); @@ -1879,17 +1916,20 @@ public void WriteXmlSchema(TextWriter? writer, Converter multipleT /// Writes the structure as an XML schema to an object. /// The object with which to write. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(XmlWriter? writer) => WriteXmlSchema(writer, SchemaFormat.Public, null); /// Writes the structure as an XML schema to an object. /// The object with which to write. /// A delegate used to convert into string. + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(XmlWriter? writer, Converter multipleTargetConverter) { ADP.CheckArgumentNull(multipleTargetConverter, nameof(multipleTargetConverter)); WriteXmlSchema(writer, SchemaFormat.Public, multipleTargetConverter); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void WriteXmlSchema(string fileName, SchemaFormat schemaFormat, Converter? multipleTargetConverter) { XmlTextWriter xw = new XmlTextWriter(fileName, null); @@ -1906,6 +1946,7 @@ private void WriteXmlSchema(string fileName, SchemaFormat schemaFormat, Converte } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void WriteXmlSchema(Stream? stream, SchemaFormat schemaFormat, Converter? multipleTargetConverter) { if (stream == null) @@ -1919,6 +1960,7 @@ private void WriteXmlSchema(Stream? stream, SchemaFormat schemaFormat, Converter WriteXmlSchema(w, schemaFormat, multipleTargetConverter); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void WriteXmlSchema(TextWriter? writer, SchemaFormat schemaFormat, Converter? multipleTargetConverter) { if (writer == null) @@ -1932,6 +1974,7 @@ private void WriteXmlSchema(TextWriter? writer, SchemaFormat schemaFormat, Conve WriteXmlSchema(w, schemaFormat, multipleTargetConverter); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void WriteXmlSchema(XmlWriter? writer, SchemaFormat schemaFormat, Converter? multipleTargetConverter) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, schemaFormat={1}", ObjectID, schemaFormat); @@ -1962,8 +2005,10 @@ private void WriteXmlSchema(XmlWriter? writer, SchemaFormat schemaFormat, Conver } #endregion + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(XmlReader? reader) => ReadXml(reader, false); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal XmlReadMode ReadXml(XmlReader? reader, bool denyResolving) { IDisposable? restrictedScope = null; @@ -2243,6 +2288,7 @@ internal XmlReadMode ReadXml(XmlReader? reader, bool denyResolving) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(Stream? stream) { if (stream == null) @@ -2258,6 +2304,7 @@ public XmlReadMode ReadXml(Stream? stream) return ReadXml(xr, false); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(TextReader? reader) { if (reader == null) @@ -2273,6 +2320,7 @@ public XmlReadMode ReadXml(TextReader? reader) return ReadXml(xr, false); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(string fileName) { XmlTextReader xr = new XmlTextReader(fileName); @@ -2290,6 +2338,7 @@ public XmlReadMode ReadXml(string fileName) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal void InferSchema(XmlDocument xdoc, string[]? excludedNamespaces, XmlReadMode mode) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, mode={1}", ObjectID, mode); @@ -2341,6 +2390,7 @@ private bool IsEmpty() return true; } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] private void ReadXmlDiffgram(XmlReader reader) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); @@ -2471,8 +2521,10 @@ private void ReadXmlDiffgram(XmlReader reader) /// /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(XmlReader? reader, XmlReadMode mode) => ReadXml(reader, mode, false); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal XmlReadMode ReadXml(XmlReader? reader, XmlReadMode mode, bool denyResolving) { IDisposable? restictedScope = null; @@ -2726,6 +2778,7 @@ internal XmlReadMode ReadXml(XmlReader? reader, XmlReadMode mode, bool denyResol } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(Stream? stream, XmlReadMode mode) { if (stream == null) @@ -2739,6 +2792,7 @@ public XmlReadMode ReadXml(Stream? stream, XmlReadMode mode) return ReadXml(reader, mode, false); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(TextReader? reader, XmlReadMode mode) { if (reader == null) @@ -2752,6 +2806,7 @@ public XmlReadMode ReadXml(TextReader? reader, XmlReadMode mode) return ReadXml(xmlreader, mode, false); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(string fileName, XmlReadMode mode) { XmlTextReader? xr = null; @@ -2778,17 +2833,22 @@ public XmlReadMode ReadXml(string fileName, XmlReadMode mode) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream) => WriteXml(stream, XmlWriteMode.IgnoreSchema); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer) => WriteXml(writer, XmlWriteMode.IgnoreSchema); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer) => WriteXml(writer, XmlWriteMode.IgnoreSchema); + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName) => WriteXml(fileName, XmlWriteMode.IgnoreSchema); /// /// Writes schema and data for the DataSet. /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream, XmlWriteMode mode) { if (stream != null) @@ -2800,6 +2860,7 @@ public void WriteXml(Stream? stream, XmlWriteMode mode) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer, XmlWriteMode mode) { if (writer != null) @@ -2811,6 +2872,7 @@ public void WriteXml(TextWriter? writer, XmlWriteMode mode) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer, XmlWriteMode mode) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, mode={1}", ObjectID, mode); @@ -2837,6 +2899,7 @@ public void WriteXml(XmlWriter? writer, XmlWriteMode mode) } } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName, XmlWriteMode mode) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, fileName='{1}', mode={2}", ObjectID, fileName, (int)mode); @@ -3297,6 +3360,7 @@ internal bool ValidateLocaleConstraint() return null; } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected virtual void ReadXmlSerializable(XmlReader reader) { // does not mean DataSet is null,but it does not have any child diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 8b4c1083b6088..f3e89e19b64a4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -191,6 +191,7 @@ public DataTable(string? tableName, string? tableNamespace) : this(tableName) } // Deserialize the table from binary/xml stream. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] protected DataTable(SerializationInfo info, StreamingContext context) : this() { bool isSingleTable = context.Context != null ? Convert.ToBoolean(context.Context, CultureInfo.InvariantCulture) : true; @@ -217,6 +218,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte } // Serialize the table schema and data. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SerializeDataTable(SerializationInfo info, StreamingContext context, bool isSingleTable, SerializationFormat remotingFormat) { info.AddValue("DataTable.RemotingVersion", new Version(2, 0)); @@ -280,6 +282,7 @@ private void SerializeDataTable(SerializationInfo info, StreamingContext context } // Deserialize the table schema and data. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void DeserializeDataTable(SerializationInfo info, StreamingContext context, bool isSingleTable, SerializationFormat remotingFormat) { if (remotingFormat != SerializationFormat.Xml) @@ -321,6 +324,7 @@ internal void DeserializeDataTable(SerializationInfo info, StreamingContext cont } // Serialize the columns + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SerializeTableSchema(SerializationInfo info, StreamingContext context, bool isSingleTable) { //DataTable basic properties @@ -397,6 +401,7 @@ internal void SerializeTableSchema(SerializationInfo info, StreamingContext cont } // Deserialize all the Columns + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void DeserializeTableSchema(SerializationInfo info, StreamingContext context, bool isSingleTable) { //DataTable basic properties @@ -645,6 +650,7 @@ internal void SerializeExpressionColumns(SerializationInfo info, StreamingContex } // Deserialize the expressions on the table - Marked internal so that DataSet deserializer can call into this + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void DeserializeExpressionColumns(SerializationInfo info, StreamingContext context, int serIndex) { int colCount = Columns.Count; @@ -659,6 +665,7 @@ internal void DeserializeExpressionColumns(SerializationInfo info, StreamingCont } // Serialize all the Rows. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SerializeTableData(SerializationInfo info, StreamingContext context, int serIndex) { //Cache all the column count, row count @@ -744,6 +751,7 @@ internal void SerializeTableData(SerializationInfo info, StreamingContext contex } // Deserialize all the Rows. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void DeserializeTableData(SerializationInfo info, StreamingContext context, int serIndex) { bool enforceConstraintsOrg = _enforceConstraints; @@ -896,6 +904,7 @@ internal void GetRowAndColumnErrors(int rowIndex, Hashtable rowErrors, Hashtable } // Set the row and columns in error.. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void ConvertToRowError(int rowIndex, Hashtable rowErrors, Hashtable colErrors) { Debug.Assert(Rows.Count > rowIndex); @@ -1242,6 +1251,7 @@ public DataView DefaultView public string DisplayExpression { get { return DisplayExpressionInternal; } + [RequiresUnreferencedCode("Members from types used in the expressions may be trimmed if not referenced directly.")] set { _displayExpression = !string.IsNullOrEmpty(value) ? @@ -2005,7 +2015,7 @@ public virtual void EndInit() { if (dc.Computed) { - dc.Expression = dc.Expression; + dc.CopyExpressionFrom(dc); } } } @@ -2316,7 +2326,6 @@ internal DataTable Clone(DataSet? cloneDS) } } - private DataTable IncrementalCloneTo(DataTable sourceTable, DataTable targetTable) { foreach (DataColumn dc in sourceTable.Columns) @@ -2409,7 +2418,7 @@ private DataTable CloneTo(DataTable clone, DataSet? cloneDS, bool skipExpression { for (int i = 0; i < clmns.Count; i++) { - clone.Columns[clmns[i].ColumnName]!.Expression = clmns[i].Expression; + clone.Columns[clmns[i].ColumnName]!.CopyExpressionFrom(clmns[i]); } } @@ -2811,7 +2820,6 @@ internal void CheckNotModifying(DataRow row) /// /// Clears the table of all data. /// - public void Clear() => Clear(true); internal void Clear(bool clearAll) @@ -2946,6 +2954,7 @@ internal int Compare(string s1, string s2, CompareInfo? comparer) /// /// Computes the given expression on the current rows that pass the filter criteria. /// + [RequiresUnreferencedCode("Members of types used in the filter or expression might be trimmed.")] public object Compute(string? expression, string? filter) { DataRow[] rows = Select(filter, "", DataViewRowState.CurrentRows); @@ -3185,7 +3194,7 @@ internal Index GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, I return ndx; } -// TODO: Enable after System.ComponentModel.TypeConverter is annotated + // TODO: Enable after System.ComponentModel.TypeConverter is annotated #nullable disable IList IListSource.GetList() => DefaultView; @@ -4194,6 +4203,8 @@ internal void RollbackRow(DataRow row) /// /// Returns an array of all objects. /// + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Filter expression is empty therefore this is safe.")] public DataRow[] Select() { DataCommonEventSource.Log.Trace(" {0}", ObjectID); @@ -4204,6 +4215,7 @@ public DataRow[] Select() /// Returns an array of all objects that match the filter criteria in order of /// primary key (or lacking one, order of addition.) /// + [RequiresUnreferencedCode(Data.Select.RequiresUnreferencedCodeMessage)] public DataRow[] Select(string? filterExpression) { DataCommonEventSource.Log.Trace(" {0}, filterExpression='{1}'", ObjectID, filterExpression); @@ -4214,6 +4226,7 @@ public DataRow[] Select(string? filterExpression) /// Returns an array of all objects that match the filter criteria, in the /// specified sort order. /// + [RequiresUnreferencedCode(Data.Select.RequiresUnreferencedCodeMessage)] public DataRow[] Select(string? filterExpression, string? sort) { DataCommonEventSource.Log.Trace(" {0}, filterExpression='{1}', sort='{2}'", ObjectID, filterExpression, sort); @@ -4224,6 +4237,7 @@ public DataRow[] Select(string? filterExpression, string? sort) /// Returns an array of all objects that match the filter in the order of the /// sort, that match the specified state. /// + [RequiresUnreferencedCode(Data.Select.RequiresUnreferencedCodeMessage)] public DataRow[] Select(string? filterExpression, string? sort, DataViewRowState recordStates) { DataCommonEventSource.Log.Trace(" {0}, filterExpression='{1}', sort='{2}', recordStates={3}", ObjectID, filterExpression, sort, recordStates); @@ -4821,6 +4835,8 @@ internal bool UpdatingCurrent(DataRow row, DataRowAction action) action == DataRowAction.ChangeCurrentAndOriginal); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "DataColumn with null expression and int data type is safe.")] internal DataColumn AddUniqueKey(int position) { if (_colUnique != null) @@ -4868,6 +4884,8 @@ internal DataColumn AddUniqueKey(int position) internal DataColumn AddUniqueKey() => AddUniqueKey(-1); + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Expression is null and potential problem with data type has already been reported when constructing parentKey")] internal DataColumn AddForeignKey(DataColumn parentKey) { Debug.Assert(parentKey != null, "AddForeignKey: Invalid paramter.. related primary key is null"); @@ -5298,24 +5316,34 @@ private void SetDataRowWithLoadOption(DataRow dataRow, int recordNo, LoadOption public DataTableReader CreateDataReader() => new DataTableReader(this); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream) => WriteXml(stream, XmlWriteMode.IgnoreSchema, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream, bool writeHierarchy) => WriteXml(stream, XmlWriteMode.IgnoreSchema, writeHierarchy); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer) => WriteXml(writer, XmlWriteMode.IgnoreSchema, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer, bool writeHierarchy) => WriteXml(writer, XmlWriteMode.IgnoreSchema, writeHierarchy); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer) => WriteXml(writer, XmlWriteMode.IgnoreSchema, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer, bool writeHierarchy) => WriteXml(writer, XmlWriteMode.IgnoreSchema, writeHierarchy); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName) => WriteXml(fileName, XmlWriteMode.IgnoreSchema, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName, bool writeHierarchy) => WriteXml(fileName, XmlWriteMode.IgnoreSchema, writeHierarchy); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream, XmlWriteMode mode) => WriteXml(stream, mode, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(Stream? stream, XmlWriteMode mode, bool writeHierarchy) { if (stream != null) @@ -5327,11 +5355,13 @@ public void WriteXml(Stream? stream, XmlWriteMode mode, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer, XmlWriteMode mode) { WriteXml(writer, mode, false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(TextWriter? writer, XmlWriteMode mode, bool writeHierarchy) { if (writer != null) @@ -5343,10 +5373,13 @@ public void WriteXml(TextWriter? writer, XmlWriteMode mode, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer, XmlWriteMode mode) { WriteXml(writer, mode, false); } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(XmlWriter? writer, XmlWriteMode mode, bool writeHierarchy) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, mode={1}", ObjectID, mode); @@ -5414,8 +5447,10 @@ public void WriteXml(XmlWriter? writer, XmlWriteMode mode, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName, XmlWriteMode mode) => WriteXml(fileName, mode, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXml(string fileName, XmlWriteMode mode, bool writeHierarchy) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, fileName='{1}', mode={2}", ObjectID, fileName, mode); @@ -5437,8 +5472,10 @@ public void WriteXml(string fileName, XmlWriteMode mode, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(Stream? stream) => WriteXmlSchema(stream, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(Stream? stream, bool writeHierarchy) { if (stream == null) @@ -5452,8 +5489,10 @@ public void WriteXmlSchema(Stream? stream, bool writeHierarchy) WriteXmlSchema(w, writeHierarchy); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(TextWriter? writer) => WriteXmlSchema(writer, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(TextWriter? writer, bool writeHierarchy) { if (writer == null) @@ -5502,8 +5541,10 @@ private bool CheckForClosureOnExpressionTables(List tableList) return true; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(XmlWriter? writer) => WriteXmlSchema(writer, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(XmlWriter? writer, bool writeHierarchy) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}", ObjectID); @@ -5557,8 +5598,10 @@ public void WriteXmlSchema(XmlWriter? writer, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(string fileName) => WriteXmlSchema(fileName, false); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void WriteXmlSchema(string fileName, bool writeHierarchy) { XmlTextWriter xw = new XmlTextWriter(fileName, null); @@ -5575,6 +5618,7 @@ public void WriteXmlSchema(string fileName, bool writeHierarchy) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(Stream? stream) { if (stream == null) @@ -5590,6 +5634,7 @@ public XmlReadMode ReadXml(Stream? stream) return ReadXml(xr, false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(TextReader? reader) { if (reader == null) @@ -5605,6 +5650,7 @@ public XmlReadMode ReadXml(TextReader? reader) return ReadXml(xr, false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(string fileName) { XmlTextReader xr = new XmlTextReader(fileName); @@ -5622,6 +5668,7 @@ public XmlReadMode ReadXml(string fileName) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public XmlReadMode ReadXml(XmlReader? reader) => ReadXml(reader, false); private void RestoreConstraint(bool originalEnforceConstraint) @@ -5659,6 +5706,7 @@ private bool IsEmptyXml(XmlReader reader) return false; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlReadMode ReadXml(XmlReader? reader, bool denyResolving) { IDisposable? restrictedScope = null; @@ -6233,6 +6281,8 @@ internal bool MoveToElement(XmlReader reader, int depth) } return (reader.NodeType == XmlNodeType.Element); } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void ReadXmlDiffgram(XmlReader reader) { // fill correctly @@ -6342,6 +6392,7 @@ private void ReadXmlDiffgram(XmlReader reader) EnforceConstraints = fEnforce; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ReadXSDSchema(XmlReader reader, bool denyResolving) { XmlSchemaSet sSet = new XmlSchemaSet(); @@ -6358,6 +6409,7 @@ internal void ReadXSDSchema(XmlReader reader, bool denyResolving) schema.LoadSchema(sSet, this); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(Stream? stream) { if (stream == null) @@ -6368,6 +6420,7 @@ public void ReadXmlSchema(Stream? stream) ReadXmlSchema(new XmlTextReader(stream), false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(TextReader? reader) { if (reader == null) @@ -6378,6 +6431,7 @@ public void ReadXmlSchema(TextReader? reader) ReadXmlSchema(new XmlTextReader(reader), false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(string fileName) { XmlTextReader xr = new XmlTextReader(fileName); @@ -6391,11 +6445,13 @@ public void ReadXmlSchema(string fileName) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void ReadXmlSchema(XmlReader? reader) { ReadXmlSchema(reader, false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ReadXmlSchema(XmlReader? reader, bool denyResolving) { long logScopeId = DataCommonEventSource.Log.EnterScope(" {0}, denyResolving={1}", ObjectID, denyResolving); @@ -6646,7 +6702,7 @@ public static XmlSchemaComplexType GetDataTableSchema(XmlSchemaSet? schemaSet) return XmlSchema.Read(new XmlTextReader(stream), null); } -// TODO: Enable after System.Private.Xml is annotated + // TODO: Enable after System.Private.Xml is annotated #nullable disable #pragma warning disable 8632 void IXmlSerializable.ReadXml(XmlReader reader) @@ -6668,12 +6724,18 @@ void IXmlSerializable.ReadXml(XmlReader reader) void IXmlSerializable.WriteXml(XmlWriter writer) { - WriteXmlSchema(writer, false); - WriteXml(writer, XmlWriteMode.DiffGram, false); + WriteXmlCore(writer); } #pragma warning restore 8632 #nullable enable + // This method exists so that suppression can be placed on `IXmlSerializable.WriteXml(XmlWriter writer)` + private void WriteXmlCore(XmlWriter writer) + { + WriteXmlSchema(writer, false); + WriteXml(writer, XmlWriteMode.DiffGram, false); + } + protected virtual void ReadXmlSerializable(XmlReader? reader) => ReadXml(reader, XmlReadMode.DiffGram, true); // RowDiffIdUsageSection & DSRowDiffIdUsageSection Usage: @@ -6880,6 +6942,8 @@ internal void EvaluateExpressions() } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This is unsafe only when columns have associated expression. All ways to add such expression are marked unsafe.")] internal void EvaluateExpressions(DataRow row, DataRowAction action, List? cachedRows) { // evaluate all expressions for specified row diff --git a/src/libraries/System.Data.Common/src/System/Data/DataView.cs b/src/libraries/System.Data.Common/src/System/Data/DataView.cs index 11ed8cd79f61d..ba1e5fa3f5445 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataView.cs @@ -126,6 +126,7 @@ public DataView(DataTable? table) : this(table, false) /// Initializes a new instance of the class with the /// specified . /// + [RequiresUnreferencedCode(Select.RequiresUnreferencedCodeMessage)] public DataView(DataTable table, string? RowFilter, string? Sort, DataViewRowState RowState) { GC.SuppressFinalize(this); @@ -314,6 +315,7 @@ public virtual string? RowFilter DataExpression? expression = (_rowFilter as DataExpression); return (expression == null ? "" : expression.Expression); // CONSIDER: return optimized expression here } + [RequiresUnreferencedCode(Select.RequiresUnreferencedCodeMessage)] set { if (value == null) @@ -577,6 +579,8 @@ public void BeginInit() _fInitInProgress = true; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Warning related to RowFilter has already been shown when RowFilter was delay set.")] public void EndInit() { if (_delayedTable != null && _delayedTable.fInitInProgress) @@ -961,6 +965,7 @@ void IList.Remove(object? value) bool IBindingList.SupportsSearching => true; bool IBindingList.SupportsSorting => true; bool IBindingList.IsSorted => Sort.Length != 0; + PropertyDescriptor IBindingList.SortProperty => GetSortProperty(); internal PropertyDescriptor GetSortProperty() @@ -1123,8 +1128,10 @@ private string CreateSortString(PropertyDescriptor property, ListSortDirection d return resultString.ToString(); } -// TODO: Enable after System.ComponentModel.TypeConverter is annotated + // TODO: Enable after System.ComponentModel.TypeConverter is annotated #nullable disable + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Safe because filter is set to empty string.")] void IBindingListView.RemoveFilter() { DataCommonEventSource.Log.Trace(" {0}", ObjectID); @@ -1516,7 +1523,7 @@ internal void SetDataViewManager(DataViewManager? dataViewManager) { // sdub: check that we will not do unnesasary operation here if dataViewSetting.Sort == this.Sort ... _applyDefaultSort = dataViewSetting.ApplyDefaultSort; - DataExpression newFilter = new DataExpression(_table, dataViewSetting.RowFilter); + DataExpression newFilter = CreateDataExpressionFromDataViewSettings(dataViewSetting); SetIndex(dataViewSetting.Sort, dataViewSetting.RowStateFilter, newFilter); } catch (Exception e) when (Common.ADP.IsCatchableExceptionType(e)) @@ -1532,6 +1539,14 @@ internal void SetDataViewManager(DataViewManager? dataViewManager) } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "RowFilter is marked as unsafe because it can be used in DataExpression so that we only display warning when user is assigning an expression" + + " which means that in here we're either assigning empty filter which is safe or user has already seen a warning.")] + private DataExpression CreateDataExpressionFromDataViewSettings(DataViewSetting dataViewSetting) + { + return new DataExpression(_table, dataViewSetting.RowFilter); + } + internal virtual void SetIndex(string newSort, DataViewRowState newRowStates, IFilter? newRowFilter) { SetIndex2(newSort, newRowStates, newRowFilter, true); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewListener.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewListener.cs index b278f160c6ad7..db8424731ab34 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataViewListener.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataViewListener.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs index 8850e45f122ae..1303b616edb26 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs @@ -97,6 +97,7 @@ public string DataViewSettingCollectionString builder.Append(""); return builder.ToString(); } + [RequiresUnreferencedCode("Members of types used in the RowFilter expression might be trimmed.")] set { if (string.IsNullOrEmpty(value)) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs index 2ec0f4fcfa738..0e910870633ad 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs @@ -56,6 +56,7 @@ internal void SetDataTable(DataTable table) public string RowFilter { get { return _rowFilter; } + [RequiresUnreferencedCode(Select.RequiresUnreferencedCodeMessage)] set { if (value == null) diff --git a/src/libraries/System.Data.Common/src/System/Data/EnumerableRowCollection.cs b/src/libraries/System.Data.Common/src/System/Data/EnumerableRowCollection.cs index bbdf6b51a7518..f2e8743198ad7 100644 --- a/src/libraries/System.Data.Common/src/System/Data/EnumerableRowCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/EnumerableRowCollection.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Data; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace System.Data diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/AggregateNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/AggregateNode.cs index 98760f2ecbf9b..0dca43b20ca62 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/AggregateNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/AggregateNode.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -155,11 +156,13 @@ internal static void Bind(DataRelation? relation, List list) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { return Eval(null, DataRowVersion.Default); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { if (_childTable == null) @@ -220,6 +223,7 @@ internal override object Eval(DataRow? row, DataRowVersion version) } // Helper for the DataTable.Compute method + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] records) { if (_childTable == null) diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs index fb537bdce17a1..03c7c20835208 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Data.SqlTypes; using System.Data.Common; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -30,16 +31,19 @@ internal override void Bind(DataTable table, List list) _right.Bind(table, list); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { return Eval(null, DataRowVersion.Default); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { return EvalBinaryOp(_op, _left, _right, row, version, null); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { return EvalBinaryOp(_op, _left, _right, null, DataRowVersion.Default, recordNos); @@ -109,7 +113,7 @@ internal override ExpressionNode Optimize() if (IsConstant()) { - object val = Eval(); + object val = EvalConstant(); if (val == DBNull.Value) { @@ -134,6 +138,15 @@ internal void SetTypeMismatchError(int op, Type left, Type right) throw ExprException.TypeMismatchInBinop(op, left, right); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Evaluating constant expression is safe.")] + private object EvalConstant() + { + Debug.Assert(IsConstant()); + return Eval(); + } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static object Eval(ExpressionNode expr, DataRow? row, DataRowVersion version, int[]? recordNos) { if (recordNos == null) @@ -267,6 +280,7 @@ internal int BinaryCompare(object vLeft, object vRight, StorageType resultType, return result; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private object EvalBinaryOp(int op, ExpressionNode left, ExpressionNode right, DataRow? row, DataRowVersion version, int[]? recordNos) { object vLeft; @@ -1514,6 +1528,7 @@ internal LikeNode(DataTable? table, int op, ExpressionNode left, ExpressionNode { } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { object vLeft = _left.Eval(row, version); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ConstNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ConstNode.cs index 63d3676890094..308352fe6dbfc 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ConstNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ConstNode.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Collections.Generic; using System.Globalization; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -68,16 +69,19 @@ internal override void Bind(DataTable table, List list) BindTable(table); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { return _val; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { return Eval(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { return Eval(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs index 8be3afbd84d3c..79dc4a705ab7d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Data.SqlTypes; using System.Data.Common; @@ -20,10 +21,12 @@ internal sealed class DataExpression : IFilter private readonly Type? _dataType; // This set if the expression is part of ExpressionCoulmn private DataColumn[] _dependency = Array.Empty(); + [RequiresUnreferencedCode("Members of types used in the expression might be trimmed")] internal DataExpression(DataTable? table, string? expression) : this(table, expression, null) { } + [RequiresUnreferencedCode("Members of types used in the expression might be trimmed")] internal DataExpression(DataTable? table, string? expression, Type? type) { ExpressionParser parser = new ExpressionParser(table); @@ -115,6 +118,8 @@ internal object Evaluate() return Evaluate((DataRow?)null, DataRowVersion.Default); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Constructors taking expression are marked as unsafe")] internal object Evaluate(DataRow? row, DataRowVersion version) { object? result; @@ -158,7 +163,8 @@ internal object Evaluate(DataRow[] rows) return Evaluate(rows, DataRowVersion.Default); } - + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Constructors taking expression are marked as unsafe")] internal object Evaluate(DataRow[] rows, DataRowVersion version) { if (!_bound) @@ -185,6 +191,8 @@ internal object Evaluate(DataRow[] rows, DataRowVersion version) } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Constructors taking expression are marked as unsafe")] public bool Invoke(DataRow row, DataRowVersion version) { if (_expr == null) diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionNode.cs index 2febaeb4721a0..7d5c4ba4a4d59 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionNode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data.Common; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -43,13 +44,17 @@ protected void BindTable(DataTable table) } internal abstract void Bind(DataTable table, List list); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal abstract object Eval(); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal abstract object Eval(DataRow? row, DataRowVersion version); + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal abstract object Eval(int[] recordNos); internal abstract bool IsConstant(); internal abstract bool IsTableConstant(); internal abstract bool HasLocalAggregate(); internal abstract bool HasRemoteAggregate(); + internal abstract ExpressionNode Optimize(); internal virtual bool DependsOn(DataColumn column) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs index d6e20b5a9f0c7..83a5066a4261c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace System.Data diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs index 6a666e60718f4..79577f945b94e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs @@ -5,6 +5,7 @@ using System.Data.Common; using System.Data.SqlTypes; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; namespace System.Data @@ -110,11 +111,13 @@ internal override void Bind(DataTable table, List list) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { return Eval(null, DataRowVersion.Default); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { Debug.Assert(_info < s_funcs.Length && _info >= 0, "Invalid function info."); @@ -173,6 +176,7 @@ internal override object Eval(DataRow? row, DataRowVersion version) return EvalFunction(s_funcs[_info]._id, argumentValues, row, version); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { throw ExprException.ComputeNotAggregate(ToString()!); @@ -242,6 +246,8 @@ internal override bool DependsOn(DataColumn column) return false; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Constant expressions are safe to be evaluated.")] internal override ExpressionNode Optimize() { for (int i = 0; i < _argumentCount; i++) @@ -270,6 +276,7 @@ internal override ExpressionNode Optimize() return this; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private Type GetDataType(ExpressionNode node) { Type nodeType = node.GetType(); @@ -304,6 +311,7 @@ private Type GetDataType(ExpressionNode node) return dataType; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private object EvalFunction(FunctionId id, object[] argumentValues, DataRow? row, DataRowVersion version) { StorageType storageType; diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/LookupNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/LookupNode.cs index bacf6d2fabc71..d19576c26aa4b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/LookupNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/LookupNode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -82,11 +83,13 @@ internal override void Bind(DataTable table, List list) AggregateNode.Bind(_relation, list); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { throw ExprException.EvalNoContext(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { if (_column == null || _relation == null) @@ -99,6 +102,7 @@ internal override object Eval(DataRow? row, DataRowVersion version) return parent[_column, parent.HasVersion(version) ? version : DataRowVersion.Current]; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { throw ExprException.ComputeNotAggregate(ToString()!); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs index 8cb163db379f2..ded0f3982a6c8 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -75,12 +76,14 @@ internal override void Bind(DataTable table, List list) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { // can not eval column without ROW value; throw ExprException.EvalNoContext(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { if (!_found) @@ -101,6 +104,7 @@ internal override object Eval(DataRow? row, DataRowVersion version) return _column![row.GetRecordFromVersion(version)]; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] records) { throw ExprException.ComputeNotAggregate(ToString()!); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/UnaryNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/UnaryNode.cs index 3bff8db070a36..5e0fcb3742447 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/UnaryNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/UnaryNode.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Data.Common; using System.Data.SqlTypes; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -26,16 +27,19 @@ internal override void Bind(DataTable table, List list) _right.Bind(table, list); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { return Eval(null, DataRowVersion.Default); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { return EvalUnaryOp(_op, _right.Eval(row, version)); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { return _right.Eval(recordNos); @@ -170,7 +174,8 @@ internal override bool DependsOn(DataColumn column) return (_right.DependsOn(column)); } - + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "Evaluating constant expression is safe")] internal override ExpressionNode Optimize() { _right = _right.Optimize(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ZeroOpNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ZeroOpNode.cs index 75291d3c86f67..28b6771c19811 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ZeroOpNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ZeroOpNode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -24,6 +25,7 @@ internal override void Bind(DataTable table, List list) { } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval() { switch (_op) @@ -40,11 +42,13 @@ internal override object Eval() } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(DataRow? row, DataRowVersion version) { return Eval(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal override object Eval(int[] recordNos) { return Eval(); diff --git a/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs b/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs index 92753db288013..361ef47e0f2fc 100644 --- a/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using System.Data; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -82,7 +83,7 @@ public override string? RowFilter return null; } } - + [RequiresUnreferencedCode(Select.RequiresUnreferencedCodeMessage)] set { if (value == null) @@ -230,7 +231,7 @@ internal override void SetIndex(string newSort, DataViewRowState newRowStates, I #endregion #region IBindingList -// TODO: Enable after System.ComponentModel.TypeConverter is annotated + // TODO: Enable after System.ComponentModel.TypeConverter is annotated #nullable disable /// /// Clears both expression-based and DataView's string-based sorting. diff --git a/src/libraries/System.Data.Common/src/System/Data/Merger.cs b/src/libraries/System.Data.Common/src/System/Data/Merger.cs index a06f531ab1ce9..5a4c7b1179f05 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Merger.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Merger.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -104,7 +105,7 @@ internal void MergeDataSet(DataSet source) DataColumn targetColumn = targetTable.Columns[dc.ColumnName]!; if (!existingColumns!.Contains(targetColumn)) { - targetColumn.Expression = dc.Expression; + targetColumn.CopyExpressionFrom(dc); } } } @@ -405,7 +406,7 @@ internal void MergeRows(DataRow[] rows) { for (int i = oldCount; i < targetTable.Columns.Count; i++) { - targetTable.Columns[i].Expression = table.Columns[targetTable.Columns[i].ColumnName]!.Expression; + targetTable.Columns[i].CopyExpressionFrom(table.Columns[targetTable.Columns[i].ColumnName]!); } } diff --git a/src/libraries/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs b/src/libraries/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs index 849908991e48a..432e0eb7142bf 100644 --- a/src/libraries/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs +++ b/src/libraries/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace System.Data.ProviderBase @@ -1138,6 +1139,7 @@ private void RollbackAddedItems(List? items) return dataValues; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void AddAdditionalProperties(DataColumn targetColumn, DataRow schemaRow) { DataColumnCollection columns = schemaRow.Table.Columns; diff --git a/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs b/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs index dfffcc6e52c21..585c6c248976d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs +++ b/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs @@ -94,6 +94,7 @@ private int NormalizedMinimumCapacity(int capacity) return (((capacity + 10) >> 10) + 1) << 10; } + internal int NewRecordBase() { int record; diff --git a/src/libraries/System.Data.Common/src/System/Data/Select.cs b/src/libraries/System.Data.Common/src/System/Data/Select.cs index 97fbb80c7b08f..79c273c1d5dc9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Select.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Select.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Data { internal sealed class Select { + internal const string RequiresUnreferencedCodeMessage = "Members of types used in the filter expression might be trimmed."; private readonly DataTable _table; private readonly IndexField[] _indexFields; private readonly DataViewRowState _recordStates; @@ -34,6 +36,7 @@ private sealed class ColumnInfo private int _nCandidates; private int _matchedCandidates; + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public Select(DataTable table, string? filterExpression, string? sort, DataViewRowState recordStates) { _table = table; @@ -596,6 +599,8 @@ public DataRow[] GetRows() return newRows; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "All constructors are marked as unsafe.")] private bool AcceptRecord(int record) { DataRow? row = _table._recordManager[record]; @@ -630,6 +635,8 @@ private bool AcceptRecord(int record) return result; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "All constructors are marked as unsafe.")] private int Eval(BinaryNode expr, DataRow row, DataRowVersion version) { if (expr._op == Operators.And) diff --git a/src/libraries/System.Data.Common/src/System/Data/Selection.cs b/src/libraries/System.Data.Common/src/System/Data/Selection.cs index 2d3fa4c921c3d..21a6d951393c1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Selection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Selection.cs @@ -896,6 +896,7 @@ public void RecordChanged(int record) } } } + // new RecordChanged which takes oldIndex and newIndex and fires _onListChanged public void RecordChanged(int oldIndex, int newIndex) { diff --git a/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs b/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs index f7d8081614dd9..5c66f68859545 100644 --- a/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs +++ b/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace System.Data @@ -27,6 +28,7 @@ protected TypedTableBase() : base() { } /// /// SerializationInfo containing data to construct the object. /// The streaming context for the object being deserialized. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs index 7885dc7f66e75..571d343deaf02 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.Diagnostics; using System.Data.Common; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -27,6 +28,7 @@ internal XDRSchema(DataSet ds, bool fInline) _ds = ds; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void LoadSchema(XmlElement schemaRoot, DataSet ds) { if (schemaRoot == null) @@ -177,6 +179,7 @@ internal bool IsXDRField(XmlElement node, XmlElement typeNode) return true; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable HandleTable(XmlElement node) { XmlElement typeNode; @@ -217,8 +220,9 @@ internal DataTable HandleTable(XmlElement node) private sealed class NameType : IComparable { public string name; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] public Type type; - public NameType(string n, Type t) + public NameType(string n, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type t) { name = n; type = t; @@ -292,6 +296,7 @@ private static NameType FindNameType(string name) private static readonly NameType s_enumerationNameType = FindNameType("enumeration"); + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] private Type ParseDataType(string dt, string dtValues) { string strType = dt; @@ -336,6 +341,7 @@ internal string GetInstanceName(XmlElement node) return instanceName; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleColumn(XmlElement node, DataTable table) { Debug.Assert(FEqualIdentity(node, Keywords.XDR_ELEMENT, Keywords.XDRNS) || @@ -535,7 +541,7 @@ internal void GetMinMax(XmlElement elNode, bool isAttribute, ref int minOccurs, } } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleTypeNode(XmlElement typeNode, DataTable table, ArrayList tableChildren) { DataTable tableChild; @@ -564,6 +570,7 @@ internal void HandleTypeNode(XmlElement typeNode, DataTable table, ArrayList tab } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable InstantiateTable(DataSet dataSet, XmlElement node, XmlElement typeNode) { string typeName = string.Empty; @@ -656,6 +663,7 @@ internal DataTable InstantiateTable(DataSet dataSet, XmlElement node, XmlElement return table; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable InstantiateSimpleTable(DataSet dataSet, XmlElement node) { string typeName; 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 39e1eed9057d7..12502ad9da104 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs @@ -8,6 +8,7 @@ using System.Collections; using System.Xml; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -17,6 +18,7 @@ internal sealed class XMLDiffLoader private DataSet _dataSet; private DataTable _dataTable; + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void LoadDiffGram(DataSet ds, XmlReader dataTextReader) { XmlReader reader = DataTextReader.CreateReader(dataTextReader); @@ -48,6 +50,7 @@ private void CreateTablesHierarchy(DataTable dt) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void LoadDiffGram(DataTable dt, XmlReader dataTextReader) { XmlReader reader = DataTextReader.CreateReader(dataTextReader); @@ -70,6 +73,7 @@ internal void LoadDiffGram(DataTable dt, XmlReader dataTextReader) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ProcessDiffs(DataSet ds, XmlReader ssync) { DataTable tableBefore; @@ -121,6 +125,8 @@ internal void ProcessDiffs(DataSet ds, XmlReader ssync) return; } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ProcessDiffs(ArrayList tableList, XmlReader ssync) { DataTable tableBefore; @@ -174,7 +180,7 @@ internal void ProcessDiffs(ArrayList tableList, XmlReader ssync) return; } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ProcessErrors(DataSet ds, XmlReader ssync) { DataTable table; @@ -214,6 +220,7 @@ internal void ProcessErrors(DataSet ds, XmlReader ssync) return; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void ProcessErrors(ArrayList dt, XmlReader ssync) { DataTable table; @@ -284,6 +291,7 @@ private DataTable GetTable(string tableName, string ns) return null; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlReader row) { // read table information 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 1efbb5518dfe6..f7cfd54efe8c7 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs @@ -26,6 +26,7 @@ internal static TypeConverter GetConverter(Type type) return TypeDescriptor.GetConverter(type); } + [RequiresUnreferencedCode("Calls into TypeDescriptor.GetProperties. Type cannot be statically discovered.")] internal static void SetProperties(object instance, XmlAttributeCollection attrs) { // This is called from both XSD and XDR schemas. @@ -263,6 +264,7 @@ internal static string QualifiedName(string name) return name; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal static void SetProperties(object instance, XmlAttribute[] attrs) { // This is called from both XSD and XDR schemas. @@ -323,6 +325,7 @@ internal static void SetProperties(object instance, XmlAttribute[] attrs) } }// SetProperties + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void SetExtProperties(object instance, XmlAttribute[] attrs) { PropertyCollection props = null; @@ -396,6 +399,7 @@ internal static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln) return null; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void SetExtProperties(object instance, XmlAttributeCollection attrs) { PropertyCollection props = null; @@ -415,6 +419,7 @@ private static void SetExtProperties(object instance, XmlAttributeCollection att } }// SetExtProperties + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleRefTableProperties(ArrayList RefTables, XmlSchemaElement element) { string typeName = GetInstanceName(element); @@ -425,6 +430,7 @@ internal void HandleRefTableProperties(ArrayList RefTables, XmlSchemaElement ele SetExtProperties(table, element.UnhandledAttributes); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleRelation(XmlElement node, bool fNested) { string strName; @@ -644,11 +650,14 @@ private XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements) return null; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void LoadSchema(XmlSchemaSet schemaSet, DataTable dt) { if (dt.DataSet != null) LoadSchema(schemaSet, dt.DataSet); } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds) { //Element schemaRoot, DataSet ds) { _constraintNodes = new Hashtable(); @@ -857,6 +866,7 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void HandleRelations(XmlSchemaAnnotation ann, bool fNested) { foreach (object __items in ann.Items) @@ -892,6 +902,7 @@ internal XmlSchemaObjectCollection GetParticleItems(XmlSchemaParticle pt) return null; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, bool isBase) { XmlSchemaObjectCollection items = GetParticleItems(pt); @@ -980,6 +991,7 @@ internal void HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList ta return; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleAttributes(XmlSchemaObjectCollection attributes, DataTable table, bool isBase) { foreach (XmlSchemaObject so in attributes) @@ -1000,6 +1012,7 @@ internal void HandleAttributes(XmlSchemaObjectCollection attributes, DataTable t } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void HandleAttributeGroup(XmlSchemaAttributeGroup attributeGroup, DataTable table, bool isBase) { foreach (XmlSchemaObject obj in attributeGroup.Attributes) @@ -1027,6 +1040,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)) @@ -1267,6 +1282,7 @@ internal static Rule TranslateRule(string strRule) return ForeignKeyConstraint.Rule_Default; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleKeyref(XmlSchemaKeyref keyref) { string refer = XmlConvert.DecodeName(keyref.Refer.Name); // check here!!! @@ -1374,7 +1390,7 @@ internal void HandleKeyref(XmlSchemaKeyref keyref) } } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleConstraint(XmlSchemaIdentityConstraint keyNode) { string name = null; @@ -1428,6 +1444,7 @@ internal void HandleConstraint(XmlSchemaIdentityConstraint keyNode) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable InstantiateSimpleTable(XmlSchemaElement node) { DataTable table; @@ -1542,6 +1559,7 @@ internal string GetInstanceName(XmlSchemaAnnotated node) } // Sequences of handling Elements, Attributes and Text-only column should be the same as in InferXmlSchema + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, bool isRef) { DataTable table; @@ -1760,8 +1778,9 @@ internal DataTable InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType private sealed class NameType : IComparable { public readonly string name; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] public readonly Type type; - public NameType(string n, Type t) + public NameType(string n, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type t) { name = n; type = t; @@ -1852,6 +1871,7 @@ private static NameType FindNameType(string name) } // input param dt is a "qName" for UDSimpleType else it assumes it's a XSD builtin simpleType + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] private Type ParseDataType(string dt) { if (!IsXsdType(dt)) @@ -1938,7 +1958,7 @@ internal XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node) return typeNode; } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode, string strType, DataTable table, bool isBase, XmlAttribute[] attrs, bool isNillable) { // disallow multiple simple content columns for the table @@ -2075,6 +2095,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode, } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] 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. @@ -2175,6 +2196,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table, bool isBase) { Type type = null; @@ -2337,6 +2359,7 @@ internal void HandleAttributeColumn(XmlSchemaAttribute attrib, DataTable table, } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool isBase) { Type type = null; @@ -2537,6 +2560,7 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet) { string dsName = node.Name; @@ -2824,6 +2848,7 @@ internal bool IsTable(XmlSchemaElement node) // internal bool IsTopLevelElement (XmlSchemaElement node) { // return (elements.IndexOf(node) != -1); // } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataTable HandleTable(XmlSchemaElement node) { if (!IsTable(node)) 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 1453fe83ce86c..b5f5eb009801e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text; using System.Xml; @@ -94,6 +95,7 @@ internal bool FromInference } // after loading, all detached DataRows are attached to their tables + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void AttachRows(DataRow parentRow, XmlNode parentElement) { if (parentElement == null) @@ -292,6 +294,7 @@ internal bool IsTextOnly(DataColumn c) return true; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void LoadData(XmlDocument xdoc) { if (xdoc.DocumentElement == null) @@ -369,6 +372,7 @@ internal void LoadData(XmlDocument xdoc) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadRowData(DataRow row, XmlElement rowElement) { XmlNode n; @@ -499,6 +503,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) { if (parentElement == null) @@ -545,6 +550,7 @@ private void LoadRows(DataRow parentRow, XmlNode parentElement) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SetRowValueFromXmlText(DataRow row, DataColumn col, string xmlText) { row[col] = col.ConvertXmlToObject(xmlText); @@ -584,6 +590,7 @@ private void InitNameTable() _ROWORDER = nameTable.Add(Keywords.ROWORDER); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void LoadData(XmlReader reader) { _dataReader = DataTextReader.CreateReader(reader); @@ -679,6 +686,7 @@ internal void LoadData(XmlReader reader) // // Yes, it is terrible and I don't like it also.. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadTopMostTable(DataTable table) { // /------------------------------- This one is in topMostNode (backed up to XML DOM) @@ -859,6 +867,7 @@ private void LoadTopMostTable(DataTable table) // this method divided into 3 parts: attribute processing (including diffgram), // nested elements processing and loading data. Please keep it this way. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadTable(DataTable table, bool isNested) { // /--------------------------- We are here on entrance @@ -1127,6 +1136,7 @@ private void LoadTable(DataTable table, bool isNested) } // Returns column value + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadColumn(DataColumn column, object[] foundColumns) { // /--------------------------------- We are here on entrance @@ -1357,6 +1367,7 @@ private void LoadColumn(DataColumn column, object[] foundColumns) // Check for schema and skips or loads XSD schema if found. Returns true if schema found. // DataReader would be set on the first XML element after the schema of schema was found. // If no schema detected, reader's position will not change. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private bool ProcessXsdSchema() { if (((object)_dataReader.LocalName == _XSD_SCHEMA && (object)_dataReader.NamespaceURI == _XSDNS)) diff --git a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs index 6e9fbb9ac1b17..509a7f6082fe3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs +++ b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs @@ -106,6 +106,7 @@ internal static void AddExtendedProperties(PropertyCollection? props, XmlElement } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void AddXdoProperties(object? instance, XmlElement root, XmlDocument xd) { if (instance == null) @@ -127,6 +128,7 @@ internal void AddXdoProperties(object? instance, XmlElement root, XmlDocument xd return; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void AddXdoProperty(PropertyDescriptor pd, object instance, XmlElement root, XmlDocument xd) { Type type = pd.PropertyType; @@ -538,6 +540,7 @@ private DataTable[] CreateToplevelTables() // SxS: this method can generate XSD files if the input xmlWriter is XmlTextWriter or DataTextWriter and its underlying stream is FileStream // These XSDs are located in the same folder as the underlying stream's file path (see SetPath method). + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SchemaTree(XmlDocument xd, XmlWriter xmlWriter, DataSet? ds, DataTable? dt, bool writeHierarchy) { _constraintNames = new ArrayList(); @@ -934,6 +937,7 @@ internal void SchemaTree(XmlDocument xd, XmlWriter xmlWriter, DataSet? ds, DataT return; // rootSchema; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlElement SchemaTree(XmlDocument xd, DataTable dt) { _dsElement = xd.CreateElement(Keywords.XSD_PREFIX, Keywords.XSD_ELEMENT, Keywords.XSDNS); @@ -1092,11 +1096,13 @@ internal void SetPath(XmlWriter xw) _filePath = _filePath + "\\"; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(DataSet ds, XmlWriter xw) { Save(ds, null, xw); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(DataTable dt, XmlWriter xw) { XmlDocument doc = new XmlDocument(); @@ -1109,16 +1115,19 @@ internal void Save(DataTable dt, XmlWriter xw) doc.Save(xw); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(DataSet ds, DataTable? dt, XmlWriter xw) { Save(ds, dt, xw, false); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(DataSet? ds, DataTable? dt, XmlWriter xw, bool writeHierarchy) { Save(ds, dt, xw, writeHierarchy, null); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(DataSet? ds, DataTable? dt, XmlWriter xw, bool writeHierarchy, Converter? multipleTargetConverter) { _targetConverter = multipleTargetConverter; @@ -1406,6 +1415,7 @@ private string FindTargetNamespace(DataTable table) return tgNamespace; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlElement HandleColumn(DataColumn col, XmlDocument dc, XmlElement schema, bool fWriteOrdinal) { Debug.Assert(_prefixes != null); @@ -1581,6 +1591,7 @@ internal void AppendChildWithoutRef(XmlElement node, string Namespace, XmlElemen return null; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlElement HandleTable(DataTable table, XmlDocument dc, XmlElement schema) { return HandleTable(table, dc, schema, true); @@ -1710,6 +1721,7 @@ private bool IsAutoGenerated(object o) return false; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlElement HandleTable(DataTable table, XmlDocument dc, XmlElement schema, bool genNested) { Debug.Assert(_prefixes != null); @@ -2331,11 +2343,13 @@ private bool EmptyData() return true; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(XmlWriter xmlw) { Save(xmlw, null); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(XmlWriter xmlw, DataTable? table) { _xmlw = DataTextWriter.CreateWriter(xmlw); @@ -2395,6 +2409,7 @@ internal void Save(XmlWriter xmlw, DataTable? table) _xmlw.Flush(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void GenerateTable(DataTable table) { int rowCount = table.Rows.Count; @@ -2470,6 +2485,7 @@ private void GenerateTableErrors(DataTable table) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void GenerateRow(DataRow row) { DataRowState state = row.RowState; @@ -2526,6 +2542,7 @@ private void GenerateRow(DataRow row) _xmlw.WriteEndElement(); //old row } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void GenerateColumn(DataRow row, DataColumn col, DataRowVersion version) { string? value = null; @@ -2776,6 +2793,7 @@ internal static bool RowHasErrors(DataRow row) // the following line writes the data part // for the new diffgram format + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SaveDiffgramData(XmlWriter xw, Hashtable rowsOrder) { Debug.Assert(_ds != null || _dt != null); @@ -2818,7 +2836,7 @@ internal void SaveDiffgramData(XmlWriter xw, Hashtable rowsOrder) _xmlw.Flush(); } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Save(XmlWriter xw, bool writeSchema) { Debug.Assert(_ds != null || _dt != null); @@ -2910,7 +2928,7 @@ private ArrayList GetNestedChildRelations(DataRow row) return list; } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void XmlDataRowWriter(DataRow row, string encodedTableName) { Debug.Assert(_xmlw != null); diff --git a/src/libraries/System.Data.Common/src/System/Xml/DataDocumentXPathNavigator.cs b/src/libraries/System.Data.Common/src/System/Xml/DataDocumentXPathNavigator.cs index 1fc9394dd1253..ed6c31b6e7c44 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/DataDocumentXPathNavigator.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/DataDocumentXPathNavigator.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Data; +using System.Diagnostics.CodeAnalysis; using System.Xml.XPath; #pragma warning disable 0618 // ignore obsolete warning about XmlDataDocument @@ -13,6 +15,7 @@ internal sealed class DataDocumentXPathNavigator : XPathNavigator, IHasXmlNode private XmlDataDocument _doc; //pointer to remember the root -- can only be XmlDataDocument for DataDocumentXPathNavigator private readonly XPathNodePointer _temp; + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal DataDocumentXPathNavigator(XmlDataDocument doc, XmlNode node) { _curNode = new XPathNodePointer(this, doc, node); @@ -20,12 +23,16 @@ internal DataDocumentXPathNavigator(XmlDataDocument doc, XmlNode node) _doc = doc; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private DataDocumentXPathNavigator(DataDocumentXPathNavigator other) { _curNode = other._curNode.Clone(this); _temp = other._temp.Clone(this); _doc = other._doc; } + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XPathNavigator Clone() => new DataDocumentXPathNavigator(this); internal XPathNodePointer CurNode => _curNode; @@ -44,6 +51,8 @@ private DataDocumentXPathNavigator(DataDocumentXPathNavigator other) public override string Value { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { XPathNodeType xnt = _curNode.NodeType; @@ -62,6 +71,8 @@ public override string Value // Attributes public override bool HasAttributes => _curNode.AttributeCount > 0; + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override string GetAttribute(string localName, string namespaceURI) { if (_curNode.NodeType != XPathNodeType.Element) @@ -73,16 +84,22 @@ public override string GetAttribute(string localName, string namespaceURI) return _temp.MoveToAttribute(localName, namespaceURI) ? _temp.Value! : string.Empty; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override string GetNamespace(string name) => _curNode.GetNamespace(name); public override bool MoveToNamespace(string name) => _curNode.NodeType != XPathNodeType.Element ? false : _curNode.MoveToNamespace(name); + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) => _curNode.NodeType != XPathNodeType.Element ? false : _curNode.MoveToFirstNamespace(namespaceScope); + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) => _curNode.NodeType != XPathNodeType.Namespace ? false : _curNode.MoveToNextNamespace(namespaceScope); @@ -155,8 +172,12 @@ public override bool IsSamePosition(XPathNavigator other) //the function is only called for XPathNodeList enumerate nodes and // shouldn't be promoted to frequently use because it will cause foliation + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] XmlNode IHasXmlNode.GetNode() => _curNode.Node!; + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNodeOrder ComparePosition(XPathNavigator? other) { if (other == null) diff --git a/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs b/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs index d04cd7d46fed0..3df260fa1abbc 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs @@ -3,6 +3,7 @@ using System.Data; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; #pragma warning disable 0618 // ignore obsolete warning about XmlDataDocument @@ -550,6 +551,7 @@ internal string Prefix internal string? Value { + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] get { RealFoliate(); diff --git a/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs b/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs index f7095827dfcd2..4e4c878b51c54 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs @@ -3,6 +3,7 @@ using System.Data; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Xml.XPath; #pragma warning disable 618 // ignore obsolete warning about XmlDataDocument @@ -311,6 +312,7 @@ internal string Prefix internal string? Value { + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] get { RealFoliate(); @@ -351,6 +353,7 @@ internal string? Value internal string InnerText { + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] get { RealFoliate(); @@ -1062,6 +1065,7 @@ internal bool IsSamePosition(XPathNodePointer pointer) && pointer._parentOfNS == _parentOfNS); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlNodeOrder CompareNamespacePosition(XPathNodePointer other) { XPathNodePointer xp1 = Clone((DataDocumentXPathNavigator)(_owner.Target!)); @@ -1087,6 +1091,7 @@ private static XmlNode GetRoot(XmlNode node, ref int depth) return curNode; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlNodeOrder ComparePosition(XPathNodePointer other) { RealFoliate(); @@ -1230,6 +1235,7 @@ internal XmlNodeOrder ComparePosition(XPathNodePointer other) internal XmlNode? Node { + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] get { RealFoliate(); @@ -1322,6 +1328,7 @@ private void RealFoliate() //The function only helps to find out if there is a namespace declaration of given name is defined on the given node //It will not check the ancestor of the given node. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private string? GetNamespace(XmlBoundElement be, string name) { if (be == null) @@ -1355,6 +1362,7 @@ private void RealFoliate() } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal string GetNamespace(string name) { //we are checking the namespace nodes backwards comparing its normal order in DOM tree @@ -1454,6 +1462,7 @@ internal bool MoveToNamespace(string name) //the function will find the next namespace node on the given bound element starting with the given column or attribute // whether to use column or attribute depends on if the bound element is foliated or not. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private bool MoveToNextNamespace(XmlBoundElement? be, DataColumn? col, XmlAttribute? curAttr) { if (be != null) @@ -1506,6 +1515,7 @@ private bool MoveToNextNamespace(XmlBoundElement? be, DataColumn? col, XmlAttrib } //Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call ) + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { RealFoliate(); @@ -1541,6 +1551,7 @@ internal bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) } //endElem is on the path from startElem to root is enforced by the caller + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private bool DuplicateNS(XmlBoundElement endElem, string lname) { if (_parentOfNS == null || endElem == null) @@ -1562,6 +1573,7 @@ private bool DuplicateNS(XmlBoundElement endElem, string lname) } //Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call ) + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { RealFoliate(); diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs index ae57ad3186ea9..97fcd22ba3412 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs @@ -3,6 +3,7 @@ using System.Data; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Threading; #pragma warning disable 618 // ignore obsolete warning about XmlDataDocument @@ -24,6 +25,7 @@ internal sealed class XmlBoundElement : XmlElement private DataRow? _row; private ElementState _state; + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlBoundElement(string prefix, string localName, string namespaceURI, XmlDocument doc) : base(prefix, localName, namespaceURI, doc) { _state = ElementState.None; @@ -31,6 +33,8 @@ internal XmlBoundElement(string prefix, string localName, string namespaceURI, X public override XmlAttributeCollection Attributes { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { AutoFoliate(); @@ -42,6 +46,8 @@ public override XmlAttributeCollection Attributes public override XmlNode? FirstChild { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { AutoFoliate(); @@ -53,6 +59,8 @@ public override XmlNode? FirstChild public override XmlNode? LastChild { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { AutoFoliate(); @@ -62,6 +70,8 @@ public override XmlNode? LastChild public override XmlNode? PreviousSibling { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { XmlNode? prev = base.PreviousSibling; @@ -82,6 +92,8 @@ public override XmlNode? PreviousSibling public override XmlNode? NextSibling { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { XmlNode? next = base.NextSibling; @@ -102,6 +114,8 @@ public override XmlNode? NextSibling public override bool HasChildNodes { + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] get { AutoFoliate(); @@ -109,24 +123,32 @@ public override bool HasChildNodes } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNode? InsertBefore(XmlNode newChild, XmlNode? refChild) { AutoFoliate(); return base.InsertBefore(newChild, refChild); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNode? InsertAfter(XmlNode newChild, XmlNode? refChild) { AutoFoliate(); return base.InsertAfter(newChild, refChild); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild) { AutoFoliate(); return base.ReplaceChild(newChild, oldChild); } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNode? AppendChild(XmlNode newChild) { AutoFoliate(); @@ -149,6 +171,8 @@ internal void RemoveAllChildren() public override string InnerXml { get { return base.InnerXml; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] set { RemoveAllChildren(); @@ -196,6 +220,8 @@ internal ElementState ElementState set { _state = value; } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] internal void Foliate(ElementState newState) { XmlDataDocument doc = (XmlDataDocument)OwnerDocument; @@ -206,6 +232,7 @@ internal void Foliate(ElementState newState) } // Foliate the node as a side effect of user calling functions on this node (like NextSibling) OR as a side effect of DataDocNav using nodes to do editing + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void AutoFoliate() { XmlDataDocument doc = (XmlDataDocument)OwnerDocument; @@ -237,6 +264,8 @@ public override XmlNode CloneNode(bool deep) return element; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override void WriteContentTo(XmlWriter w) { DataPointer dp = new DataPointer((XmlDataDocument)OwnerDocument, this); @@ -251,6 +280,8 @@ public override void WriteContentTo(XmlWriter w) } } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override void WriteTo(XmlWriter w) { DataPointer dp = new DataPointer((XmlDataDocument)OwnerDocument, this); @@ -265,6 +296,7 @@ public override void WriteTo(XmlWriter w) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void WriteRootBoundElementTo(DataPointer dp, XmlWriter w) { Debug.Assert(dp.NodeType == XmlNodeType.Element); @@ -305,6 +337,7 @@ private void WriteRootBoundElementTo(DataPointer dp, XmlWriter w) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void WriteBoundElementTo(DataPointer dp, XmlWriter w) { Debug.Assert(dp.NodeType == XmlNodeType.Element); @@ -333,6 +366,7 @@ private static void WriteBoundElementTo(DataPointer dp, XmlWriter w) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void WriteBoundElementContentTo(DataPointer dp, XmlWriter w) { if (!dp.IsEmptyElement && dp.MoveToFirstChild()) @@ -347,6 +381,7 @@ private static void WriteBoundElementContentTo(DataPointer dp, XmlWriter w) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void WriteTo(DataPointer dp, XmlWriter w) { switch (dp.NodeType) diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs index 09d6ee751b9b3..dfec09877cbf5 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs @@ -19,6 +19,7 @@ namespace System.Xml [Obsolete("XmlDataDocument class will be removed in a future release.")] public class XmlDataDocument : XmlDocument { + private const string RequiresUnreferencedCodeMessage = "XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly."; private DataSet _dataSet; private DataSetMapper _mapper; @@ -94,6 +95,7 @@ internal void AssertPointerPresent(IXmlDataVirtualNode pointer) // We can set-up listeners and track each change in schema, but it is more perf-friendly to do it laizily, all at once, when the first DataRow is created // (we rely on the fact that DataRowCreated is a DataSet wide event, rather than a DataTable event) [MemberNotNull(nameof(_dataSet))] + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void AttachDataSet(DataSet ds) { // You should not have already an associated dataset @@ -109,6 +111,7 @@ private void AttachDataSet(DataSet ds) // after loading, all detached DataRows are synchronized with the xml tree and inserted to their tables // or after setting the innerxml, synchronize the rows and if created new and detached, will be inserted. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SyncRows(DataRow? parentRow, XmlNode node, bool fAddRowsToTable) { XmlBoundElement? be = node as XmlBoundElement; @@ -142,6 +145,7 @@ internal void SyncRows(DataRow? parentRow, XmlNode node, bool fAddRowsToTable) // All detached DataRows are synchronized with the xml tree and inserted to their tables. // Synchronize the rows and if created new and detached, will be inserted. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void SyncTree(XmlNode node) { XmlBoundElement? be = null; @@ -186,6 +190,7 @@ internal ElementState AutoFoliationState set { _autoFoliationState = value; } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindForLoad() { Debug.Assert(_ignoreXmlEvents == true); @@ -200,6 +205,7 @@ private void BindForLoad() _ignoreDataSetEvents = false; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void Bind(bool fLoadFromDataSet) { // If we have a DocumentElement then it is illegal to call this func to load from data-set @@ -234,6 +240,7 @@ internal void Bind(DataRow r, XmlBoundElement e) } // Binds special listeners to catch the 1st data-row created. When the 1st DataRow is created, XmlDataDocument will automatically bind all regular listeners. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindSpecialListeners() { Debug.Assert(_fDataRowCreatedSpecial == false); @@ -241,6 +248,8 @@ private void BindSpecialListeners() _dataSet.DataRowCreated += new DataRowCreatedEventHandler(OnDataRowCreatedSpecial); _fDataRowCreatedSpecial = true; } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void UnBindSpecialListeners() { Debug.Assert(_fDataRowCreatedSpecial == true); @@ -248,12 +257,14 @@ private void UnBindSpecialListeners() _fDataRowCreatedSpecial = false; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindListeners() { BindToDocument(); BindToDataSet(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindToDataSet() { // We could be already bound to DataSet in this scenario: @@ -292,6 +303,7 @@ private void BindToDataSet() _fBoundToDataSet = true; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindToDocument() { if (!_fBoundToDocument) @@ -306,6 +318,7 @@ private void BindToDocument() } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void BindToTable(DataTable t) { t.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged); @@ -327,6 +340,8 @@ private void BindToTable(DataTable t) /// Creates an element with the specified Prefix, LocalName, and /// NamespaceURI. /// + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlElement CreateElement(string? prefix, string localName, string? namespaceURI) { // There are three states for the document: @@ -452,6 +467,7 @@ private void DefoliateRegion(XmlBoundElement rowElem) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlElement EnsureDocumentElement() { XmlElement? docelem = DocumentElement; @@ -469,6 +485,8 @@ private XmlElement EnsureDocumentElement() return docelem; } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlElement EnsureNonRowDocumentElement() { XmlElement? docElem = DocumentElement; @@ -481,6 +499,8 @@ private XmlElement EnsureNonRowDocumentElement() return DemoteDocumentElement(); } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlElement DemoteDocumentElement() { // Changes of Xml here should not affect ROM @@ -501,6 +521,7 @@ private XmlElement DemoteDocumentElement() // CreateElement will attach DataRows to newly created XmlBoundElement. // It should be called when we have special listeners hooked and we need to change from the special-listeners mode to the // populated/permanenet mode where all listeners are correctly hooked up and the mapper is correctly set-up. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void EnsurePopulatedMode() { // Unbind special listeners, bind permanent ones, setup the mapping, etc @@ -567,6 +588,7 @@ private void FixNestedChildren(DataRow row, XmlElement rowElement) } // This function accepts node params that are not row-elements. In this case, calling this function is a no-op + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void Foliate(XmlBoundElement node, ElementState newState) { Debug.Assert(newState == ElementState.WeakFoliation || newState == ElementState.StrongFoliation); @@ -608,6 +630,7 @@ internal void Foliate(XmlBoundElement node, ElementState newState) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void Foliate(XmlElement element) { if (element is XmlBoundElement) @@ -615,6 +638,7 @@ private void Foliate(XmlElement element) } // Foliate rowElement region if there are DataPointers that points into it + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void FoliateIfDataPointers(DataRow row, XmlElement rowElement) { if (!IsFoliated(rowElement) && HasPointers(rowElement)) @@ -632,6 +656,7 @@ private void FoliateIfDataPointers(DataRow row, XmlElement rowElement) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void EnsureFoliation(XmlBoundElement rowElem, ElementState foliation) { if (rowElem.IsFoliated) //perf reason, avoid unecessary lock. @@ -639,6 +664,7 @@ private void EnsureFoliation(XmlBoundElement rowElem, ElementState foliation) ForceFoliation(rowElem, foliation); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void ForceFoliation(XmlBoundElement node, ElementState newState) { lock (_foliationLock) @@ -937,6 +963,7 @@ internal bool IsFoliationEnabled // This creates a tree and synchronize ROM w/ the created tree. // It requires the populated mode to be on - in case we are not in populated mode, it will make the XmlDataDocument be in populated mode. // It takes advantage of the fAssociateDataRow flag for populated mode, which allows creation of XmlBoundElement w/o associating DataRow objects. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal XmlNode CloneTree(DataPointer other) { EnsurePopulatedMode(); @@ -975,6 +1002,7 @@ internal XmlNode CloneTree(DataPointer other) return newNode; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlNode CloneTreeInternal(DataPointer other) { Debug.Assert(_ignoreDataSetEvents == true); @@ -1014,6 +1042,8 @@ private XmlNode CloneTreeInternal(DataPointer other) return newNode; } + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlNode CloneNode(bool deep) { XmlDataDocument clone = (XmlDataDocument)(base.CloneNode(false)); @@ -1046,6 +1076,7 @@ public override XmlNode CloneNode(bool deep) return clone; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlNode CloneNode(DataPointer dp) => dp.NodeType switch { @@ -1141,6 +1172,8 @@ public override void Load(TextReader txtReader) /// /// Loads the XML document from the specified XmlReader. /// + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override void Load(XmlReader reader) { if (FirstChild != null) @@ -1177,6 +1210,7 @@ public override void Load(XmlReader reader) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadDataSetFromTree() { _ignoreDataSetEvents = true; @@ -1202,6 +1236,7 @@ private void LoadDataSetFromTree() } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadTreeFromDataSet(DataSet ds) { _ignoreDataSetEvents = true; @@ -1258,6 +1293,7 @@ private void LoadTreeFromDataSet(DataSet ds) } // load all data from tree structre into datarows + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void LoadRows(XmlBoundElement? rowElem, XmlNode node) { Debug.Assert(node != null); @@ -1295,6 +1331,7 @@ internal DataSetMapper Mapper } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void OnDataRowCreated(object oDataSet, DataRow row) { Debug.Assert(row.RowState == DataRowState.Detached); @@ -1306,6 +1343,7 @@ internal void OnClearCalled(object oDataSet, DataTable? table) throw new NotSupportedException(SR.DataDom_NotSupport_Clear); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void OnDataRowCreatedSpecial(object oDataSet, DataRow row) { Debug.Assert(row.RowState == DataRowState.Detached); @@ -1315,7 +1353,9 @@ internal void OnDataRowCreatedSpecial(object oDataSet, DataRow row) // Pass the event to the regular listener OnNewRow(row); } + // Called when a new DataRow is created + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal void OnNewRow(DataRow row) { Debug.Assert(row.Element == null); @@ -1325,6 +1365,7 @@ internal void OnNewRow(DataRow row) AttachBoundElementToDataRow(row); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private XmlBoundElement AttachBoundElementToDataRow(DataRow row) { Debug.Assert(row.Element == null); @@ -1347,6 +1388,7 @@ private bool NeedXSI_NilAttr(DataRow row) return (Convert.IsDBNull(value)); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnAddRow(DataRow row) { // Xml operations in this func should not trigger ROM operations @@ -1374,6 +1416,7 @@ private void OnAddRow(DataRow row) OnNestedParentChange(row, rowElement, null); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnColumnValueChanged(DataRow row, DataColumn col, XmlBoundElement rowElement) { if (IsNotMapped(col)) @@ -1552,6 +1595,7 @@ private void OnColumnValueChanged(DataRow row, DataColumn col, XmlBoundElement r } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnColumnChanged(object sender, DataColumnChangeEventArgs args) { // You should not be able to make DataRow field changes if the DataRow is deleted @@ -1588,6 +1632,7 @@ private void OnColumnChanged(object sender, DataColumnChangeEventArgs args) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnColumnValuesChanged(DataRow row, XmlBoundElement rowElement) { Debug.Assert(row != null); @@ -1616,6 +1661,7 @@ private void OnColumnValuesChanged(DataRow row, XmlBoundElement rowElement) _columnChangeList.Clear(); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnDeleteRow(DataRow row, XmlBoundElement rowElement) { // IgnoreXmlEvents s/b on since we are manipulating the XML tree and we not want this to reflect in ROM view. @@ -1629,6 +1675,7 @@ private void OnDeleteRow(DataRow row, XmlBoundElement rowElement) rowElement.ParentNode!.RemoveChild(rowElement); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnDeletingRow(DataRow row, XmlBoundElement rowElement) { // Note that this function is beeing called even if ignoreDataSetEvents == true. @@ -1690,6 +1737,7 @@ private void OnFoliated(XmlNode node) } // Change the childElement position in the tree to conform to the parent nested relationship in ROM + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNestedParentChange(DataRow child, XmlBoundElement childElement, DataColumn? childCol) { Debug.Assert(child.Element == childElement && childElement.Row == child); @@ -1743,6 +1791,7 @@ private void OnNestedParentChange(DataRow child, XmlBoundElement childElement, D #endif } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeChanged(object sender, XmlNodeChangedEventArgs args) { if (_ignoreXmlEvents) @@ -1786,7 +1835,7 @@ private void OnNodeChanging(object sender, XmlNodeChangedEventArgs args) throw new InvalidOperationException(SR.DataDom_EnforceConstraintsShouldBeOff); } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeInserted(object sender, XmlNodeChangedEventArgs args) { if (_ignoreXmlEvents) @@ -1841,7 +1890,7 @@ private void OnNodeInserting(object sender, XmlNodeChangedEventArgs args) throw new InvalidOperationException(SR.DataDom_EnforceConstraintsShouldBeOff); } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeRemoved(object sender, XmlNodeChangedEventArgs args) { if (_ignoreXmlEvents) @@ -1894,6 +1943,7 @@ private void OnNodeRemoving(object sender, XmlNodeChangedEventArgs args) } // Node was removed from connected tree to disconnected tree + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeRemovedFromTree(XmlNode node, XmlNode? oldParent) { XmlBoundElement? oldRowElem; @@ -1916,7 +1966,9 @@ private void OnNodeRemovedFromTree(XmlNode node, XmlNode? oldParent) // Assert that all sub-regions are disconnected AssertNonLiveRows(node); } + // Node was removed from the disconnected tree to disconnected tree + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeRemovedFromFragment(XmlNode node, XmlNode? oldParent) { XmlBoundElement? oldRowElem; @@ -1953,7 +2005,7 @@ private void OnNodeRemovedFromFragment(XmlNode node, XmlNode? oldParent) AssertNonLiveRows(node); } - + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnRowChanged(object sender, DataRowChangeEventArgs args) { if (_ignoreDataSetEvents) @@ -2020,6 +2072,7 @@ private void OnRowChanged(object sender, DataRowChangeEventArgs args) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnRowChanging(object sender, DataRowChangeEventArgs args) { // We foliate the region each time the assocaited row gets deleted @@ -2198,6 +2251,7 @@ private void OnRelationPropertyChanging(object? oRelationsCollection, PropertyCh throw new InvalidOperationException(SR.DataDom_DataSetNestedRelationsChange); } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnUndeleteRow(DataRow row, XmlElement rowElement) { XmlNode? refRow; @@ -2244,6 +2298,7 @@ private void PromoteChild(XmlNode child, XmlNode prevSibling) } // Promote child regions under parent as next siblings of parent + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void PromoteInnerRegions(XmlNode parent) { Debug.Assert(parent != null); @@ -2349,6 +2404,7 @@ private void ReplaceInitialChildText(XmlNode parent, string value) return n.PreviousSibling; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal static void SetRowValueToNull(DataRow row, DataColumn col) { Debug.Assert(col.ColumnMapping != MappingType.Hidden); @@ -2359,6 +2415,7 @@ internal static void SetRowValueToNull(DataRow row, DataColumn col) } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] internal static void SetRowValueFromXmlText(DataRow row, DataColumn col, string xmlText) { Debug.Assert(xmlText != null); @@ -2381,12 +2438,15 @@ internal static void SetRowValueFromXmlText(DataRow row, DataColumn col, string row[col] = oVal; } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SynchronizeRowFromRowElement(XmlBoundElement rowElement) { SynchronizeRowFromRowElement(rowElement, null); } + // Sync row fields w/ values from rowElem region. // If rowElemList is != null, all subregions of rowElem are appended to it. + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SynchronizeRowFromRowElement(XmlBoundElement rowElement, ArrayList? rowElemList) { DataRow? row = rowElement.Row; @@ -2424,6 +2484,8 @@ private void SynchronizeRowFromRowElement(XmlBoundElement rowElement, ArrayList? } #endif } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SynchronizeRowFromRowElementEx(XmlBoundElement rowElement, ArrayList? rowElemList) { Debug.Assert(rowElement != null); @@ -2523,6 +2585,7 @@ private void SynchronizeRowFromRowElementEx(XmlBoundElement rowElement, ArrayLis } } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void UpdateAllColumns(DataRow row, XmlBoundElement rowElement) { foreach (DataColumn c in row.Table.Columns) @@ -2534,6 +2597,7 @@ private void UpdateAllColumns(DataRow row, XmlBoundElement rowElement) /// /// Initializes a new instance of the XmlDataDocument class. /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlDataDocument() : base(new XmlDataImplementation()) { Init(); @@ -2545,11 +2609,13 @@ public XmlDataDocument() : base(new XmlDataImplementation()) /// Initializes a new instance of the XmlDataDocument class with the specified /// DataSet. /// + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] public XmlDataDocument(DataSet dataset) : base(new XmlDataImplementation()) { Init(dataset); } + [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] internal XmlDataDocument(XmlImplementation imp) : base(imp) { // This constructor is used by XmlDataImplementation.CreateDocument(), which @@ -2592,6 +2658,7 @@ private void Init() [MemberNotNull(nameof(_foliationLock))] [MemberNotNull(nameof(_attrXml))] [MemberNotNull(nameof(_dataSet))] + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void Init(DataSet ds) { if (ds == null) @@ -2624,6 +2691,8 @@ private bool IsRowLive(DataRow row) { return (row.RowState & (DataRowState.Added | DataRowState.Unchanged | DataRowState.Modified)) != 0; } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private static void SetNestedParentRow(DataRow childRow, DataRow? parentRow) { DataRelation? rel = GetNestedParentRelation(childRow); @@ -2638,6 +2707,7 @@ private static void SetNestedParentRow(DataRow childRow, DataRow? parentRow) } // A node (node) was inserted into the main tree (connected) from oldParent==null state + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeInsertedInTree(XmlNode node) { XmlBoundElement? be; @@ -2676,6 +2746,7 @@ private void OnNodeInsertedInTree(XmlNode node) AssertLiveRows(node); } // "node" was inserting into a disconnected tree from oldParent==null state + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNodeInsertedInFragment(XmlNode node) { XmlBoundElement? be; @@ -2713,6 +2784,7 @@ private void OnNodeInsertedInFragment(XmlNode node) } // A row-elem was inserted into the connected tree (connected) from oldParent==null state + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnRowElementInsertedInTree(XmlBoundElement rowElem, ArrayList rowElemList) { Debug.Assert(rowElem.Row != null); @@ -2775,6 +2847,7 @@ private void OnRowElementInsertedInTree(XmlBoundElement rowElem, ArrayList rowEl } // Disconnect the DataRow associated w/ the rowElem region + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void EnsureDisconnectedDataRow(XmlBoundElement rowElem) { Debug.Assert(rowElem.Row != null); @@ -2827,6 +2900,7 @@ private void EnsureDisconnectedDataRow(XmlBoundElement rowElem) // A non-row-elem was inserted into the connected tree (connected) from oldParent==null state + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNonRowElementInsertedInTree(XmlNode node, XmlBoundElement rowElement, ArrayList rowElemList) { // non-row-elem is beeing inserted @@ -2843,6 +2917,7 @@ private void OnNonRowElementInsertedInTree(XmlNode node, XmlBoundElement rowElem } // A non-row-elem was inserted into disconnected tree (fragment) from oldParent==null state (i.e. was disconnected) + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void OnNonRowElementInsertedInFragment(XmlNode node, XmlBoundElement rowElement, ArrayList rowElemList) { // non-row-elem is beeing inserted @@ -2857,6 +2932,7 @@ private void OnNonRowElementInsertedInFragment(XmlNode node, XmlBoundElement row // Nothing to do if the row is deleted (there is no sync-ing from XML to ROM for deleted rows) } + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SetNestedParentRegion(XmlBoundElement childRowElem) { Debug.Assert(childRowElem.Row != null); @@ -2865,6 +2941,8 @@ private void SetNestedParentRegion(XmlBoundElement childRowElem) _mapper.GetRegion(childRowElem.ParentNode, out parentRowElem); SetNestedParentRegion(childRowElem, parentRowElem); } + + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] private void SetNestedParentRegion(XmlBoundElement childRowElem, XmlBoundElement? parentRowElem) { DataRow childRow = childRowElem.Row!; @@ -2925,7 +3003,8 @@ internal static bool IsOnlyWhitespace( string str ) { return true; } */ - + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] protected override XPathNavigator? CreateNavigator(XmlNode node) { Debug.Assert(node.OwnerDocument == this || node == this); diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlDataImplementation.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlDataImplementation.cs index a161154f3152f..eb1adac8fe4fb 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlDataImplementation.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlDataImplementation.cs @@ -3,11 +3,18 @@ #pragma warning disable 618 // ignore obsolete warning about XmlDataDocument +using System.Data; +using System.Diagnostics.CodeAnalysis; + namespace System.Xml { internal sealed class XmlDataImplementation : XmlImplementation { + [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] public XmlDataImplementation() : base() { } + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "This whole class is unsafe. Constructors are marked as such.")] public override XmlDocument CreateDocument() => new XmlDataDocument(this); } } diff --git a/src/libraries/System.Data.Odbc/src/ILLink/ILLink.Suppressions.xml b/src/libraries/System.Data.Odbc/src/ILLink/ILLink.Suppressions.xml index 04be721d7102d..533fc1cd0ed04 100644 --- a/src/libraries/System.Data.Odbc/src/ILLink/ILLink.Suppressions.xml +++ b/src/libraries/System.Data.Odbc/src/ILLink/ILLink.Suppressions.xml @@ -7,5 +7,53 @@ member M:Interop.Odbc.SQLSetConnectAttrW(System.Data.Odbc.OdbcConnectionHandle,System.Data.Odbc.ODBC32.SQL_ATTR,System.Transactions.IDtcTransaction,System.Int32) + + ILLink + IL2026 + member + M:System.Data.ProviderBase.DbMetaDataFactory.#ctor(System.IO.Stream,System.String,System.String) + + + ILLink + IL2072 + member + M:System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(System.Data.DataRow,System.String[],System.Data.Common.DbConnection) + + + ILLink + IL2026 + member + M:System.Data.Odbc.OdbcDataAdapter.#ctor() + + + ILLink + IL2026 + member + M:System.Data.Odbc.OdbcDataAdapter.#ctor(System.String,System.String) + + + ILLink + IL2026 + member + M:System.Data.Odbc.OdbcDataAdapter.#ctor(System.String,System.Data.Odbc.OdbcConnection) + + + ILLink + IL2026 + member + M:System.Data.Odbc.OdbcDataAdapter.#ctor(System.Data.Odbc.OdbcCommand) + + + ILLink + IL2026 + member + M:System.Data.Odbc.OdbcDataAdapter.#ctor(System.Data.Odbc.OdbcDataAdapter) + + + ILLink + IL2072 + member + M:System.Data.Odbc.OdbcMetaDataFactory.NewDataTableFromReader(System.Data.IDataReader,System.Object[]@,System.String) + \ No newline at end of file diff --git a/src/libraries/System.Data.OleDb/src/ILLink/ILLink.Suppressions.xml b/src/libraries/System.Data.OleDb/src/ILLink/ILLink.Suppressions.xml index a177940c6f5fa..2e52a33c8a98e 100644 --- a/src/libraries/System.Data.OleDb/src/ILLink/ILLink.Suppressions.xml +++ b/src/libraries/System.Data.OleDb/src/ILLink/ILLink.Suppressions.xml @@ -19,5 +19,59 @@ member M:System.Data.OleDb.OleDbConnectionInternal.CreateInstanceDataLinks + + ILLink + IL2026 + member + M:System.Data.ProviderBase.DbMetaDataFactory.#ctor(System.IO.Stream,System.String,System.String) + + + ILLink + IL2072 + member + M:System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(System.Data.DataRow,System.String[],System.Data.Common.DbConnection) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbCommandBuilder.DeriveParametersFromStoredProcedure(System.Data.OleDb.OleDbConnection,System.Data.OleDb.OleDbCommand) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbDataAdapter.#ctor() + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbDataAdapter.#ctor(System.String,System.String) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbDataAdapter.#ctor(System.String,System.Data.OleDb.OleDbConnection) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbDataAdapter.#ctor(System.Data.OleDb.OleDbCommand) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbDataAdapter.#ctor(System.Data.OleDb.OleDbDataAdapter) + + + ILLink + IL2026 + member + M:System.Data.OleDb.OleDbMetaDataFactory.GetDataSourceInformationTable(System.Data.OleDb.OleDbConnection,System.Data.OleDb.OleDbConnectionInternal) + \ No newline at end of file