Resolve ILLink warnings in System.ComponentModel.TypeConverter (Round 1) (#48890)
authorEric Erhardt <eric.erhardt@microsoft.com>
Tue, 9 Mar 2021 18:49:25 +0000 (12:49 -0600)
committerGitHub <noreply@github.com>
Tue, 9 Mar 2021 18:49:25 +0000 (12:49 -0600)
* Resolve ILLink warnings in System.ComponentModel.TypeConverter (Round 1)

Contributes to #45623

* Update the AttributeCollection message

* Add trimming test for SimplePropertyDescriptor.IsReadOnly

* Update the ref source with DynamicallyAccessedMembers attributes

53 files changed:
src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs
src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.csproj
src/libraries/System.ComponentModel.Annotations/src/ILLink/ILLink.Suppressions.xml
src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/AssociatedMetadataTypeTypeDescriptionProvider.cs
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/AssociatedMetadataTypeTypeDescriptor.cs
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/MetadataTypeAttribute.cs
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/RangeAttribute.cs
src/libraries/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs
src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/IContainer.cs
src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/ISite.cs
src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Suppressions.xml
src/libraries/System.ComponentModel.TypeConverter/src/MS/Internal/Xml/Linq/ComponentModel/XComponentModel.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AmbientValueAttribute.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ArrayConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CollectionConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Container.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CustomTypeDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/DelegatingTypeDescriptionProvider.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/IDesignerOptionService.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/Serialization/MemberRelationshipService.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExpandableObjectConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MultilineStringConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NestedContainer.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs
src/libraries/System.ComponentModel.TypeConverter/tests/TrimmingTests/TypeConverterIsReadOnly.cs [new file with mode: 0644]
src/libraries/System.Data.Common/ref/System.Data.Common.cs
src/libraries/System.Data.Common/src/ILLink/ILLink.Suppressions.xml
src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
src/libraries/System.Data.Common/src/System/Data/DataRowView.cs
src/libraries/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs
src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs

index ec83158..e50b882 100644 (file)
@@ -6,13 +6,13 @@
 
 namespace System.ComponentModel.DataAnnotations
 {
-// TODO-NULLABLE: Enable after System.ComponentModel.TypeDescriptionProvider is annotated
+    // TODO-NULLABLE: Enable after System.ComponentModel.TypeDescriptionProvider is annotated
 #nullable disable
     public partial class AssociatedMetadataTypeTypeDescriptionProvider : System.ComponentModel.TypeDescriptionProvider
     {
         public AssociatedMetadataTypeTypeDescriptionProvider(System.Type type) { }
-        public AssociatedMetadataTypeTypeDescriptionProvider(System.Type type, System.Type associatedMetadataType) { }
-        public override System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType, object instance) { throw null; }
+        public AssociatedMetadataTypeTypeDescriptionProvider(System.Type type, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type associatedMetadataType) { }
+        public override System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type objectType, object instance) { throw null; }
     }
 #nullable enable
     [System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
@@ -194,7 +194,8 @@ namespace System.ComponentModel.DataAnnotations
     [System.AttributeUsageAttribute(System.AttributeTargets.Class, AllowMultiple=false)]
     public sealed partial class MetadataTypeAttribute : System.Attribute
     {
-        public MetadataTypeAttribute(System.Type metadataClassType) { }
+        public MetadataTypeAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type metadataClassType) { }
+        [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
         public System.Type MetadataClassType { get { throw null; } }
     }
     [System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)]
@@ -216,10 +217,11 @@ namespace System.ComponentModel.DataAnnotations
     {
         public RangeAttribute(double minimum, double maximum) { }
         public RangeAttribute(int minimum, int maximum) { }
-        public RangeAttribute(System.Type type, string minimum, string maximum) { }
+        public RangeAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string minimum, string maximum) { }
         public bool ConvertValueInInvariantCulture { get { throw null; } set { } }
         public object Maximum { get { throw null; } }
         public object Minimum { get { throw null; } }
+        [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
         public System.Type OperandType { get { throw null; } }
         public bool ParseLimitsInInvariantCulture { get { throw null; } set { } }
         public override string FormatErrorMessage(string name) { throw null; }
index fdedddf..532f0e6 100644 (file)
@@ -5,5 +5,7 @@
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="System.ComponentModel.Annotations.cs" />
+    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMembersAttribute.cs" />
+    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 6153ad9..acf0ec2 100644 (file)
@@ -3,18 +3,6 @@
   <assembly fullname="System.ComponentModel.Annotations, PublicKeyToken=b03f5f7f11d50a3a">
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2070</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptor.TypeDescriptorCache.CheckAssociatedMetadataType(System.Type,System.Type)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
-      <argument>IL2070</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptor.TypeDescriptorCache.GetAssociatedMetadata(System.Type,System.String)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
       <argument>IL2072</argument>
       <property name="Scope">member</property>
       <property name="Target">M:System.ComponentModel.DataAnnotations.CompareAttribute.IsValid(System.Object,System.ComponentModel.DataAnnotations.ValidationContext)</property>
@@ -56,4 +44,4 @@
       <property name="Target">M:System.ComponentModel.DataAnnotations.ValidationAttribute.SetResourceAccessorByPropertyLookup</property>
     </attribute>
   </assembly>
-</linker>
\ No newline at end of file
+</linker>
index 6291ade..52c3fff 100644 (file)
     <Compile Include="$(CommonPath)System\NotImplemented.cs"
              Link="Common\System\NotImplemented.cs" />
   </ItemGroup>
+  <ItemGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) != '.NETCoreApp'">
+    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMembersAttribute.cs" />
+    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
+    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
+  </ItemGroup>
   <ItemGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETCoreApp'">
     <Reference Include="System.Collections" />
     <Reference Include="System.Collections.Concurrent" />
index fc7b7e4..a408e38 100644 (file)
@@ -4,6 +4,8 @@
 // TODO-NULLABLE: Enable after System.ComponentModel.TypeDescriptionProvider is annotated
 #nullable disable
 
