Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add ILLink annotations to S.D.Common related to DbConnectionStringBuilder #54280

Merged
merged 5 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace System.ComponentModel.DataAnnotations
Expand All @@ -20,6 +21,7 @@ public MetadataPropertyDescriptorWrapper(PropertyDescriptor descriptor, Attribut
_isReadOnly = (readOnlyAttribute != null ? readOnlyAttribute.IsReadOnly : false);
}

[RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public override void AddValueChanged(object component, EventHandler handler) { _descriptor.AddValueChanged(component, handler); }

public override bool CanResetValue(object component) { return _descriptor.CanResetValue(component); }
Expand All @@ -41,6 +43,7 @@ public override bool IsReadOnly

public override Type PropertyType { get { return _descriptor.PropertyType; } }

[RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public override void RemoveValueChanged(object component, EventHandler handler) { _descriptor.RemoveValueChanged(component, handler); }

public override void ResetValue(object component) { _descriptor.ResetValue(component); }
Expand All @@ -49,6 +52,10 @@ public override bool IsReadOnly

public override bool ShouldSerializeValue(object component) { return _descriptor.ShouldSerializeValue(component); }

public override bool SupportsChangeEvents { get { return _descriptor.SupportsChangeEvents; } }
public override bool SupportsChangeEvents
{
[RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
get { return _descriptor.SupportsChangeEvents; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ protected CustomTypeDescriptor(System.ComponentModel.ICustomTypeDescriptor paren
public virtual System.ComponentModel.PropertyDescriptor GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
public virtual object GetEditor(System.Type editorBaseType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public virtual System.ComponentModel.EventDescriptorCollection GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public virtual System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes) { throw null; }
Expand Down Expand Up @@ -579,6 +580,7 @@ public partial interface ICustomTypeDescriptor
System.ComponentModel.PropertyDescriptor GetDefaultProperty();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object GetEditor(System.Type editorBaseType);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptorCollection GetEvents();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes);
Expand Down Expand Up @@ -1055,7 +1057,8 @@ protected PropertyDescriptor(string name, System.Attribute[] attrs) : base (defa
public abstract bool IsReadOnly { get; }
public abstract System.Type PropertyType { get; }
public System.ComponentModel.DesignerSerializationVisibility SerializationVisibility { get { throw null; } }
public virtual bool SupportsChangeEvents { get { throw null; } }
public virtual bool SupportsChangeEvents { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")] get { throw null; } }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public virtual void AddValueChanged(object component, System.EventHandler handler) { }
public abstract bool CanResetValue(object component);
protected object CreateInstance([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type) { throw null; }
Expand All @@ -1079,6 +1082,7 @@ protected override void FillAttributes(System.Collections.IList attributeList) {
public abstract object GetValue(object component);
protected internal System.EventHandler GetValueChangedHandler(object component) { throw null; }
protected virtual void OnValueChanged(object component, System.EventArgs e) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public virtual void RemoveValueChanged(object component, System.EventHandler handler) { }
public abstract void ResetValue(object component);
public abstract void SetValue(object component, object value);
Expand Down Expand Up @@ -1470,6 +1474,7 @@ public static void CreateAssociation(object primary, object secondary) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of component cannot be statically discovered.")]
public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
public static System.ComponentModel.EventDescriptorCollection GetEvents([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public static System.ComponentModel.EventDescriptorCollection GetEvents([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType, System.Attribute[] attributes) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ public override Type PropertyType

public override bool SupportsChangeEvents
{
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
get { return true; }
}

[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public override void AddValueChanged(object component, EventHandler handler)
{
bool hasValueChangedHandler = GetValueChangedHandler(component) != null;
Expand All @@ -108,6 +110,7 @@ public override bool CanResetValue(object component)
return false;
}

[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public override void RemoveValueChanged(object component, EventHandler handler)
{
base.RemoveValueChanged(component, handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public virtual TypeConverter GetConverter()
/// returned. If no parent is provided,this will return an empty
/// event collection.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public virtual EventDescriptorCollection GetEvents()
{
if (_parent != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public interface ICustomTypeDescriptor
/// <summary>
/// Gets the events for this instance of a component.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
EventDescriptorCollection GetEvents();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public DesignerSerializationVisibility SerializationVisibility
/// <summary>
/// Allows interested objects to be notified when this property changes.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public virtual void AddValueChanged(object component, EventHandler handler)
{
if (component == null)
Expand Down Expand Up @@ -399,6 +400,7 @@ protected virtual void OnValueChanged(object component, EventArgs e)
/// <summary>
/// Allows interested objects to be notified when this property changes.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public virtual void RemoveValueChanged(object component, EventHandler handler)
{
if (component == null)
Expand Down Expand Up @@ -465,6 +467,10 @@ protected internal EventHandler GetValueChangedHandler(object component)
/// from direct calls made to PropertyDescriptor.SetValue (value=false). For example, the component may
/// implement the INotifyPropertyChanged interface, or may have an explicit '{name}Changed' event for this property.
/// </summary>
public virtual bool SupportsChangeEvents => false;
public virtual bool SupportsChangeEvents
{
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
get => false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ private object AmbientValue
/// </summary>
private EventDescriptor ChangedEventValue
{
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
get
{
if (!_state[s_bitChangedQueried])
Expand All @@ -263,6 +264,7 @@ private EventDescriptor ChangedEventValue
/// </summary>
private EventDescriptor IPropChangedEventValue
{
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
get
{
if (!_state[s_bitIPropChangedQueried])
Expand Down Expand Up @@ -481,6 +483,7 @@ private MethodInfo ShouldSerializeMethodValue
/// <summary>
/// Allows interested objects to be notified when this property changes.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public override void AddValueChanged(object component, EventHandler handler)
{
if (component == null)
Expand Down Expand Up @@ -963,6 +966,7 @@ protected override void OnValueChanged(object component, EventArgs e)
/// <summary>
/// Allows interested objects to be notified when this property changes.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public override void RemoveValueChanged(object component, EventHandler handler)
{
if (component == null)
Expand Down Expand Up @@ -1197,6 +1201,11 @@ public override bool ShouldSerializeValue(object component)
/// from direct calls made to PropertyDescriptor.SetValue (value=false). For example, the component may
/// implement the INotifyPropertyChanged interface, or may have an explicit '{name}Changed' event for this property.
/// </summary>
public override bool SupportsChangeEvents => IPropChangedEventValue != null || ChangedEventValue != null;
public override bool SupportsChangeEvents
{
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]

get => IPropChangedEventValue != null || ChangedEventValue != null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ public static object GetEditor(
/// <summary>
/// Gets a collection of events for a specified type of component.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
public static EventDescriptorCollection GetEvents(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
{
Expand Down Expand Up @@ -2746,6 +2747,7 @@ object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
return _handler.GetEditor(_instance, editorBaseType);
}

[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return _handler.GetEvents(_instance);
Expand Down Expand Up @@ -3067,6 +3069,7 @@ object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
EventDescriptorCollection events = _primary.GetEvents() ?? _secondary.GetEvents();
Expand Down Expand Up @@ -3468,7 +3471,7 @@ object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
// Check to see if the provider we get is a ReflectTypeDescriptionProvider.
Expand Down Expand Up @@ -3801,6 +3804,7 @@ object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
[RequiresUnreferencedCode(EventDescriptor.RequiresUnreferencedCodeMessage)]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
// Check to see if the provider we get is a ReflectTypeDescriptionProvider.
Expand Down
5 changes: 5 additions & 0 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ public void EndEdit() { }
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[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; }
Expand Down Expand Up @@ -2095,6 +2096,7 @@ protected virtual void OnStateChange(System.Data.StateChangeEventArgs stateChang
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction(System.Data.IsolationLevel isolationLevel) { throw null; }
System.Data.IDbCommand System.Data.IDbConnection.CreateCommand() { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public partial class DbConnectionStringBuilder : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.ComponentModel.ICustomTypeDescriptor
{
public DbConnectionStringBuilder() { }
Expand Down Expand Up @@ -2130,6 +2132,7 @@ public virtual void Clear() { }
protected internal void ClearPropertyDescriptors() { }
public virtual bool ContainsKey(string keyword) { throw null; }
public virtual bool EquivalentTo(System.Data.Common.DbConnectionStringBuilder connectionStringBuilder) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
protected virtual void GetProperties(System.Collections.Hashtable propertyDescriptors) { }
public virtual bool Remove(string keyword) { throw null; }
public virtual bool ShouldSerialize(string keyword) { throw null; }
Expand All @@ -2150,6 +2153,7 @@ void System.Collections.IDictionary.Remove(object keyword) { }
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[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; }
Expand Down Expand Up @@ -2332,6 +2336,7 @@ protected DbDataRecord() { }
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[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; }
Expand Down
Loading