Skip to content

Commit

Permalink
Resolve ILLink warnings in System.ComponentModel.TypeConverter (Round…
Browse files Browse the repository at this point in the history
… 2) (#49467)

* Resolve ILLink warnings in System.ComponentModel.TypeConverter (Round 2)

Contributes to #45623

* Change ComNativeDescriptorProxy so the linker can see the Type (when it is available) by using Type.GetType.
  • Loading branch information
eerhardt authored Mar 15, 2021
1 parent 6d23851 commit ddff65b
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ public DescriptionAttribute(string description) { }
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed partial class DesignerAttribute : System.Attribute
{
public DesignerAttribute(string designerTypeName) { }
public DesignerAttribute(string designerTypeName, string designerBaseTypeName) { }
public DesignerAttribute(string designerTypeName, System.Type designerBaseType) { }
public DesignerAttribute(System.Type designerType) { }
public DesignerAttribute(System.Type designerType, System.Type designerBaseType) { }
public DesignerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName) { }
public DesignerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerBaseTypeName) { }
public DesignerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type designerBaseType) { }
public DesignerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type designerType) { }
public DesignerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type designerType, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type designerBaseType) { }
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public string DesignerBaseTypeName { get { throw null; } }
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public string DesignerTypeName { get { throw null; } }
public override object TypeId { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
Expand Down Expand Up @@ -162,10 +164,12 @@ public DisplayNameAttribute(string displayName) { }
public sealed partial class EditorAttribute : System.Attribute
{
public EditorAttribute() { }
public EditorAttribute(string typeName, string? baseTypeName) { }
public EditorAttribute(string typeName, System.Type baseType) { }
public EditorAttribute(System.Type type, System.Type baseType) { }
public EditorAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] string typeName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] string? baseTypeName) { }
public EditorAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] string typeName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type baseType) { }
public EditorAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type baseType) { }
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
public string? EditorBaseTypeName { get { throw null; } }
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
public string EditorTypeName { get { throw null; } }
public override object TypeId { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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.ComponentModel.Design;
using System.Diagnostics.CodeAnalysis;

namespace System.ComponentModel
{
Expand All @@ -17,7 +17,7 @@ public sealed class DesignerAttribute : Attribute
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerAttribute'/> class using the name of the type that
/// provides design-time services.
/// </summary>
public DesignerAttribute(string designerTypeName)
public DesignerAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName)
{
DesignerTypeName = designerTypeName ?? throw new ArgumentNullException(nameof(designerTypeName));
DesignerBaseTypeName = "System.ComponentModel.Design.IDesigner, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
Expand All @@ -27,7 +27,7 @@ public DesignerAttribute(string designerTypeName)
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerAttribute'/> class using the type that provides
/// design-time services.
/// </summary>
public DesignerAttribute(Type designerType)
public DesignerAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type designerType)
{
if (designerType == null)
{
Expand All @@ -42,7 +42,9 @@ public DesignerAttribute(Type designerType)
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerAttribute'/> class using the designer type and the
/// base class for the designer.
/// </summary>
public DesignerAttribute(string designerTypeName, string designerBaseTypeName)
public DesignerAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerBaseTypeName)
{
DesignerTypeName = designerTypeName ?? throw new ArgumentNullException(nameof(designerTypeName));
DesignerBaseTypeName = designerBaseTypeName;
Expand All @@ -52,7 +54,9 @@ public DesignerAttribute(string designerTypeName, string designerBaseTypeName)
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerAttribute'/> class, using the name of the designer
/// class and the base class for the designer.
/// </summary>
public DesignerAttribute(string designerTypeName, Type designerBaseType)
public DesignerAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string designerTypeName,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type designerBaseType)
{
if (designerTypeName == null)
{
Expand All @@ -71,7 +75,9 @@ public DesignerAttribute(string designerTypeName, Type designerBaseType)
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerAttribute'/> class using the types of the designer and
/// designer base class.
/// </summary>
public DesignerAttribute(Type designerType, Type designerBaseType)
public DesignerAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type designerType,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type designerBaseType)
{
if (designerType == null)
{
Expand All @@ -89,11 +95,14 @@ public DesignerAttribute(Type designerType, Type designerBaseType)
/// <summary>
/// Gets the name of the base type of this designer.
/// </summary>
// Using PublicParameterlessConstructor to preserve the type. See https://github.com/mono/linker/issues/1878
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public string DesignerBaseTypeName { get; }

/// <summary>
/// Gets the name of the designer type associated with this designer attribute.
/// </summary>
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public string DesignerTypeName { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -25,7 +27,9 @@ public EditorAttribute()
/// Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class with the type name and base type
/// name of the editor.
/// </summary>
public EditorAttribute(string typeName, string? baseTypeName)
public EditorAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] string typeName,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] string? baseTypeName)
{
EditorTypeName = typeName ?? throw new ArgumentNullException(nameof(typeName));
EditorBaseTypeName = baseTypeName;
Expand All @@ -34,7 +38,9 @@ public EditorAttribute(string typeName, string? baseTypeName)
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class.
/// </summary>
public EditorAttribute(string typeName, Type baseType)
public EditorAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] string typeName,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type baseType)
{
if (typeName == null)
{
Expand All @@ -52,7 +58,9 @@ public EditorAttribute(string typeName, Type baseType)
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class.
/// </summary>
public EditorAttribute(Type type, Type baseType)
public EditorAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type baseType)
{
if (type == null)
{
Expand All @@ -70,11 +78,13 @@ public EditorAttribute(Type type, Type baseType)
/// <summary>
/// Gets the name of the base class or interface serving as a lookup key for this editor.
/// </summary>
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public string? EditorBaseTypeName { get; }

/// <summary>
/// Gets the name of the editor class.
/// </summary>
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public string EditorTypeName { get; }

/// <summary>
Expand Down
Loading

0 comments on commit ddff65b

Please sign in to comment.