+using System.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel.DataAnnotations
 {
     /// <summary>
@@ -12,6 +14,7 @@ namespace System.ComponentModel.DataAnnotations
     /// </summary>
     public class AssociatedMetadataTypeTypeDescriptionProvider : TypeDescriptionProvider
     {
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         private readonly Type _associatedMetadataType;
 
         /// <summary>
@@ -31,7 +34,9 @@ namespace System.ComponentModel.DataAnnotations
         /// <param name="type">The type for which the metadata provider is created.</param>
         /// <param name="associatedMetadataType">The associated type that contains the metadata.</param>
         /// <exception cref="System.ArgumentNullException">The value of associatedMetadataType is null.</exception>
-        public AssociatedMetadataTypeTypeDescriptionProvider(Type type, Type associatedMetadataType)
+        public AssociatedMetadataTypeTypeDescriptionProvider(
+            Type type,
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type associatedMetadataType)
             : this(type)
         {
             if (associatedMetadataType == null)
@@ -48,7 +53,7 @@ namespace System.ComponentModel.DataAnnotations
         /// <param name="objectType">The type of object to retrieve the type descriptor for.</param>
         /// <param name="instance">An instance of the type.</param>
         /// <returns>The descriptor that provides metadata for the type.</returns>
-        public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+        public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
         {
             ICustomTypeDescriptor baseDescriptor = base.GetTypeDescriptor(objectType, instance);
             return new AssociatedMetadataTypeTypeDescriptor(baseDescriptor, objectType, _associatedMetadataType);
index 2bc82d5..2a6d206 100644 (file)
@@ -6,7 +6,7 @@
 
 using System.Collections.Concurrent;
 using System.Collections.Generic;
-using System.Globalization;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Reflection;
 
@@ -14,11 +14,15 @@ namespace System.ComponentModel.DataAnnotations
 {
     internal class AssociatedMetadataTypeTypeDescriptor : CustomTypeDescriptor
     {
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         private Type AssociatedMetadataType { get; set; }
 
         private bool IsSelfAssociated { get; set; }
 
-        public AssociatedMetadataTypeTypeDescriptor(ICustomTypeDescriptor parent, Type type, Type associatedMetadataType)
+        public AssociatedMetadataTypeTypeDescriptor(
+            ICustomTypeDescriptor parent,
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type,
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type associatedMetadataType)
             : base(parent)
         {
             AssociatedMetadataType = associatedMetadataType ?? TypeDescriptorCache.GetAssociatedMetadataType(type);
@@ -29,6 +33,7 @@ namespace System.ComponentModel.DataAnnotations
             }
         }
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
         {
             return GetPropertiesWithMetadata(base.GetProperties(attributes));
@@ -98,7 +103,9 @@ namespace System.ComponentModel.DataAnnotations
             // Stores whether or not a type and associated metadata type has been checked for validity
             private static readonly ConcurrentDictionary<(Type, Type), bool> s_validatedMetadataTypeCache = new ConcurrentDictionary<(Type, Type), bool>();
 
-            public static void ValidateMetadataType(Type type, Type associatedType)
+            public static void ValidateMetadataType(
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type,
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] Type associatedType)
             {
                 (Type, Type) typeTuple = (type, associatedType);
                 if (!s_validatedMetadataTypeCache.ContainsKey(typeTuple))
@@ -108,6 +115,7 @@ namespace System.ComponentModel.DataAnnotations
                 }
             }
 
+            [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
             public static Type GetAssociatedMetadataType(Type type)
             {
                 Type associatedMetadataType = null;
@@ -126,7 +134,9 @@ namespace System.ComponentModel.DataAnnotations
                 return associatedMetadataType;
             }
 
-            private static void CheckAssociatedMetadataType(Type mainType, Type associatedMetadataType)
+            private static void CheckAssociatedMetadataType(
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type mainType,
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] Type associatedMetadataType)
             {
                 // Only properties from main type
                 HashSet<string> mainTypeMemberNames = new HashSet<string>(mainType.GetProperties().Select(p => p.Name));
@@ -148,7 +158,9 @@ namespace System.ComponentModel.DataAnnotations
                 }
             }
 
-            public static Attribute[] GetAssociatedMetadata(Type type, string memberName)
+            public static Attribute[] GetAssociatedMetadata(
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
+                string memberName)
             {
                 (Type, string) memberTuple = (type, memberName);
                 Attribute[] attributes;
index b4e3b56..43ac37f 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.ComponentModel.DataAnnotations
 {
@@ -11,6 +12,7 @@ namespace System.ComponentModel.DataAnnotations
     [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
     public sealed class MetadataTypeAttribute : Attribute
     {
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         private readonly Type _metadataClassType;
 
         /// <summary>
@@ -19,7 +21,7 @@ namespace System.ComponentModel.DataAnnotations
         /// </summary>
         /// <param name="metadataClassType">The metadata class to reference.</param>
         /// <exception cref="System.ArgumentNullException">metadataClassType is null.</exception>
-        public MetadataTypeAttribute(Type metadataClassType)
+        public MetadataTypeAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type metadataClassType)
         {
             _metadataClassType = metadataClassType;
         }
@@ -27,6 +29,7 @@ namespace System.ComponentModel.DataAnnotations
         /// <summary>
         /// Gets the metadata class that is associated with a data-model partial class.
         /// </summary>
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         public Type MetadataClassType
         {
             get
index a3b2e0b..ce76d24 100644 (file)
@@ -1,6 +1,7 @@
 // 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;
 using System.Globalization;
 
 namespace System.ComponentModel.DataAnnotations
@@ -45,7 +46,10 @@ namespace System.ComponentModel.DataAnnotations
         /// <param name="type">The type of the range parameters. Must implement IComparable.</param>
         /// <param name="minimum">The minimum allowable value.</param>
         /// <param name="maximum">The maximum allowable value.</param>
-        public RangeAttribute(Type type, string minimum, string maximum)
+        public RangeAttribute(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
+            string minimum,
+            string maximum)
             : base(() => SR.RangeAttribute_ValidationError)
         {
             OperandType = type;
@@ -67,6 +71,7 @@ namespace System.ComponentModel.DataAnnotations
         ///     Gets the type of the <see cref="Minimum" /> and <see cref="Maximum" /> values (e.g. Int32, Double, or some custom
         ///     type)
         /// </summary>
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         public Type OperandType { get; }
 
         /// <summary>
@@ -199,7 +204,8 @@ namespace System.ComponentModel.DataAnnotations
                                                             comparableType.FullName));
                     }
 
-                    TypeConverter converter = TypeDescriptor.GetConverter(type);
+                    // use OperandType here so the trimmer doesn't warn about the 'type' field on a compiler generated type
+                    TypeConverter converter = TypeDescriptor.GetConverter(OperandType);
                     IComparable min = (IComparable)(ParseLimitsInInvariantCulture
                         ? converter.ConvertFromInvariantString((string)minimum)
                         : converter.ConvertFromString((string)minimum));
index 35d52c0..c4b69c8 100644 (file)
@@ -192,6 +192,7 @@ namespace System.ComponentModel
     {
         System.ComponentModel.ComponentCollection Components { get; }
         void Add(System.ComponentModel.IComponent? component);
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
         void Add(System.ComponentModel.IComponent? component, string? name);
         void Remove(System.ComponentModel.IComponent? component);
     }
@@ -233,7 +234,7 @@ namespace System.ComponentModel
         System.ComponentModel.IComponent Component { get; }
         System.ComponentModel.IContainer? Container { get; }
         bool DesignMode { get; }
-        string? Name { get; set; }
+        string? Name { get; [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")] set; }
     }
     public partial interface ISupportInitialize
     {
index d9a6305..07b1716 100644 (file)
@@ -1,7 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System.Runtime.InteropServices;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.ComponentModel
 {
@@ -27,6 +27,7 @@ namespace System.ComponentModel
         /// <see cref='System.ComponentModel.IContainer'/> at the end of the list,
         /// and assigns a name to the component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
         void Add(IComponent? component, string? name);
 
         /// <summary>
index e51287f..911d8eb 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     /// <summary>
@@ -37,6 +39,6 @@ namespace System.ComponentModel
         /// When implemented by a class, gets or sets the name of the component
         /// associated with the <see cref='System.ComponentModel.ISite'/>.
         /// </summary>
-        string? Name { get; set; }
+        string? Name { get; [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")] set; }
     }
 }
index d741db0..29397fc 100644 (file)
@@ -38,7 +38,7 @@ namespace System.ComponentModel
         public AmbientValueAttribute(object value) { }
         public AmbientValueAttribute(float value) { }
         public AmbientValueAttribute(string value) { }
-        public AmbientValueAttribute(System.Type type, string value) { }
+        public AmbientValueAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string value) { }
         public object Value { get { throw null; } }
         public override bool Equals(object obj) { throw null; }
         public override int GetHashCode() { throw null; }
@@ -47,6 +47,7 @@ namespace System.ComponentModel
     {
         public ArrayConverter() { }
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -58,15 +59,17 @@ namespace System.ComponentModel
         protected virtual System.Attribute[] Attributes { get { throw null; } }
         public int Count { get { throw null; } }
         public virtual System.Attribute this[int index] { get { throw null; } }
-        public virtual System.Attribute this[System.Type attributeType] { get { throw null; } }
+        public virtual System.Attribute this[[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type attributeType] { get { throw null; } }
         int System.Collections.ICollection.Count { get { throw null; } }
         bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
         object System.Collections.ICollection.SyncRoot { get { throw null; } }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public bool Contains(System.Attribute attribute) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public bool Contains(System.Attribute[] attributes) { throw null; }
         public void CopyTo(System.Array array, int index) { }
         public static System.ComponentModel.AttributeCollection FromExisting(System.ComponentModel.AttributeCollection existing, params System.Attribute[] newAttributes) { throw null; }
-        protected System.Attribute GetDefaultAttribute(System.Type attributeType) { throw null; }
+        protected System.Attribute GetDefaultAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type attributeType) { throw null; }
         public System.Collections.IEnumerator GetEnumerator() { throw null; }
         public bool Matches(System.Attribute attribute) { throw null; }
         public bool Matches(System.Attribute[] attributes) { throw null; }
@@ -116,7 +119,7 @@ namespace System.ComponentModel
         OneWay = 0,
         TwoWay = 1,
     }
-    public partial class BindingList<T> : System.Collections.ObjectModel.Collection<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.ICancelAddNew, System.ComponentModel.IRaiseItemChangedEvents
+    public partial class BindingList<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] T> : System.Collections.ObjectModel.Collection<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.ICancelAddNew, System.ComponentModel.IRaiseItemChangedEvents
     {
         public BindingList() { }
         public BindingList(System.Collections.Generic.IList<T> list) { }
@@ -202,6 +205,7 @@ namespace System.ComponentModel
     {
         public CollectionConverter() { }
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -220,6 +224,7 @@ namespace System.ComponentModel
     public partial class ComponentConverter : System.ComponentModel.ReferenceConverter
     {
         public ComponentConverter(System.Type type) : base (default(System.Type)) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -233,7 +238,9 @@ namespace System.ComponentModel
     {
         public ComponentResourceManager() { }
         public ComponentResourceManager(System.Type t) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public void ApplyResources(object value, string objectName) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public virtual void ApplyResources(object value, string objectName, System.Globalization.CultureInfo culture) { }
     }
     public partial class Container : System.ComponentModel.IContainer, System.IDisposable
@@ -241,6 +248,7 @@ namespace System.ComponentModel
         public Container() { }
         public virtual System.ComponentModel.ComponentCollection Components { get { throw null; } }
         public virtual void Add(System.ComponentModel.IComponent component) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
         public virtual void Add(System.ComponentModel.IComponent component, string name) { }
         protected virtual System.ComponentModel.ISite CreateSite(System.ComponentModel.IComponent component, string name) { throw null; }
         public void Dispose() { }
@@ -249,6 +257,7 @@ namespace System.ComponentModel
         protected virtual object GetService(System.Type service) { throw null; }
         public virtual void Remove(System.ComponentModel.IComponent component) { }
         protected void RemoveWithoutUnsiting(System.ComponentModel.IComponent component) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered.")]
         protected virtual void ValidateName(System.ComponentModel.IComponent component, string name) { }
     }
     public abstract partial class ContainerFilterService
@@ -280,8 +289,10 @@ namespace System.ComponentModel
         public virtual System.ComponentModel.PropertyDescriptor GetDefaultProperty() { throw null; }
         public virtual object GetEditor(System.Type editorBaseType) { throw null; }
         public virtual System.ComponentModel.EventDescriptorCollection GetEvents() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("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; }
         public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) { throw null; }
         public virtual object GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; }
     }
@@ -400,8 +411,9 @@ namespace System.ComponentModel
     }
     public partial class EnumConverter : System.ComponentModel.TypeConverter
     {
-        public EnumConverter(System.Type type) { }
+        public EnumConverter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type type) { }
         protected virtual System.Collections.IComparer Comparer { get { throw null; } }
+        [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
         protected System.Type EnumType { get { throw null; } }
         protected System.ComponentModel.TypeConverter.StandardValuesCollection Values { get { throw null; } set { } }
         public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; }
@@ -415,9 +427,9 @@ namespace System.ComponentModel
     }
     public abstract partial class EventDescriptor : System.ComponentModel.MemberDescriptor
     {
-        protected EventDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(System.ComponentModel.MemberDescriptor)) { }
-        protected EventDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(System.ComponentModel.MemberDescriptor)) { }
-        protected EventDescriptor(string name, System.Attribute[] attrs) : base (default(System.ComponentModel.MemberDescriptor)) { }
+        protected EventDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(string)) { }
+        protected EventDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(string)) { }
+        protected EventDescriptor(string name, System.Attribute[] attrs) : base (default(string)) { }
         public abstract System.Type ComponentType { get; }
         public abstract System.Type EventType { get; }
         public abstract bool IsMulticast { get; }
@@ -466,6 +478,7 @@ namespace System.ComponentModel
     public partial class ExpandableObjectConverter : System.ComponentModel.TypeConverter
     {
         public ExpandableObjectConverter() { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -554,8 +567,10 @@ namespace System.ComponentModel
         System.ComponentModel.PropertyDescriptor GetDefaultProperty();
         object GetEditor(System.Type editorBaseType);
         System.ComponentModel.EventDescriptorCollection GetEvents();
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes);
         System.ComponentModel.PropertyDescriptorCollection GetProperties();
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[] attributes);
         object GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd);
     }
@@ -965,6 +980,7 @@ namespace System.ComponentModel
     {
         public MultilineStringConverter() { }
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -989,6 +1005,7 @@ namespace System.ComponentModel
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
         public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; }
         public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
         public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
@@ -1011,11 +1028,11 @@ namespace System.ComponentModel
     }
     public abstract partial class PropertyDescriptor : System.ComponentModel.MemberDescriptor
     {
-        protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(System.ComponentModel.MemberDescriptor)) { }
-        protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(System.ComponentModel.MemberDescriptor)) { }
-        protected PropertyDescriptor(string name, System.Attribute[] attrs) : base (default(System.ComponentModel.MemberDescriptor)) { }
+        protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(string)) { }
+        protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(string)) { }
+        protected PropertyDescriptor(string name, System.Attribute[] attrs) : base (default(string)) { }
         public abstract System.Type ComponentType { get; }
-        public virtual System.ComponentModel.TypeConverter Converter { get { throw null; } }
+        public virtual System.ComponentModel.TypeConverter Converter { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")] get { throw null; } }
         public virtual bool IsLocalizable { get { throw null; } }
         public abstract bool IsReadOnly { get; }
         public abstract System.Type PropertyType { get; }
@@ -1026,10 +1043,15 @@ namespace System.ComponentModel
         protected object CreateInstance(System.Type type) { throw null; }
         public override bool Equals(object obj) { throw null; }
         protected override void FillAttributes(System.Collections.IList attributeList) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")]
         public System.ComponentModel.PropertyDescriptorCollection GetChildProperties() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(System.Attribute[] filter) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered. The Type of instance cannot be statically discovered.")]
         public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The PropertyDescriptor's PropertyType cannot be statically discovered. The Type of instance cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public virtual System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance, System.Attribute[] filter) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")]
         public virtual object GetEditor(System.Type editorBaseType) { throw null; }
         public override int GetHashCode() { throw null; }
         protected override object GetInvocationTarget(System.Type type, object instance) { throw null; }
@@ -1269,8 +1291,11 @@ namespace System.ComponentModel
         protected System.Exception GetConvertToException(object value, System.Type destinationType) { throw null; }
         public bool GetCreateInstanceSupported() { throw null; }
         public virtual bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public System.ComponentModel.PropertyDescriptorCollection GetProperties(object value) { throw null; }
         public bool GetPropertiesSupported() { throw null; }
         public virtual bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
@@ -1285,8 +1310,8 @@ namespace System.ComponentModel
         protected System.ComponentModel.PropertyDescriptorCollection SortProperties(System.ComponentModel.PropertyDescriptorCollection props, string[] names) { throw null; }
         protected abstract partial class SimplePropertyDescriptor : System.ComponentModel.PropertyDescriptor
         {
-            protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType) : base (default(System.ComponentModel.MemberDescriptor)) { }
-            protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType, System.Attribute[] attributes) : base (default(System.ComponentModel.MemberDescriptor)) { }
+            protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType) : base (default(string), default(System.Attribute[])) { }
+            protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType, System.Attribute[] attributes) : base (default(string), default(System.Attribute[])) { }
             public override System.Type ComponentType { get { throw null; } }
             public override bool IsReadOnly { get { throw null; } }
             public override System.Type PropertyType { get { throw null; } }
