Skip to content

Remove special logic for TypeConverterAttribute #2659

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 1, 2022

Conversation

jtschuster
Copy link
Member

Fixes #1942

We no longer need special logic for TypeConverterAttributes. This removes that code, and adds a test to reproduce the issue found in #1942.

@jtschuster jtschuster merged commit b10e1bc into dotnet:main Mar 1, 2022
@marek-safar
Copy link
Contributor

Are the annotations correct in .NET6 release so targeting LTS from net7 works as expected?

@eerhardt
Copy link
Member

eerhardt commented Mar 3, 2022

Are the annotations correct in .NET6 release so targeting LTS from net7 works as expected?

Yes. See dotnet/runtime#39144. TypeConverterAttribute was made trim-compatible in .NET 5.

@agocke @vitek-karas @jtschuster - Is there any chance this change can be backported to .NET 6 for Maui? I'm seeing the following warnings 330 times when trimming a Maui app, which is causing A LOT of noise.

ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]
ILLink : Trim analysis warning IL2111: Microsoft.Maui.Controls.VisualElement.Visual: Method 'Microsoft.Maui.Controls.VisualTypeConverter.CreateVisual(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [C:\git\WeatherTwentyOne\src\WeatherTwentyOne\WeatherTwentyOne.csproj]

In case you are curious, I explained the reason these warnings occur here.

@agocke
Copy link
Member

agocke commented Mar 3, 2022

Given that this is an SDK-only change with high impact, I think it has a chance.

agocke pushed a commit to agocke/linker that referenced this pull request Mar 18, 2022
agocke added a commit that referenced this pull request Mar 23, 2022
(cherry picked from commit b10e1bc)

Co-authored-by: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove special handling of TypeDescriptionProviderAttribute and TypeConverterAttribute
5 participants