Skip to content

Commit

Permalink
Remove RUC from DataSet ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
krwq committed May 7, 2021
1 parent 928b9d6 commit 33b3e45
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 33 deletions.
3 changes: 0 additions & 3 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ protected internal DataRow(System.Data.DataRowBuilder builder) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public void AcceptChanges() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public void BeginEdit() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void CancelEdit() { }
Expand Down Expand Up @@ -529,13 +528,11 @@ public void EndEdit() { }
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataSetSchema")]
public partial class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataSet() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions 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 or types used in expressions may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataSet(string dataSetName) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool CaseSensitive { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")] set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<property name="Scope">member</property>
<property name="Target">M:System.Data.Common.DataAdapter.CloneInternals</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2026</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Data.DataSet.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2026</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ public virtual void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRoo
xmlWriter.WriteString(ConvertObjectToXml(value)); // should it be NO OP?
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
public static DataStorage CreateStorage(DataColumn column, Type dataType, StorageType typeCode)
public static DataStorage CreateStorage(DataColumn column, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type dataType, StorageType typeCode)
{
Debug.Assert(typeCode == GetStorageType(dataType), "Incorrect storage type specified");
if ((StorageType.Empty == typeCode) && (null != dataType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ internal sealed class SqlUdtStorage : DataStorage

private static readonly ConcurrentDictionary<Type, object> s_typeToNull = new ConcurrentDictionary<Type, object>();

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
public SqlUdtStorage(DataColumn column, Type type)
public SqlUdtStorage(DataColumn column, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type)
: this(column, type, GetStaticNullForUdtType(type))
{
}
Expand All @@ -36,8 +35,7 @@ private SqlUdtStorage(DataColumn column, Type type, object nullValue)
}

// to support oracle types and other INUllable types that have static Null as field
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal static object GetStaticNullForUdtType(Type type) => s_typeToNull.GetOrAdd(type, t => GetStaticNullForUdtTypeCore(type));
internal static object GetStaticNullForUdtType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => s_typeToNull.GetOrAdd(type, t => GetStaticNullForUdtTypeCore(type));

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern",
Justification = "The only callsite is marked as unsafe. Workaround for https://github.com/mono/linker/issues/1981")]
Expand Down
13 changes: 4 additions & 9 deletions src/libraries/System.Data.Common/src/System/Data/DataColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class DataColumn : MarshalByValueComponent
private bool _allowNull = true;
private string? _caption;
private string _columnName;
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
private Type _dataType = null!; // Always set in UpdateColumnType
private StorageType _storageType;
internal object _defaultValue = DBNull.Value; // DefaultValue Converter
Expand Down Expand Up @@ -97,7 +98,7 @@ public DataColumn(string? columnName) : this(columnName, typeof(string), null, M
/// using the specified column name and data type.
/// </summary>
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = "Not using expression. `dataType` is marked so that it's safe.")]
Justification = "Expression is null and `dataType` is marked appropriately.")]
public DataColumn(string? columnName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type dataType) : this(columnName, dataType, null, MappingType.Element)
{
}
Expand Down Expand Up @@ -151,8 +152,7 @@ public DataColumn(string? columnName, Type dataType, string? expr, MappingType t
_columnMapping = type;
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private void UpdateColumnType(Type type, StorageType typeCode)
private void UpdateColumnType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type, StorageType typeCode)
{
TypeLimiter.EnsureTypeIsAllowed(type);
_dataType = type;
Expand Down Expand Up @@ -491,11 +491,11 @@ public string Prefix
[DefaultValue(typeof(string))]
[RefreshProperties(RefreshProperties.All)]
[TypeConverter(typeof(ColumnTypeConverter))]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
[AllowNull]
public Type DataType
{
get { return _dataType; }
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
set
{
if (_dataType != value)
Expand Down Expand Up @@ -660,7 +660,6 @@ public DataSetDateTime DateTimeMode
[AllowNull]
public object DefaultValue
{
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
get
{
Debug.Assert(_defaultValue != null, "It should not have been set to null.");
Expand All @@ -687,7 +686,6 @@ public object DefaultValue

return _defaultValue;
}
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
set
{
DataCommonEventSource.Log.Trace("<ds.DataColumn.set_DefaultValue|API> {0}", ObjectID);
Expand Down Expand Up @@ -1774,7 +1772,6 @@ protected internal void RaisePropertyChanging(string name)
OnPropertyChanging(new PropertyChangedEventArgs(name));
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private DataStorage InsureStorage()
{
if (_storage == null)
Expand All @@ -1785,7 +1782,6 @@ private DataStorage InsureStorage()
return _storage;
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal void SetCapacity(int capacity)
{
InsureStorage().SetCapacity(capacity);
Expand Down Expand Up @@ -1827,7 +1823,6 @@ internal void ConvertObjectToXml(object value, XmlWriter xmlWriter, XmlRootAttri
InsureStorage().ConvertObjectToXml(value, xmlWriter, xmlAttrib);
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal object GetEmptyColumnStore(int recordCount)
{
return InsureStorage().GetEmptyStorageInternal(recordCount);
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/System.Data.Common/src/System/Data/DataRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,8 @@ public void AcceptChanges()
/// Begins an edit operation on a <see cref='System.Data.DataRow'/>object.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)]
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
public void BeginEdit() => BeginEditInternal();

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private bool BeginEditInternal()
{
if (_inChangingEvent)
Expand Down
6 changes: 1 addition & 5 deletions src/libraries/System.Data.Common/src/System/Data/DataSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace System.Data
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, ISupportInitializeNotification, ISerializable
{
internal const string RequiresUnreferencedCodeMessage = "Members from serialized types or types used in expressions may be trimmed if not referenced directly.";
internal const string RequiresUnreferencedCodeMessage = "Members from serialized types or types used in expressions may be trimmed if not referenced directly";
private const string KEY_XMLSCHEMA = "XmlSchema";
private const string KEY_XMLDIFFGRAM = "XmlDiffGram";

Expand Down Expand Up @@ -78,7 +78,6 @@ public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, I
/// <summary>
/// Initializes a new instance of the <see cref='System.Data.DataSet'/> class.
/// </summary>
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
public DataSet()
{
GC.SuppressFinalize(this);
Expand All @@ -94,7 +93,6 @@ public DataSet()
/// Initializes a new instance of a <see cref='System.Data.DataSet'/>
/// class with the given name.
/// </summary>
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
public DataSet(string dataSetName) : this()
{
DataSetName = dataSetName;
Expand Down Expand Up @@ -269,8 +267,6 @@ protected DataSet(SerializationInfo info, StreamingContext context, bool Constru
DeserializeDataSet(info, context, remotingFormat, schemaSerializationMode);
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = "This whole class is unsafe. Constructors are marked as such.")]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
SerializationFormat remotingFormat = RemotingFormat;
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/System.Data.Common/src/System/Data/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3418,7 +3418,6 @@ private IndexField[] NewIndexDesc(DataKey key)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal int NewRecord() => NewRecord(-1);

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal int NewUninitializedRecord()
{
return _recordManager.NewRecordBase();
Expand Down Expand Up @@ -3459,7 +3458,6 @@ internal int NewRecordFromArray(object?[] value)
}
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal int NewRecord(int sourceRecord)
{
int record = _recordManager.NewRecordBase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal RecordManager(DataTable table)
_table = table;
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private void GrowRecordCapacity()
{
RecordCapacity = NewCapacity(_recordCapacity) < NormalizedMinimumCapacity(_minimumCapacity) ?
Expand Down Expand Up @@ -64,7 +63,6 @@ internal int MinimumCapacity
internal int RecordCapacity
{
get { return _recordCapacity; }
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
set
{
if (_recordCapacity != value)
Expand Down Expand Up @@ -98,7 +96,6 @@ private int NormalizedMinimumCapacity(int capacity)
return (((capacity + 10) >> 10) + 1) << 10;
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
internal int NewRecordBase()
{
int record;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ internal ElementState ElementState
set { _state = value; }
}

[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = "This whole class is unsafe. Constructors are marked as such.")]
internal void Foliate(ElementState newState)
{
XmlDataDocument doc = (XmlDataDocument)OwnerDocument;
Expand All @@ -241,8 +242,6 @@ private void AutoFoliate()
}
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = "This whole class is unsafe. Constructors are marked as such.")]
public override XmlNode CloneNode(bool deep)
{
XmlDataDocument doc = (XmlDataDocument)(OwnerDocument);
Expand Down

0 comments on commit 33b3e45

Please sign in to comment.