@@ -1311,16 +1336,22 @@ namespace System.ComponentModel
         protected TypeDescriptionProvider(System.ComponentModel.TypeDescriptionProvider parent) { }
         public virtual object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; }
         public virtual System.Collections.IDictionary GetCache(object instance) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public virtual System.ComponentModel.ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance) { throw null; }
         protected internal virtual System.ComponentModel.IExtenderProvider[] GetExtenderProviders(object instance) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public virtual string GetFullComponentName(object component) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("GetReflectionType is not trim compatible because the Type of object cannot be statically discovered.")]
         public System.Type GetReflectionType(object instance) { throw null; }
-        public System.Type GetReflectionType(System.Type objectType) { throw null; }
-        public virtual System.Type GetReflectionType(System.Type objectType, object instance) { throw null; }
+        [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+        public System.Type GetReflectionType([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type objectType) { throw null; }
+        [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+        public virtual System.Type GetReflectionType([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type objectType, object instance) { throw null; }
         public virtual System.Type GetRuntimeType(System.Type reflectionType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(object instance) { throw null; }
-        public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType) { throw null; }
-        public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType, object instance) { throw null; }
+        public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type objectType) { throw null; }
+        public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type objectType, object instance) { throw null; }
         public virtual bool IsSupportedType(System.Type type) { throw null; }
     }
     public sealed partial class TypeDescriptor
@@ -1348,65 +1379,93 @@ namespace System.ComponentModel
         public static void AddProviderTransparent(System.ComponentModel.TypeDescriptionProvider provider, System.Type type) { }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
         public static void CreateAssociation(object primary, object secondary) { }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.Design.IDesigner CreateDesigner(System.ComponentModel.IComponent component, System.Type designerBaseType) { throw null; }
         public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor, params System.Attribute[] attributes) { throw null; }
         public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; }
         public static object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; }
-        public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, System.ComponentModel.PropertyDescriptor oldPropertyDescriptor, params System.Attribute[] attributes) { throw null; }
-        public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; }
+        public static System.ComponentModel.PropertyDescriptor CreateProperty([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType, System.ComponentModel.PropertyDescriptor oldPropertyDescriptor, params System.Attribute[] attributes) { throw null; }
+        public static System.ComponentModel.PropertyDescriptor CreateProperty([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
         public static object GetAssociation(System.Type type, object primary) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.AttributeCollection GetAttributes(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.AttributeCollection GetAttributes(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.AttributeCollection GetAttributes(System.Type componentType) { throw null; }
+        public static System.ComponentModel.AttributeCollection GetAttributes([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetClassName(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetClassName(object component, bool noCustomTypeDesc) { throw null; }
-        public static string GetClassName(System.Type componentType) { throw null; }
+        public static string GetClassName([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetComponentName(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetComponentName(object component, bool noCustomTypeDesc) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.TypeConverter GetConverter(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.TypeConverter GetConverter(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.TypeConverter GetConverter(System.Type type) { throw null; }
+        public static System.ComponentModel.TypeConverter GetConverter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.EventDescriptor GetDefaultEvent(System.Type componentType) { throw null; }
+        public static System.ComponentModel.EventDescriptor GetDefaultEvent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(System.Type componentType) { throw null; }
+        public static System.ComponentModel.PropertyDescriptor GetDefaultProperty([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static object GetEditor(object component, System.Type editorBaseType) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static object GetEditor(object component, System.Type editorBaseType, bool noCustomTypeDesc) { throw null; }
-        public static object GetEditor(System.Type type, System.Type editorBaseType) { throw null; }
+        public static object GetEditor([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, System.Type editorBaseType) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.EventDescriptorCollection GetEvents(object component) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType) { throw null; }
-        public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType, System.Attribute[] attributes) { throw null; }
+        public static System.ComponentModel.EventDescriptorCollection GetEvents([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(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.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType, System.Attribute[] attributes) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetFullComponentName(object component) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc) { throw null; }
-        public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType) { throw null; }
-        public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType, System.Attribute[] attributes) { throw null; }
+        public static System.ComponentModel.PropertyDescriptorCollection GetProperties([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(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.PropertyDescriptorCollection GetProperties([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type componentType, System.Attribute[] attributes) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
         public static System.ComponentModel.TypeDescriptionProvider GetProvider(object instance) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
         public static System.ComponentModel.TypeDescriptionProvider GetProvider(System.Type type) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("GetReflectionType is not trim compatible because the Type of object cannot be statically discovered.")]
         public static System.Type GetReflectionType(object instance) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
-        public static System.Type GetReflectionType(System.Type type) { throw null; }
+        [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+        public static System.Type GetReflectionType([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type type) { throw null; }
         public static void Refresh(object component) { }
         public static void Refresh(System.Reflection.Assembly assembly) { }
         public static void Refresh(System.Reflection.Module module) { }
@@ -1553,7 +1612,9 @@ namespace System.ComponentModel.Design
         protected System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection CreateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection parent, string name, object value) { throw null; }
         protected virtual void PopulateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options) { }
         protected virtual bool ShowDialog(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options, object optionObject) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         object System.ComponentModel.Design.IDesignerOptionService.GetOptionValue(string pageName, string valueName) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         void System.ComponentModel.Design.IDesignerOptionService.SetOptionValue(string pageName, string valueName, object value) { }
         [System.ComponentModel.EditorAttribute("", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
         public sealed partial class DesignerOptionCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
@@ -1564,7 +1625,7 @@ namespace System.ComponentModel.Design
             public System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection this[string name] { get { throw null; } }
             public string Name { get { throw null; } }
             public System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection Parent { get { throw null; } }
-            public System.ComponentModel.PropertyDescriptorCollection Properties { get { throw null; } }
+            public System.ComponentModel.PropertyDescriptorCollection Properties { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of DesignerOptionCollection's value cannot be statically discovered.")] get { throw null; } }
             bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
             object System.Collections.ICollection.SyncRoot { get { throw null; } }
             bool System.Collections.IList.IsFixedSize { get { throw null; } }
@@ -1747,7 +1808,9 @@ namespace System.ComponentModel.Design
     }
     public partial interface IDesignerOptionService
     {
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         object GetOptionValue(string pageName, string valueName);
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         void SetOptionValue(string pageName, string valueName, object value);
     }
     public partial interface IDictionaryService
@@ -2175,6 +2238,7 @@ namespace System.Drawing
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
         public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; }
         public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -2187,6 +2251,7 @@ namespace System.Drawing
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
         public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; }
         public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -2199,6 +2264,7 @@ namespace System.Drawing
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
         public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; }
         public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
@@ -2211,6 +2277,7 @@ namespace System.Drawing
         public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
         public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; }
         public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; }
         public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
     }
index d0db983..558d9f1 100644 (file)
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2070</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetEvents(System.Type)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
-      <argument>IL2070</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetProperties(System.Type)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
       <argument>IL2072</argument>
       <property name="Scope">member</property>
       <property name="Target">M:System.ComponentModel.LicenseManager.ValidateInternalRecursive(System.ComponentModel.LicenseContext,System.Type,System.Object,System.Boolean,System.ComponentModel.License@,System.String@)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2072</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.TypeDescriptor.CreateDesigner(System.ComponentModel.IComponent,System.Type)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.AttributeCollection.GetDefaultAttribute(System.Type)</property>
+      <property name="Target">M:System.ComponentModel.NullableConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ComponentResourceManager.ApplyResources(System.Object,System.String,System.Globalization.CultureInfo)</property>
+      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillEventInfoAttribute(System.Reflection.EventInfo,System.Collections.IList)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.EnumConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)</property>
+      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillMethods</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.EnumConverter.GetStandardValues(System.ComponentModel.ITypeDescriptorContext)</property>
+      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillSingleMethodAttribute(System.Reflection.MethodInfo,System.Collections.IList)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.NullableConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)</property>
+      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.FillAttributes(System.Collections.IList)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillEventInfoAttribute(System.Reflection.EventInfo,System.Collections.IList)</property>
+      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.get_SetMethodValue</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
       <argument>IL2075</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillMethods</property>
+      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.GetIntrinsicTypeEditor(System.Collections.Hashtable,System.Type)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2075</argument>
+      <argument>IL2080</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillSingleMethodAttribute(System.Reflection.MethodInfo,System.Collections.IList)</property>
+      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillMethods</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2075</argument>
+      <argument>IL2080</argument>
       <property name="Scope">member</property>
       <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.FillAttributes(System.Collections.IList)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2075</argument>
+      <argument>IL2080</argument>
       <property name="Scope">member</property>
       <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.get_SetMethodValue</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2075</argument>
-      <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.GetIntrinsicTypeEditor(System.Collections.Hashtable,System.Type)</property>
-    </attribute>
-    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
-      <argument>ILLink</argument>
-      <argument>IL2075</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetExtendedProperties(System.ComponentModel.IExtenderProvider)</property>
+      <property name="Target">M:System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Deserialize(System.IO.Stream,System.String,System.ComponentModel.Design.RuntimeLicenseContext)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2080</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectEventDescriptor.FillMethods</property>
+      <property name="Target">M:System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Serialize(System.IO.Stream,System.String,System.ComponentModel.Design.DesigntimeLicenseContext)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2080</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.FillAttributes(System.Collections.IList)</property>
+      <property name="Target">M:System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System#ComponentModel#ICustomTypeDescriptor#GetConverter</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2080</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.get_GetMethodValue</property>
+      <property name="Target">M:System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System#ComponentModel#ICustomTypeDescriptor#GetDefaultEvent</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2080</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.get_SetMethodValue</property>
+      <property name="Target">M:System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System#ComponentModel#ICustomTypeDescriptor#GetDefaultProperty</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2087</argument>
+      <argument>IL2026</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.BindingList`1.AddNewCore</property>
+      <property name="Target">M:System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System#ComponentModel#ICustomTypeDescriptor#GetEditor(System.Type)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2090</argument>
+      <argument>IL2062</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.BindingList`1.get_ItemTypeHasDefaultConstructor</property>
+      <property name="Target">M:System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetAttributes</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2026</argument>
+      <argument>IL2072</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Deserialize(System.IO.Stream,System.String,System.ComponentModel.Design.RuntimeLicenseContext)</property>
+      <property name="Target">M:System.ComponentModel.NullableConverter.#ctor(System.Type)</property>
     </attribute>
     <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
       <argument>ILLink</argument>
-      <argument>IL2026</argument>
+      <argument>IL2072</argument>
       <property name="Scope">member</property>
-      <property name="Target">M:System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Serialize(System.IO.Stream,System.String,System.ComponentModel.Design.DesigntimeLicenseContext)</property>
+      <property name="Target">M:System.ComponentModel.ReflectPropertyDescriptor.FillAttributes(System.Collections.IList)</property>
     </attribute>
   </assembly>
 </linker>
index 9b98716..d59b6b6 100644 (file)
@@ -5,6 +5,7 @@ using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Xml.Linq;
 
@@ -16,7 +17,7 @@ namespace MS.Internal.Xml.Linq.ComponentModel
         {
         }
 
-        public override ICustomTypeDescriptor GetTypeDescriptor(Type type, object instance)
+        public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance)
         {
             return new XTypeDescriptor<T>(base.GetTypeDescriptor(type, instance));
         }
@@ -28,11 +29,14 @@ namespace MS.Internal.Xml.Linq.ComponentModel
         {
         }
 
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
+            Justification = "No attributes are supplied.")]
         public override PropertyDescriptorCollection GetProperties()
         {
             return GetProperties(null);
         }
 
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
         {
             PropertyDescriptorCollection properties = new PropertyDescriptorCollection(null);
index d592d19..76e19ce 100644 (file)
@@ -17,7 +17,7 @@ namespace System.ComponentModel
         /// specified value to the specified type, and using the U.S. English culture as the
         /// translation context.
         /// </summary>
-        public AmbientValueAttribute(Type type, string value)
+        public AmbientValueAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string value)
         {
             // The try/catch here is because attributes should never throw exceptions. We would fail to
             // load an otherwise normal class.
index 0405be4..c7a0b66 100644 (file)
@@ -1,6 +1,7 @@
 // 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;
 using System.Globalization;
 
 namespace System.ComponentModel
@@ -27,6 +28,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of properties for the type of array specified by the value parameter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             if (value == null)
index 0bfda00..31fac2d 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Reflection;
 using System.Collections;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.ComponentModel
 {
@@ -11,6 +12,8 @@ namespace System.ComponentModel
     /// </summary>
     public class AttributeCollection : ICollection, IEnumerable
     {
+        internal const string FilterRequiresUnreferencedCodeMessage = "The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.";
+
         /// <summary>
         /// An empty AttributeCollection that can used instead of creating a new one.
         /// </summary>
@@ -132,7 +135,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the attribute with the specified type.
         /// </summary>
-        public virtual Attribute this[Type attributeType]
+        public virtual Attribute this[[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)] Type attributeType]
         {
             get
             {
@@ -215,6 +218,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Determines if this collection of attributes has the specified attribute.
         /// </summary>
+        [RequiresUnreferencedCode(FilterRequiresUnreferencedCodeMessage)]
         public bool Contains(Attribute attribute)
         {
             if (attribute == null)
@@ -230,6 +234,7 @@ namespace System.ComponentModel
         /// Determines if this attribute collection contains the all
         /// the specified attributes in the attribute array.
         /// </summary>
+        [RequiresUnreferencedCode(FilterRequiresUnreferencedCodeMessage)]
         public bool Contains(Attribute[] attributes)
         {
             if (attributes == null)
@@ -252,7 +257,7 @@ namespace System.ComponentModel
         /// Returns the default value for an attribute. This uses the following heuristic:
         /// 1. It looks for a public static field named "Default".
         /// </summary>
-        protected Attribute GetDefaultAttribute(Type attributeType)
+        protected Attribute GetDefaultAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)] Type attributeType)
         {
             if (attributeType == null)
             {
index de3d0e2..6f69253 100644 (file)
@@ -1,18 +1,19 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System.Reflection;
-using System.Collections.ObjectModel;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
 using System.Runtime.CompilerServices;
 
 namespace System.ComponentModel
 {
     [Serializable]
     [TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
-    public class BindingList<T> : Collection<T>, IBindingList, ICancelAddNew, IRaiseItemChangedEvents
+    public class BindingList<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> :
+        Collection<T>, IBindingList, ICancelAddNew, IRaiseItemChangedEvents
     {
         private int addNewPos = -1; // Do not rename (binary serialization)
         private bool raiseListChangedEvents = true; // Do not rename (binary serialization)
index 67a92b5..d78d014 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Collections;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 
 namespace System.ComponentModel
@@ -29,6 +30,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for the type of array specified by the value
         /// parameter using the specified context and attributes.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             return new PropertyDescriptorCollection(null);
index 097cc3f..23f8591 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     /// <summary>
@@ -20,6 +22,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for the type of component
         /// specified by the value parameter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             return TypeDescriptor.GetProperties(value, attributes);
index 034be51..88f6bcf 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Collections;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Reflection;
 using System.Resources;
@@ -51,6 +52,7 @@ namespace System.ComponentModel
         /// to the corresponding property on the object. If there is no matching
         /// property the resource will be ignored.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public void ApplyResources(object value, string objectName) => ApplyResources(value, objectName, null);
 
         /// <summary>
@@ -60,6 +62,7 @@ namespace System.ComponentModel
         /// to the corresponding property on the object. If there is no matching
         /// property the resource will be ignored.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public virtual void ApplyResources(object value, string objectName, CultureInfo culture)
         {
             if (value == null)
index cc0a801..d966c03 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     /// <summary>
@@ -22,6 +24,7 @@ namespace System.ComponentModel
         /// Adds the specified component to the <see cref='System.ComponentModel.Container'/>
         /// The component is unnamed.
         /// </summary>
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "No name is provided.")]
         public virtual void Add(IComponent component) => Add(component, null);
 
         // Adds a component to the container.
@@ -29,6 +32,7 @@ namespace System.ComponentModel
         /// Adds the specified component to the <see cref='System.ComponentModel.Container'/> and assigns
         /// a name to it.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
         public virtual void Add(IComponent component, string name)
         {
             lock (_syncObj)
@@ -212,6 +216,7 @@ namespace System.ComponentModel
         /// verifies that name is either null or unique compared to the names of other
         /// components in the container.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered.")]
         protected virtual void ValidateName(IComponent component, string name)
         {
             if (component == null)
@@ -274,6 +279,7 @@ namespace System.ComponentModel
             public string Name
             {
                 get => _name;
+                [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
                 set
                 {
                     if (value == null || _name == null || !value.Equals(_name))
index 79d0e80..fd6e5f7 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     public abstract class CustomTypeDescriptor : ICustomTypeDescriptor
@@ -119,6 +121,7 @@ namespace System.ComponentModel
         /// returned. If no parent is provided,this will return an empty
         /// event collection.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public virtual EventDescriptorCollection GetEvents(Attribute[] attributes)
         {
             if (_parent != null)
@@ -153,6 +156,7 @@ namespace System.ComponentModel
         /// If no parent is provided,this will return an empty
         /// property collection.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public virtual PropertyDescriptorCollection GetProperties(Attribute[] attributes)
         {
             if (_parent != null)
index 6c3f604..5e05f31 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Collections;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.ComponentModel
 {
@@ -58,6 +59,7 @@ namespace System.ComponentModel
         /// If not overridden, the default implementation of this method will call
         /// GetTypeDescriptor.GetComponentName.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public override string GetFullComponentName(object component) => Provider.GetFullComponentName(component);
 
         /// <summary>
@@ -74,6 +76,7 @@ namespace System.ComponentModel
         /// model only supports extended properties this API can be used for extended
         /// attributes and events as well, if the type description provider supports it.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
         {
             return Provider.GetExtendedTypeDescriptor(instance);
@@ -89,7 +92,10 @@ namespace System.ComponentModel
         /// If no custom type descriptor can be located for an object, GetReflection
         /// is called to perform normal reflection against the object.
         /// </summary>
-        public override Type GetReflectionType(Type objectType, object instance)
+        [return: DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)]
+        public override Type GetReflectionType(
+            [DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)] Type objectType,
+            object instance)
         {
             return Provider.GetReflectionType(objectType, instance);
         }
@@ -104,7 +110,7 @@ namespace System.ComponentModel
         /// interested in providing type information for the object it should
         /// return null.
         /// </summary>
-        public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+        public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
         {
             return Provider.GetTypeDescriptor(objectType, instance);
         }
index 3c19b44..490dded 100644 (file)
@@ -56,6 +56,7 @@ namespace System.ComponentModel.Design
         /// Retrieves the property descriptor for the given page / value name. Returns
         /// null if the property couldn't be found.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of DesignerOptionCollection's value cannot be statically discovered.")]
         private PropertyDescriptor GetOptionProperty(string pageName, string valueName)
         {
             if (pageName == null)
@@ -99,6 +100,7 @@ namespace System.ComponentModel.Design
         /// <summary>
         /// Gets the value of an option defined in this package.
         /// </summary>
+        [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         object IDesignerOptionService.GetOptionValue(string pageName, string valueName)
         {
             PropertyDescriptor optionProp = GetOptionProperty(pageName, valueName);
@@ -108,6 +110,7 @@ namespace System.ComponentModel.Design
         /// <summary>
         /// Sets the value of an option defined in this package.
         /// </summary>
+        [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         void IDesignerOptionService.SetOptionValue(string pageName, string valueName, object value)
         {
             PropertyDescriptor optionProp = GetOptionProperty(pageName, valueName);
@@ -185,6 +188,7 @@ namespace System.ComponentModel.Design
             /// </summary>
             public PropertyDescriptorCollection Properties
             {
+                [RequiresUnreferencedCode("The Type of DesignerOptionCollection's value cannot be statically discovered.")]
                 get
                 {
                     if (_properties == null)
@@ -450,6 +454,7 @@ namespace System.ComponentModel.Design
         {
             public override bool GetPropertiesSupported(ITypeDescriptorContext cxt) => true;
 
+            [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
             public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext cxt, object value, Attribute[] attributes)
             {
                 PropertyDescriptorCollection props = new PropertyDescriptorCollection(null);
index 7b4326e..49909f5 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel.Design
 {
     /// <summary>
@@ -11,11 +13,13 @@ namespace System.ComponentModel.Design
         /// <summary>
         /// Gets the value of an option defined in this package.
         /// </summary>
+        [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         object GetOptionValue(string pageName, string valueName);
 
         /// <summary>
         /// Sets the value of an option defined in this package.
         /// </summary>
+        [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
         void SetOptionValue(string pageName, string valueName, object value);
     }
 }
index 52f6915..463b159 100644 (file)
@@ -122,22 +122,29 @@ namespace System.ComponentModel.Design.Serialization
         {
             if (!relationship.IsEmpty && !SupportsRelationship(source, relationship))
             {
-                string sourceName = TypeDescriptor.GetComponentName(source.Owner);
-                string relName = TypeDescriptor.GetComponentName(relationship.Owner);
-                if (sourceName == null)
-                {
-                    sourceName = source.Owner.ToString();
-                }
-                if (relName == null)
-                {
-                    relName = relationship.Owner.ToString();
-                }
-                throw new ArgumentException(SR.Format(SR.MemberRelationshipService_RelationshipNotSupported, sourceName, source.Member.Name, relName, relationship.Member.Name));
+                ThrowRelationshipNotSupported(source, relationship);
             }
 
             _relationships[new RelationshipEntry(source)] = new RelationshipEntry(relationship);
         }
 
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
+            Justification = "GetComponentName is only used to create a nice exception message, and has a fallback when null is returned.")]
+        private static void ThrowRelationshipNotSupported(MemberRelationship source, MemberRelationship relationship)
+        {
+            string sourceName = TypeDescriptor.GetComponentName(source.Owner);
+            string relName = TypeDescriptor.GetComponentName(relationship.Owner);
+            if (sourceName == null)
+            {
+                sourceName = source.Owner.ToString();
+            }
+            if (relName == null)
+            {
+                relName = relationship.Owner.ToString();
+            }
+            throw new ArgumentException(SR.Format(SR.MemberRelationshipService_RelationshipNotSupported, sourceName, source.Member.Name, relName, relationship.Member.Name));
+        }
+
         /// <summary>
         /// Returns true if the provided relationship is supported.
         /// </summary>
index 38c7932..8820290 100644 (file)
@@ -4,6 +4,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel.Design.Serialization;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Reflection;
 
@@ -19,11 +20,12 @@ namespace System.ComponentModel
         /// Initializes a new instance of the <see cref='System.ComponentModel.EnumConverter'/> class for the given
         /// type.
         /// </summary>
-        public EnumConverter(Type type)
+        public EnumConverter([DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)] Type type)
         {
             EnumType = type;
         }
 
+        [DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)]
         protected Type EnumType { get; }
 
         protected StandardValuesCollection Values { get; set; }
index 294a894..53cf149 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     /// <summary>
@@ -20,6 +22,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for the type of object
         /// specified by the value parameter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             return TypeDescriptor.GetProperties(value, attributes);
index b9849a3..f194821 100644 (file)
@@ -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.Diagnostics.CodeAnalysis;
+
 namespace System.ComponentModel
 {
     /// <summary>
@@ -53,6 +55,7 @@ namespace System.ComponentModel
         /// Gets the events for this instance of a component using the attribute array as a
         /// filter.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         EventDescriptorCollection GetEvents(Attribute[] attributes);
 
         /// <summary>
@@ -63,6 +66,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the properties for this instance of a component using the attribute array as a filter.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         PropertyDescriptorCollection GetProperties(Attribute[] attributes);
 
         /// <summary>
index 735b479..65db302 100644 (file)
@@ -1,6 +1,7 @@
 // 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;
 using System.Globalization;
 
 namespace System.ComponentModel
@@ -32,6 +33,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for the type of array specified by the value
         /// parameter using the specified context and attributes.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             return null;
index 21e3b57..0261be6 100644 (file)
@@ -1,6 +1,7 @@
 // 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;
 using System.Globalization;
 
 namespace System.ComponentModel
@@ -160,6 +161,7 @@ namespace System.ComponentModel
             public string Name
             {
                 get => _name;
+                [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")]
                 set
                 {
                     if (value == null || _name == null || !value.Equals(_name))
index e5eb919..336015c 100644 (file)
@@ -4,6 +4,7 @@
 using System.Collections;
 using System.ComponentModel.Design.Serialization;
 using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Reflection;
 
@@ -158,6 +159,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for the type of array specified by the value
         /// parameter using the specified context and attributes.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             if (UnderlyingTypeConverter != null)
index 3f8d704..c9381b8 100644 (file)
@@ -57,6 +57,7 @@ namespace System.ComponentModel
         /// </summary>
         public virtual TypeConverter Converter
         {
+            [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")]
             get
             {
                 // Always grab the attribute collection first here, because if the metadata version
@@ -212,15 +213,19 @@ namespace System.ComponentModel
             base.FillAttributes(attributeList);
         }
 
+        [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")]
         public PropertyDescriptorCollection GetChildProperties() => GetChildProperties(null, null);
 
+        [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public PropertyDescriptorCollection GetChildProperties(Attribute[] filter) => GetChildProperties(null, filter);
 
+        [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered. The Type of instance cannot be statically discovered.")]
         public PropertyDescriptorCollection GetChildProperties(object instance) => GetChildProperties(instance, null);
 
         /// <summary>
         /// Retrieves the properties
         /// </summary>
+        [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered. The Type of instance cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public virtual PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter)
         {
             if (instance == null)
@@ -233,10 +238,10 @@ namespace System.ComponentModel
             }
         }
 
-
         /// <summary>
         /// Gets an editor of the specified type.
         /// </summary>
+        [RequiresUnreferencedCode("The PropertyDescriptor's PropertyType cannot be statically discovered.")]
         public virtual object GetEditor(Type editorBaseType)
         {
             object editor = null;
index 975804a..4951756 100644 (file)
@@ -4,6 +4,7 @@
 using System.Collections;
 using System.ComponentModel.Design;
 using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Reflection;
 
@@ -59,6 +60,7 @@ namespace System.ComponentModel
         private static readonly int s_bitSetOnDemand = InterlockedBitVector32.CreateMask(s_bitAmbientValueQueried);
 
         private InterlockedBitVector32 _state;             // Contains the state bits for this proeprty descriptor.
+        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
         private readonly Type _componentClass;             // used to determine if we should all on us or on the designer
         private readonly Type _type;                       // the data type of the property
         private object _defaultValue;               // the default value of the property (or noValue)
@@ -75,7 +77,11 @@ namespace System.ComponentModel
         /// <summary>
         /// The main constructor for ReflectPropertyDescriptors.
         /// </summary>
-        public ReflectPropertyDescriptor(Type componentClass, string name, Type type, Attribute[] attributes)
+        public ReflectPropertyDescriptor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentClass,
+            string name,
+            Type type,
+            Attribute[] attributes)
             : base(name, attributes)
         {
             Debug.WriteLine($"Creating ReflectPropertyDescriptor for {componentClass?.FullName}.{name}");
@@ -106,7 +112,15 @@ namespace System.ComponentModel
         /// <summary>
         /// A constructor for ReflectPropertyDescriptors that have no attributes.
         /// </summary>
-        public ReflectPropertyDescriptor(Type componentClass, string name, Type type, PropertyInfo propInfo, MethodInfo getMethod, MethodInfo setMethod, Attribute[] attrs) : this(componentClass, name, type, attrs)
+        public ReflectPropertyDescriptor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentClass,
+            string name,
+            Type type,
+            PropertyInfo propInfo,
+            MethodInfo getMethod,
+            MethodInfo setMethod,
+            Attribute[] attrs)
+            : this(componentClass, name, type, attrs)
         {
             _propInfo = propInfo;
             _getMethod = getMethod;
@@ -120,7 +134,15 @@ namespace System.ComponentModel
         /// <summary>
         /// A constructor for ReflectPropertyDescriptors that creates an extender property.
         /// </summary>
-        public ReflectPropertyDescriptor(Type componentClass, string name, Type type, Type receiverType, MethodInfo getMethod, MethodInfo setMethod, Attribute[] attrs) : this(componentClass, name, type, attrs)
+        public ReflectPropertyDescriptor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentClass,
+            string name,
+            Type type,
+            Type receiverType,
+            MethodInfo getMethod,
+            MethodInfo setMethod,
+            Attribute[] attrs)
+            : this(componentClass, name, type, attrs)
         {
             _receiverType = receiverType;
             _getMethod = getMethod;
@@ -132,7 +154,10 @@ namespace System.ComponentModel
         /// This constructor takes an existing ReflectPropertyDescriptor and modifies it by merging in the
         /// passed-in attributes.
         /// </summary>
-        public ReflectPropertyDescriptor(Type componentClass, PropertyDescriptor oldReflectPropertyDescriptor, Attribute[] attributes)
+        public ReflectPropertyDescriptor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentClass,
+            PropertyDescriptor oldReflectPropertyDescriptor,
+            Attribute[] attributes)
             : base(oldReflectPropertyDescriptor, attributes)
         {
             _componentClass = componentClass;
@@ -221,7 +246,7 @@ namespace System.ComponentModel
             {
                 if (!_state[s_bitChangedQueried])
                 {
-                    _realChangedEvent = TypeDescriptor.GetEvents(ComponentType)[Name + "Changed"];
+                    _realChangedEvent = TypeDescriptor.GetEvents(_componentClass)[Name + "Changed"];
                     _state[s_bitChangedQueried] = true;
                 }
 
@@ -639,7 +664,7 @@ namespace System.ComponentModel
                     }
                     catch { }
                 }
-                return Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
+                return AttributesContainsDesignerVisibilityContent();
             }
             else if (DefaultValue == s_noValue)
             {
@@ -656,6 +681,10 @@ namespace System.ComponentModel
             return !Equals(DefaultValue, ExtenderGetValue(provider, component));
         }
 
+        [DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields, typeof(DesignerSerializationVisibilityAttribute))]
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency ensures the correct members are preserved.")]
+        private bool AttributesContainsDesignerVisibilityContent() => Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
+
         /// <summary>
         /// Indicates whether reset will change the value of the component. If there
         /// is a DefaultValueAttribute, then this will return true if getValue returns
@@ -1139,7 +1168,7 @@ namespace System.ComponentModel
                     }
                     catch { }
                 }
-                return Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
+                return AttributesContainsDesignerVisibilityContent();
             }
             else if (DefaultValue == s_noValue)
             {
index 4b47404..3ddd16d 100644 (file)
@@ -3,8 +3,8 @@
 
 using System.Collections;
 using System.Collections.Generic;
-using System.Collections.Specialized;
 using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 using System.Reflection;
 
 namespace System.ComponentModel
@@ -17,6 +17,7 @@ namespace System.ComponentModel
         /// </summary>
         private class ReflectedTypeData
         {
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
             private readonly Type _type;
             private AttributeCollection _attributes;
             private EventDescriptorCollection _events;
@@ -26,7 +27,7 @@ namespace System.ComponentModel
             private Type[] _editorTypes;
             private int _editorCount;
 
-            internal ReflectedTypeData(Type type)
+            internal ReflectedTypeData([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
             {
                 _type = type;
             }
@@ -169,6 +170,7 @@ namespace System.ComponentModel
             /// it will be used to retrieve attributes. Otherwise, _type
             /// will be used.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
             internal TypeConverter GetConverter(object instance)
             {
                 TypeConverterAttribute typeAttr = null;
@@ -225,6 +227,7 @@ namespace System.ComponentModel
             /// Return the default event. The default event is determined by the
             /// presence of a DefaultEventAttribute on the class.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
             internal EventDescriptor GetDefaultEvent(object instance)
             {
                 AttributeCollection attributes;
@@ -257,6 +260,7 @@ namespace System.ComponentModel
             /// <summary>
             /// Return the default property.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
             internal PropertyDescriptor GetDefaultProperty(object instance)
             {
                 AttributeCollection attributes;
@@ -289,6 +293,7 @@ namespace System.ComponentModel
             /// <summary>
             /// Retrieves the editor for the given base type.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
             internal object GetEditor(object instance, Type editorBaseType)
             {
                 EditorAttribute typeAttr;
index d8de50a..c2a136f 100644 (file)
@@ -5,6 +5,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel.Design;
 using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Linq;
 using System.Reflection;
@@ -172,11 +173,19 @@ namespace System.ComponentModel
             //
             [typeof(Array)] = new IntrinsicTypeConverterData((type) => new ArrayConverter()),
             [typeof(ICollection)] = new IntrinsicTypeConverterData((type) => new CollectionConverter()),
-            [typeof(Enum)] = new IntrinsicTypeConverterData((type) => new EnumConverter(type), cacheConverterInstance: false),
+            [typeof(Enum)] = new IntrinsicTypeConverterData((type) => CreateEnumConverter(type), cacheConverterInstance: false),
             [s_intrinsicNullableKey] = new IntrinsicTypeConverterData((type) => new NullableConverter(type), cacheConverterInstance: false),
             [s_intrinsicReferenceKey] = new IntrinsicTypeConverterData((type) => new ReferenceConverter(type), cacheConverterInstance: false),
         });
 
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
+            Justification = "Trimmer does not trim enums")]
+        private static EnumConverter CreateEnumConverter(Type type)
+        {
+            Debug.Assert(type.IsEnum || type == typeof(Enum));
+            return new EnumConverter(type);
+        }
+
         private static Hashtable PropertyCache => LazyInitializer.EnsureInitialized(ref s_propertyCache, () => new Hashtable());
 
         private static Hashtable EventCache => LazyInitializer.EnsureInitialized(ref s_eventCache, () => new Hashtable());
@@ -271,7 +280,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves custom attributes.
         /// </summary>
-        internal AttributeCollection GetAttributes(Type type)
+        internal AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetAttributes();
@@ -304,7 +313,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the class name for our type.
         /// </summary>
-        internal string GetClassName(Type type)
+        internal string GetClassName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetClassName(null);
@@ -313,7 +322,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the component name from the site.
         /// </summary>
-        internal string GetComponentName(Type type, object instance)
+        internal string GetComponentName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetComponentName(instance);
@@ -324,7 +333,8 @@ namespace System.ComponentModel
         /// it will be used to retrieve attributes. Otherwise, _type
         /// will be used.
         /// </summary>
-        internal TypeConverter GetConverter(Type type, object instance)
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
+        internal TypeConverter GetConverter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetConverter(instance);
@@ -334,7 +344,8 @@ namespace System.ComponentModel
         /// Return the default event. The default event is determined by the
         /// presence of a DefaultEventAttribute on the class.
         /// </summary>
-        internal EventDescriptor GetDefaultEvent(Type type, object instance)
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
+        internal EventDescriptor GetDefaultEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetDefaultEvent(instance);
@@ -343,7 +354,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Return the default property.
         /// </summary>
-        internal PropertyDescriptor GetDefaultProperty(Type type, object instance)
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
+        internal PropertyDescriptor GetDefaultProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetDefaultProperty(instance);
@@ -352,7 +364,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the editor for the given base type.
         /// </summary>
-        internal object GetEditor(Type type, object instance, Type editorBaseType)
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
+        internal object GetEditor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object instance, Type editorBaseType)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetEditor(instance, editorBaseType);
@@ -407,7 +420,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the events for this type.
         /// </summary>
-        internal EventDescriptorCollection GetEvents(Type type)
+        internal EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetEvents();
@@ -425,6 +438,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the class name for our type.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         internal string GetExtendedClassName(object instance)
         {
             return GetClassName(instance.GetType());
@@ -433,6 +447,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the component name from the site.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         internal string GetExtendedComponentName(object instance)
         {
             return GetComponentName(instance.GetType(), instance);
@@ -443,6 +458,7 @@ namespace System.ComponentModel
         /// it will be used to retrieve attributes. Otherwise, _type
         /// will be used.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         internal TypeConverter GetExtendedConverter(object instance)
         {
             return GetConverter(instance.GetType(), instance);
@@ -468,6 +484,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the editor for the given base type.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         internal object GetExtendedEditor(object instance, Type editorBaseType)
         {
             return GetEditor(instance.GetType(), instance, editorBaseType);
@@ -484,6 +501,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the properties for this type.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance and its IExtenderProviders cannot be statically discovered.")]
         internal PropertyDescriptorCollection GetExtendedProperties(object instance)
         {
             // Is this object a sited component?  If not, then it
@@ -756,6 +774,7 @@ namespace System.ComponentModel
         /// Provides a type descriptor for the given object. We only support this
         /// if the object is a component that
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
         {
             Debug.Fail("This should never be invoked. TypeDescriptionNode should wrap for us.");
@@ -771,6 +790,7 @@ namespace System.ComponentModel
         /// If not overridden, the default implementation of this method will call
         /// GetComponentName.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public override string GetFullComponentName(object component)
         {
             IComponent comp = component as IComponent;
@@ -811,7 +831,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Retrieves the properties for this type.
         /// </summary>
-        internal PropertyDescriptorCollection GetProperties(Type type)
+        internal PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             ReflectedTypeData td = GetTypeData(type, true);
             return td.GetProperties();
@@ -829,7 +849,10 @@ namespace System.ComponentModel
         /// Returns an Type for the given type. Since type implements IReflect,
         /// we just return objectType.
         /// </summary>
-        public override Type GetReflectionType(Type objectType, object instance)
+        [return: DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)]
+        public override Type GetReflectionType(
+            [DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)] Type objectType,
+            object instance)
         {
             Debug.Assert(objectType != null, "Should have arg-checked before coming in here");
             return objectType;
@@ -840,7 +863,7 @@ namespace System.ComponentModel
         /// null if there is no type data for the type yet and
         /// createIfNeeded is false.
         /// </summary>
-        private ReflectedTypeData GetTypeData(Type type, bool createIfNeeded)
+        private ReflectedTypeData GetTypeData([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, bool createIfNeeded)
         {
             ReflectedTypeData td = null;
 
@@ -882,7 +905,7 @@ namespace System.ComponentModel
         /// interested in providing type information for the object it should
         /// return null.
         /// </summary>
-        public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+        public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
         {
             Debug.Fail("This should never be invoked. TypeDescriptionNode should wrap for us.");
             return null;
@@ -921,9 +944,11 @@ namespace System.ComponentModel
         /// This method returns true if the data cache in this reflection
         /// type descriptor has data in it.
         /// </summary>
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
+            Justification = "ReflectedTypeData is not being created here, just checking if was already created.")]
         internal bool IsPopulated(Type type)
         {
-            ReflectedTypeData td = GetTypeData(type, false);
+            ReflectedTypeData td = GetTypeData(type, createIfNeeded: false);
             if (td != null)
             {
                 return td.IsPopulated;
@@ -994,7 +1019,8 @@ namespace System.ComponentModel
         /// Static helper API around reflection to get and cache
         /// events. This does not recurse to the base class.
         /// </summary>
-        private static EventDescriptor[] ReflectGetEvents(Type type)
+        private static EventDescriptor[] ReflectGetEvents(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             Hashtable eventCache = EventCache;
             EventDescriptor[] events = (EventDescriptor[])eventCache[type];
@@ -1076,6 +1102,7 @@ namespace System.ComponentModel
         /// provider instance, and a per-provider cache that contains
         /// the ExtendedPropertyDescriptors.
         /// </summary>
+        [RequiresUnreferencedCode("The type of provider cannot be statically discovered.")]
         private static PropertyDescriptor[] ReflectGetExtendedProperties(IExtenderProvider provider)
         {
             IDictionary cache = TypeDescriptor.GetCache(provider);
@@ -1168,7 +1195,8 @@ namespace System.ComponentModel
         /// Static helper API around reflection to get and cache
         /// properties. This does not recurse to the base class.
         /// </summary>
-        private static PropertyDescriptor[] ReflectGetProperties(Type type)
+        private static PropertyDescriptor[] ReflectGetProperties(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             Hashtable propertyCache = PropertyCache;
             PropertyDescriptor[] properties = (PropertyDescriptor[])propertyCache[type];
@@ -1250,9 +1278,11 @@ namespace System.ComponentModel
         /// actually requery, but it will clear our state so the next
         /// query re-populates.
         /// </summary>
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
+            Justification = "ReflectedTypeData is not being created here, just checking if was already created.")]
         internal void Refresh(Type type)
         {
-            ReflectedTypeData td = GetTypeData(type, false);
+            ReflectedTypeData td = GetTypeData(type, createIfNeeded: false);
             td?.Refresh();
         }
 
index 09e8cb1..f16fb9e 100644 (file)
@@ -224,6 +224,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of properties for the type of array specified by the value parameter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
         public PropertyDescriptorCollection GetProperties(object value) => GetProperties(null, value);
 
         /// <summary>
@@ -232,6 +233,8 @@ namespace System.ComponentModel
         /// the specified context.
         ///
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered.")]
+        [DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields, typeof(BrowsableAttribute))]
         public PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value)
         {
             return GetProperties(context, value, new Attribute[] { BrowsableAttribute.Yes });
@@ -243,6 +246,7 @@ namespace System.ComponentModel
         /// the specified context and attributes.
         ///
         /// </summary>
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public virtual PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             return null;
@@ -364,7 +368,12 @@ namespace System.ComponentModel
             /// <summary>
             /// Gets a value indicating whether this property is read-only.
             /// </summary>
-            public override bool IsReadOnly => Attributes.Contains(ReadOnlyAttribute.Yes);
+            public override bool IsReadOnly
+            {
+                [DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields, typeof(ReadOnlyAttribute))]
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency ensures the correct members are preserved.")]
+                get { return Attributes.Contains(ReadOnlyAttribute.Yes); }
+            }
 
             /// <summary>
             /// Gets the type of the property.
index 28b7a3a..2c4ad1f 100644 (file)
@@ -2,7 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Collections;
-using System.Runtime.Versioning;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.ComponentModel
 {
@@ -92,6 +92,7 @@ namespace System.ComponentModel
         /// model only supports extended properties this API can be used for extended
         /// attributes and events as well, if the type description provider supports it.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public virtual ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
         {
             if (_parent != null)
@@ -126,6 +127,7 @@ namespace System.ComponentModel
         /// If not overridden, the default implementation of this method will call
         /// GetTypeDescriptor.GetComponentName.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public virtual string GetFullComponentName(object component)
         {
             if (_parent != null)
@@ -141,7 +143,8 @@ namespace System.ComponentModel
         /// If no custom type descriptor can be located for an object, GetReflectionType
         /// is called to perform normal reflection against the object.
         /// </summary>
-        public Type GetReflectionType(Type objectType) => GetReflectionType(objectType, null);
+        [return: DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)]
+        public Type GetReflectionType([DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)] Type objectType) => GetReflectionType(objectType, null);
 
         /// <summary>
         /// The GetReflection method is a lower level version of GetTypeDescriptor.
@@ -152,6 +155,7 @@ namespace System.ComponentModel
         /// object type if no parent provider was passed. If a parent provider was passed, this
         /// method will invoke the parent provider's GetReflectionType method.
         /// </summary>
+        [RequiresUnreferencedCode("GetReflectionType is not trim compatible because the Type of object cannot be statically discovered.")]
         public Type GetReflectionType(object instance)
         {
             if (instance == null)
@@ -171,7 +175,10 @@ namespace System.ComponentModel
         /// object type if no parent provider was passed. If a parent provider was passed, this
         /// method will invoke the parent provider's GetReflectionType method.
         /// </summary>
-        public virtual Type GetReflectionType(Type objectType, object instance)
+        [return: DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)]
+        public virtual Type GetReflectionType(
+            [DynamicallyAccessedMembers(TypeDescriptor.ReflectTypesDynamicallyAccessedMembers)] Type objectType,
+            object instance)
         {
             if (_parent != null)
             {
@@ -215,7 +222,7 @@ namespace System.ComponentModel
         /// interested in providing type information for the object it should
         /// return base.
         /// </summary>
-        public ICustomTypeDescriptor GetTypeDescriptor(Type objectType)
+        public ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType)
         {
             return GetTypeDescriptor(objectType, null);
         }
@@ -228,6 +235,7 @@ namespace System.ComponentModel
         /// interested in providing type information for the object it should
         /// return base.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
         public ICustomTypeDescriptor GetTypeDescriptor(object instance)
         {
             if (instance == null)
@@ -252,7 +260,7 @@ namespace System.ComponentModel
         /// this method will invoke the parent provider's GetTypeDescriptor
         /// method.
         /// </summary>
-        public virtual ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+        public virtual ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
         {
             if (_parent != null)
             {
index 5ad91b8..d4136dd 100644 (file)
@@ -8,7 +8,6 @@ using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Reflection;
-using System.Runtime.Versioning;
 using System.Threading;
 
 namespace System.ComponentModel
@@ -19,6 +18,8 @@ namespace System.ComponentModel
     /// </summary>
     public sealed class TypeDescriptor
     {
+        internal const DynamicallyAccessedMemberTypes ReflectTypesDynamicallyAccessedMembers = DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields;
+
         // Note: this is initialized at class load because we
         // lock on it for thread safety. It is used from nearly
         // every call to this class, so it will be created soon after
@@ -460,10 +461,15 @@ namespace System.ComponentModel
 
             return instance ?? NodeFor(objectType).CreateInstance(provider, objectType, argTypes, args);
         }
+
         /// <summary>
         /// This dynamically binds a PropertyDescriptor to a type.
         /// </summary>
-        public static PropertyDescriptor CreateProperty(Type componentType, string name, Type type, params Attribute[] attributes)
+        public static PropertyDescriptor CreateProperty(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType,
+            string name,
+            Type type,
+            params Attribute[] attributes)
         {
             return new ReflectPropertyDescriptor(componentType, name, type, attributes);
         }
@@ -472,7 +478,10 @@ namespace System.ComponentModel
         /// This creates a new property descriptor identical to an existing property descriptor. The new property descriptor
         /// has the specified metadata attributes merged with the existing metadata attributes.
         /// </summary>
-        public static PropertyDescriptor CreateProperty(Type componentType, PropertyDescriptor oldPropertyDescriptor, params Attribute[] attributes)
+        public static PropertyDescriptor CreateProperty(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType,
+            PropertyDescriptor oldPropertyDescriptor,
+            params Attribute[] attributes)
         {
             // We must do some special case work here for extended properties. If the old property descriptor is really
             // an extender property that is being surfaced on a component as a normal property, then we must
@@ -504,6 +513,7 @@ namespace System.ComponentModel
         /// contains only the remaining members. The API returns
         /// NULL if it did not need to filter any members.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         private static ArrayList FilterMembers(IList members, Attribute[] attributes)
         {
             ArrayList newMembers = null;
@@ -627,7 +637,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of attributes for the specified type of component.
         /// </summary>
-        public static AttributeCollection GetAttributes(Type componentType)
+        public static AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             if (componentType == null)
             {
@@ -642,6 +652,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of attributes for the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static AttributeCollection GetAttributes(object component)
         {
             return GetAttributes(component, false);
@@ -651,6 +662,7 @@ namespace System.ComponentModel
         /// Gets a collection of attributes for the specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static AttributeCollection GetAttributes(object component, bool noCustomTypeDesc)
         {
             if (component == null)
@@ -740,12 +752,14 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the name of the class for the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetClassName(object component) => GetClassName(component, false);
 
         /// <summary>
         /// Gets the name of the class for the specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetClassName(object component, bool noCustomTypeDesc)
         {
             return GetDescriptor(component, noCustomTypeDesc).GetClassName();
@@ -754,7 +768,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the name of the class for the specified type.
         /// </summary>
-        public static string GetClassName(Type componentType)
+        public static string GetClassName(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             return GetDescriptor(componentType, nameof(componentType)).GetClassName();
         }
@@ -762,12 +777,14 @@ namespace System.ComponentModel
         /// <summary>
         /// The name of the class for the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetComponentName(object component) => GetComponentName(component, false);
 
         /// <summary>
         /// Gets the name of the class for the specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetComponentName(object component, bool noCustomTypeDesc)
         {
             return GetDescriptor(component, noCustomTypeDesc).GetComponentName();
@@ -776,12 +793,14 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a type converter for the type of the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static TypeConverter GetConverter(object component) => GetConverter(component, false);
 
         /// <summary>
         /// Gets a type converter for the type of the specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static TypeConverter GetConverter(object component, bool noCustomTypeDesc)
         {
             TypeConverter converter = GetDescriptor(component, noCustomTypeDesc).GetConverter();
@@ -791,13 +810,13 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a type converter for the specified type.
         /// </summary>
-        public static TypeConverter GetConverter(Type type)
+        public static TypeConverter GetConverter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
         {
             return GetDescriptor(type, nameof(type)).GetConverter();
         }
 
         // This is called by System.ComponentModel.DefaultValueAttribute via reflection.
-        private static object ConvertFromInvariantString(Type type, string stringValue)
+        private static object ConvertFromInvariantString([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string stringValue)
         {
             return GetConverter(type).ConvertFromInvariantString(stringValue);
         }
@@ -805,7 +824,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the default event for the specified type of component.
         /// </summary>
-        public static EventDescriptor GetDefaultEvent(Type componentType)
+        public static EventDescriptor GetDefaultEvent(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             if (componentType == null)
             {
@@ -819,12 +839,14 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the default event for the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static EventDescriptor GetDefaultEvent(object component) => GetDefaultEvent(component, false);
 
         /// <summary>
         /// Gets the default event for a component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static EventDescriptor GetDefaultEvent(object component, bool noCustomTypeDesc)
         {
             if (component == null)
@@ -839,7 +861,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the default property for the specified type of component.
         /// </summary>
-        public static PropertyDescriptor GetDefaultProperty(Type componentType)
+        public static PropertyDescriptor GetDefaultProperty(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             if (componentType == null)
             {
@@ -853,12 +876,14 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets the default property for the specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static PropertyDescriptor GetDefaultProperty(object component) => GetDefaultProperty(component, false);
 
         /// <summary>
         /// Gets the default property for the specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static PropertyDescriptor GetDefaultProperty(object component, bool noCustomTypeDesc)
         {
             if (component == null)
@@ -874,7 +899,9 @@ namespace System.ComponentModel
         /// Returns a custom type descriptor for the given type.
         /// Performs arg checking so callers don't have to.
         /// </summary>
-        internal static ICustomTypeDescriptor GetDescriptor(Type type, string typeName)
+        internal static ICustomTypeDescriptor GetDescriptor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
+            string typeName)
         {
             if (type == null)
             {
@@ -890,6 +917,7 @@ namespace System.ComponentModel
         /// will call through to instance if it is a custom type
         /// descriptor.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         internal static ICustomTypeDescriptor GetDescriptor(object component, bool noCustomTypeDesc)
         {
             if (component == null)
@@ -910,6 +938,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Returns an extended custom type descriptor for the given instance.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         internal static ICustomTypeDescriptor GetExtendedDescriptor(object component)
         {
             if (component == null)
@@ -924,6 +953,7 @@ namespace System.ComponentModel
         /// Gets an editor with the specified base type for the
         /// specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static object GetEditor(object component, Type editorBaseType)
         {
             return GetEditor(component, editorBaseType, false);
@@ -934,6 +964,7 @@ namespace System.ComponentModel
         /// specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static object GetEditor(object component, Type editorBaseType, bool noCustomTypeDesc)
         {
             if (editorBaseType == null)
@@ -947,7 +978,9 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets an editor with the specified base type for the specified type.
         /// </summary>
-        public static object GetEditor(Type type, Type editorBaseType)
+        public static object GetEditor(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
+            Type editorBaseType)
         {
             if (editorBaseType == null)
             {
@@ -960,7 +993,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of events for a specified type of component.
         /// </summary>
-        public static EventDescriptorCollection GetEvents(Type componentType)
+        public static EventDescriptorCollection GetEvents(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             if (componentType == null)
             {
@@ -975,7 +1009,10 @@ namespace System.ComponentModel
         /// Gets a collection of events for a specified type of
         /// component using a specified array of attributes as a filter.
         /// </summary>
-        public static EventDescriptorCollection GetEvents(Type componentType, Attribute[] attributes)
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
+        public static EventDescriptorCollection GetEvents(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType,
+            Attribute[] attributes)
         {
             if (componentType == null)
             {
@@ -1000,6 +1037,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of events for a specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static EventDescriptorCollection GetEvents(object component)
         {
             return GetEvents(component, null, false);
@@ -1009,6 +1047,7 @@ namespace System.ComponentModel
         /// Gets a collection of events for a specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc)
         {
             return GetEvents(component, null, noCustomTypeDesc);
@@ -1018,6 +1057,7 @@ namespace System.ComponentModel
         /// Gets a collection of events for a specified component
         /// using a specified array of attributes as a filter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public static EventDescriptorCollection GetEvents(object component, Attribute[] attributes)
         {
             return GetEvents(component, attributes, false);
@@ -1028,6 +1068,7 @@ namespace System.ComponentModel
         /// using a specified array of attributes as a filter.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public static EventDescriptorCollection GetEvents(object component, Attribute[] attributes, bool noCustomTypeDesc)
         {
             if (component == null)
@@ -1153,6 +1194,7 @@ namespace System.ComponentModel
         /// component resides in a nested container or has other nested semantics, it may
         /// return a different fully qualified name.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static string GetFullComponentName(object component)
         {
             if (component == null)
@@ -1179,7 +1221,8 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of properties for a specified type of component.
         /// </summary>
-        public static PropertyDescriptorCollection GetProperties(Type componentType)
+        public static PropertyDescriptorCollection GetProperties(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
         {
             if (componentType == null)
             {
@@ -1194,7 +1237,10 @@ namespace System.ComponentModel
         /// Gets a collection of properties for a specified type of
         /// component using a specified array of attributes as a filter.
         /// </summary>
-        public static PropertyDescriptorCollection GetProperties(Type componentType, Attribute[] attributes)
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
+        public static PropertyDescriptorCollection GetProperties(
+            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType,
+            Attribute[] attributes)
         {
             if (componentType == null)
             {
@@ -1219,6 +1265,7 @@ namespace System.ComponentModel
         /// <summary>
         /// Gets a collection of properties for a specified component.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static PropertyDescriptorCollection GetProperties(object component)
         {
             return GetProperties(component, false);
@@ -1228,6 +1275,7 @@ namespace System.ComponentModel
         /// Gets a collection of properties for a specified component.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc)
         {
             return GetPropertiesImpl(component, null, noCustomTypeDesc, true);
@@ -1238,6 +1286,7 @@ namespace System.ComponentModel
         /// component using a specified array of attributes
         /// as a filter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public static PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes)
         {
             return GetProperties(component, attributes, false);
@@ -1248,6 +1297,7 @@ namespace System.ComponentModel
         /// component using a specified array of attributes
         /// as a filter.
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public static PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes, bool noCustomTypeDesc)
         {
             return GetPropertiesImpl(component, attributes, noCustomTypeDesc, false);
@@ -1258,6 +1308,7 @@ namespace System.ComponentModel
         /// only if noAttributes is false. This is to preserve backward compat for the case when
         /// no attribute filter was passed in (as against passing in null).
         /// </summary>
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         private static PropertyDescriptorCollection GetPropertiesImpl(object component, Attribute[] attributes, bool noCustomTypeDesc, bool noAttributes)
         {
             if (component == null)
@@ -1393,7 +1444,8 @@ namespace System.ComponentModel
         /// Returns an Type instance that can be used to perform reflection.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
-        public static Type GetReflectionType(Type type)
+        [return: DynamicallyAccessedMembers(ReflectTypesDynamicallyAccessedMembers)]
+        public static Type GetReflectionType([DynamicallyAccessedMembers(ReflectTypesDynamicallyAccessedMembers)] Type type)
         {
             if (type == null)
             {
@@ -1403,11 +1455,11 @@ namespace System.ComponentModel
             return NodeFor(type).GetReflectionType(type);
         }
 
-
         /// <summary>
         /// Returns an Type instance that can be used to perform reflection.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Advanced)]
+        [RequiresUnreferencedCode("GetReflectionType is not trim compatible because the Type of object cannot be statically discovered.")]
         public static Type GetReflectionType(object instance)
         {
             if (instance == null)
@@ -1649,6 +1701,7 @@ namespace System.ComponentModel
         /// This is the last stage in our filtering pipeline. Here, we apply any
         /// user-defined filter.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         private static ICollection PipelineAttributeFilter(int pipelineType, ICollection members, Attribute[] filter, object instance, IDictionary cache)
         {
             Debug.Assert(pipelineType != PIPELINE_ATTRIBUTES, "PipelineAttributeFilter is not supported for attributes");
@@ -2321,6 +2374,7 @@ namespace System.ComponentModel
             get => typeof(TypeDescriptorComObject);
         }
 
+        [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
         public static IDesigner CreateDesigner(IComponent component, Type designerBaseType)
         {
             Type type = null;
@@ -2542,6 +2596,7 @@ namespace System.ComponentModel
         /// contains the attribute or the member does not contain the attribute and the default
         /// for the attribute matches the passed in attribute.
         /// </summary>
+        [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         private static bool ShouldHideMember(MemberDescriptor member, Attribute attribute)
         {
             if (member == null || attribute == null)
@@ -2595,7 +2650,7 @@ namespace System.ComponentModel
             /// Implements GetTypeDescriptor. This creates a custom type
             /// descriptor that walks the linked list for each of its calls.
             /// </summary>
-            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+            public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
             {
                 if (objectType == null)
                 {
@@ -2663,6 +2718,7 @@ namespace System.ComponentModel
                     return _handler.GetEvents(_instance);
                 }
 
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
                 {
                     return _handler.GetEvents(_instance, attributes);
@@ -2673,6 +2729,7 @@ namespace System.ComponentModel
                     return _handler.GetProperties(_instance, null);
                 }
 
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
                 {
                     return _handler.GetProperties(_instance, attributes);
@@ -2702,7 +2759,7 @@ namespace System.ComponentModel
             /// <summary>
             /// Creates a custom type descriptor that replaces the attributes.
             /// </summary>
-            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+            public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
             {
                 return new AttributeTypeDescriptor(_attrs, base.GetTypeDescriptor(objectType, instance));
             }
@@ -2869,7 +2926,7 @@ namespace System.ComponentModel
                 _comNativeDescriptor = (TypeDescriptionProvider)Activator.CreateInstance(realComNativeDescriptor);
             }
 
-            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+            public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
             {
                 return _comNativeDescriptor.GetTypeDescriptor(objectType, instance);
             }
@@ -2981,6 +3038,7 @@ namespace System.ComponentModel
             /// <summary>
             /// ICustomTypeDescriptor implementation.
             /// </summary>
+            [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
             EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
             {
                 EventDescriptorCollection events = _primary.GetEvents(attributes) ?? _secondary.GetEvents(attributes);
@@ -3003,6 +3061,7 @@ namespace System.ComponentModel
             /// <summary>
             /// ICustomTypeDescriptor implementation.
             /// </summary>
+            [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
             PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
             {
                 PropertyDescriptorCollection properties = _primary.GetProperties(attributes);
@@ -3091,6 +3150,7 @@ namespace System.ComponentModel
             /// Implements GetExtendedTypeDescriptor. This creates a custom type
             /// descriptor that walks the linked list for each of its calls.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
             public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
             {
                 if (instance == null)
@@ -3120,6 +3180,7 @@ namespace System.ComponentModel
             /// If not overridden, the default implementation of this method will call
             /// GetTypeDescriptor.GetComponentName.
             /// </summary>
+            [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
             public override string GetFullComponentName(object component)
             {
                 if (component == null)
@@ -3134,7 +3195,10 @@ namespace System.ComponentModel
             /// Implements GetReflectionType. This just walks the linked list
             /// looking for someone who implements the call.
             /// </summary>
-            public override Type GetReflectionType(Type objectType, object instance)
+            [return: DynamicallyAccessedMembers(ReflectTypesDynamicallyAccessedMembers)]
+            public override Type GetReflectionType(
+                [DynamicallyAccessedMembers(ReflectTypesDynamicallyAccessedMembers)] Type objectType,
+                object instance)
             {
                 if (objectType == null)
                 {
@@ -3158,7 +3222,7 @@ namespace System.ComponentModel
             /// Implements GetTypeDescriptor. This creates a custom type
             /// descriptor that walks the linked list for each of its calls.
             /// </summary>
-            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+            public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
             {
                 if (objectType == null)
                 {
@@ -3194,6 +3258,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// Creates a new WalkingExtendedTypeDescriptor.
                 /// </summary>
+                [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
                 internal DefaultExtendedTypeDescriptor(TypeDescriptionNode node, object instance)
                 {
                     _node = node;
@@ -3203,6 +3268,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 AttributeCollection ICustomTypeDescriptor.GetAttributes()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3225,6 +3291,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 string ICustomTypeDescriptor.GetClassName()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3246,6 +3313,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 string ICustomTypeDescriptor.GetComponentName()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3266,6 +3334,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 TypeConverter ICustomTypeDescriptor.GetConverter()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3288,6 +3357,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3308,6 +3378,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3327,6 +3398,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
                 {
                     if (editorBaseType == null)
@@ -3351,6 +3423,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3372,6 +3445,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3398,6 +3472,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3419,6 +3494,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3445,6 +3521,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
                 object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3471,13 +3548,17 @@ namespace System.ComponentModel
             private readonly struct DefaultTypeDescriptor : ICustomTypeDescriptor
             {
                 private readonly TypeDescriptionNode _node;
+                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
                 private readonly Type _objectType;
                 private readonly object _instance;
 
                 /// <summary>
                 /// Creates a new WalkingTypeDescriptor.
                 /// </summary>
-                internal DefaultTypeDescriptor(TypeDescriptionNode node, Type objectType, object instance)
+                internal DefaultTypeDescriptor(
+                    TypeDescriptionNode node,
+                    [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType,
+                    object instance)
                 {
                     _node = node;
                     _objectType = objectType;
@@ -3698,6 +3779,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
@@ -3752,6 +3834,7 @@ namespace System.ComponentModel
                 /// <summary>
                 /// ICustomTypeDescriptor implementation.
                 /// </summary>
+                [RequiresUnreferencedCode(AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
                 {
                     // Check to see if the provider we get is a ReflectTypeDescriptionProvider.
index e662f6f..ca62378 100644 (file)
@@ -123,6 +123,7 @@ namespace System.Drawing
 
         private static readonly string[] s_propertySort = { "X", "Y" };
 
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Point), attributes);
index 758f5bf..8a4df6c 100644 (file)
@@ -129,6 +129,7 @@ namespace System.Drawing
 
         private static readonly string[] s_propertySort = { "X", "Y", "Width", "Height" };
 
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Rectangle), attributes);
index dc492bb..d71fee4 100644 (file)
@@ -121,6 +121,7 @@ namespace System.Drawing
 
         private static readonly string[] s_propertySort = { "Width", "Height" };
 
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Size), attributes);
index 1dd5a97..61bb9c5 100644 (file)
@@ -118,6 +118,7 @@ namespace System.Drawing
 
         private static readonly string[] s_propertySort = { "Width", "Height" };
 
+        [RequiresUnreferencedCode("The Type of value cannot be statically discovered. " + AttributeCollection.FilterRequiresUnreferencedCodeMessage)]
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(SizeF), attributes);
diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/TrimmingTests/TypeConverterIsReadOnly.cs b/src/libraries/System.ComponentModel.TypeConverter/tests/TrimmingTests/TypeConverterIsReadOnly.cs
new file mode 100644 (file)
index 0000000..08f15c3
--- /dev/null
@@ -0,0 +1,72 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+/// <summary>
+/// Tests that SimplePropertyDescriptor.IsReadOnly works correctly when trimming.
+/// </summary>
+class Program
+{
+    static int Main()
+    {
+        PropertyDescriptor property = MyTypeConverter.CreatePropertyDescriptor(isReadOnly: false);
+        if (property.IsReadOnly)
+        {
+            return -1;
+        }
+
+        property = MyTypeConverter.CreatePropertyDescriptor(isReadOnly: true);
+        if (!property.IsReadOnly)
+        {
+            return -2;
+        }
+
+        Type readOnlyAttributeType = property.Attributes[0].GetType();
+        if (readOnlyAttributeType.Name != "ReadOnlyAttribute")
+        {
+            return -3;
+        }
+
+        // check to make sure the 'ReadOnlyAttribute.Default' static field is preserved
+        if (readOnlyAttributeType.GetField("Default") == null)
+        {
+            return -4;
+        }
+
+        return 100;
+    }
+}
+
+internal class MyTypeConverter : TypeConverter
+{
+    protected class MyPropertyDescriptor : SimplePropertyDescriptor
+    {
+        private readonly bool _isReadOnly;
+
+        public MyPropertyDescriptor(bool isReadOnly) : base(typeof(Program), "property", typeof(int))
+        {
+            _isReadOnly = isReadOnly;
+        }
+
+        protected override void FillAttributes(IList attributeList)
+        {
+            if (_isReadOnly)
+            {
+                attributeList.Add(ReadOnlyAttribute.Yes);
+            }
+
+            base.FillAttributes(attributeList);
+        }
+
+        public override object GetValue(object component) => null;
+        public override void SetValue(object component, object value) { }
+    }
+
+    public static PropertyDescriptor CreatePropertyDescriptor(bool isReadOnly)
+    {
+        return new MyPropertyDescriptor(isReadOnly);
+    }
+}
index 423e82d..9844b89 100644 (file)
@@ -470,8 +470,10 @@ namespace System.Data
         System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
         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.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; }
         System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("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
@@ -2057,8 +2059,10 @@ namespace System.Data.Common
         System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
         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.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; }
         System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("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; }
@@ -2232,8 +2236,10 @@ namespace System.Data.Common
         System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
         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.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[] attributes) { throw null; }
         System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
+        [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("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
index a337709..aae5e3c 100644 (file)
       <property name="Scope">member</property>
       <property name="Target">M:System.Data.DataSet.SerializeDataSet(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext,System.Data.SerializationFormat)</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.Common.DbConnectionStringBuilder.GetProperties(System.Collections.Hashtable)</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetAttributes</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetClassName</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetComponentName</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetConverter</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultEvent</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetDefaultProperty</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEditor(System.Type)</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.Common.DbConnectionStringBuilder.System#ComponentModel#ICustomTypeDescriptor#GetEvents</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.XMLSchema.SetProperties(System.Object,System.Xml.XmlAttributeCollection)</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.XmlTreeGen.AddXdoProperties(System.Object,System.Xml.XmlElement,System.Xml.XmlDocument)</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.XmlTreeGen.AddXdoProperty(System.ComponentModel.PropertyDescriptor,System.Object,System.Xml.XmlElement,System.Xml.XmlDocument)</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.XSDSchema.SetExtProperties(System.Object,System.Xml.XmlAttribute[])</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.XSDSchema.SetExtProperties(System.Object,System.Xml.XmlAttributeCollection)</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.XSDSchema.SetProperties(System.Object,System.Xml.XmlAttribute[])</property>
+    </attribute>
+    <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+      <argument>ILLink</argument>
+      <argument>IL2067</argument>
+      <property name="Scope">member</property>
+      <property name="Target">M:System.Data.XMLSchema.GetConverter(System.Type)</property>
+    </attribute>
   </assembly>
 </linker>
index 0bad614..e18d3af 100644 (file)
@@ -4,6 +4,7 @@
 using System.ComponentModel;
 using System.Data.ProviderBase;
 using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.Data.Common
 {
@@ -344,16 +345,19 @@ namespace System.Data.Common
             return new EventDescriptorCollection(null);
         }
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
         {
             return new EventDescriptorCollection(null);
         }
 
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "No Attributes are supplied.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
         {
             return ((ICustomTypeDescriptor)this).GetProperties(null);
         }
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
         {
             if (_propertyDescriptors == null)
index 533e6ed..1bd2205 100644 (file)
@@ -514,6 +514,7 @@ namespace System.Data.Common
             }
         }
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         private PropertyDescriptorCollection GetProperties(Attribute[]? attributes)
         {
             PropertyDescriptorCollection propertyDescriptors = GetProperties();
@@ -591,6 +592,7 @@ namespace System.Data.Common
         {
             return GetProperties();
         }
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
         {
             return GetProperties(attributes);
@@ -603,6 +605,7 @@ namespace System.Data.Common
         {
             return TypeDescriptor.GetEvents(this, true);
         }
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
         {
             return TypeDescriptor.GetEvents(this, attributes, true);
index 605045f..11ba194 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.Data.Common
 {
@@ -86,11 +87,14 @@ namespace System.Data.Common
 
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new EventDescriptorCollection(null);
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) => new EventDescriptorCollection(null);
 
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "No Attributes are supplied.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() =>
             ((ICustomTypeDescriptor)this).GetProperties(null);
 
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) =>
             new PropertyDescriptorCollection(null);
 
index 8f0813b..50e01e4 100644 (file)
@@ -241,10 +241,17 @@ namespace System.Data
         PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() => null;
         object ICustomTypeDescriptor.GetEditor(Type editorBaseType) => null;
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new EventDescriptorCollection(null);
+
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) => new EventDescriptorCollection(null);
+
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "No Attributes are supplied.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() => ((ICustomTypeDescriptor)this).GetProperties(null);
+
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) =>
             (_dataView.Table != null ? _dataView.Table.GetPropertyDescriptorCollection(attributes) : s_zeroPropertyDescriptorCollection);
+
         object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) => this;
 #nullable enable
         #endregion
index 24059e6..734b4f5 100644 (file)
@@ -5,6 +5,7 @@
 #nullable disable
 
 using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.Data
 {
@@ -82,6 +83,7 @@ namespace System.Data
         /// additional events.  The returned array of events will be
         /// filtered by the given set of attributes.
         /// </summary>
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) =>
             new EventDescriptorCollection(null);
 
@@ -91,6 +93,7 @@ namespace System.Data
         ///     provides.  If the component is sited, the site may add or remove
         ///     additional properties.
         /// </summary>
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "No Attributes are supplied.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() =>
             ((ICustomTypeDescriptor)this).GetProperties(null);
 
@@ -101,6 +104,7 @@ namespace System.Data
         ///     additional properties.  The returned array of properties will be
         ///     filtered by the given set of attributes.
         /// </summary>
+        [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
         PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
         {
             if (_propsCollection == null)
index 4f68992..6e9fbb9 100644 (file)
@@ -155,7 +155,7 @@ namespace System.Data
                 return;
             }
 
-            if ((!pd.ShouldSerializeValue(instance) || !pd.Attributes.Contains(DesignerSerializationVisibilityAttribute.Visible)) && (bIsSqlType == false))
+            if ((!pd.ShouldSerializeValue(instance) || !ContainsDesignerSerializationVisibleAttribute(pd)) && (bIsSqlType == false))
             {
                 return;
             }
@@ -220,6 +220,10 @@ namespace System.Data
             return;
         }
 
+        [DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields, typeof(DesignerSerializationVisibilityAttribute))]
+        [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency ensures the correct members are preserved.")]
+        private bool ContainsDesignerSerializationVisibleAttribute(PropertyDescriptor pd) => pd.Attributes.Contains(DesignerSerializationVisibilityAttribute.Visible);
+
         internal static string XmlDataTypeName(Type type)
         {
             if (type == typeof(char))