Skip to content

.NET 9, ILC reports trimmer warnings for k__BackingField for auto-properties #108978

@jonathanpeppers

Description

@jonathanpeppers

Description

For the property:

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
Type? IHybridWebView.InvokeJavaScriptType { get; set; }

We got the trimmer warning:

ILC: IL2114: Microsoft.Maui.Controls.HybridWebView.<Microsoft.Maui.IHybridWebView.InvokeJavaScriptType>k__BackingField: 'DynamicallyAccessedMembersAttribute' on 'Microsoft.Maui.Controls.HybridWebView' or one of its base types

This was inside a .NET MAUI project on iOS.

We think something like this will workaround this case, but CI is ongoing:

Reproduction Steps

  • dotnet new maui

  • Root everything:

<ItemGroup>
	<PackageReference Include="Microsoft.Maui.Controls.Foldable" Version="$(MauiVersion)" />
	<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="$(MauiVersion)" />
	<PackageReference Include="Microsoft.Maui.Graphics.Skia" Version="$(MauiVersion)" />
</ItemGroup>
<ItemGroup>
	<TrimmerRootAssembly Include="Microsoft.Maui" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Controls" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Controls.Foldable" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Controls.Maps" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Controls.Xaml" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Essentials" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Graphics" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Graphics.Skia" RootMode="All" />
	<TrimmerRootAssembly Include="Microsoft.Maui.Maps" RootMode="All" />
</ItemGroup>
  • Publish for NativeAOT: dotnet publish -c Release -p:PublishAot=true -f net9.0-ios

Expected behavior

We would not get trimmer warnings for k__BackingField.

Actual behavior

We get trimmer warnings for k__BackingField.

Regression?

Not sure

Known Workarounds

I assume we can do:

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
private Type? _invokeJavaScriptType;

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
Type? IHybridWebView.InvokeJavaScriptType
{
	get => _invokeJavaScriptType;
	set => _invokeJavaScriptType = value;
}

Configuration

> dotnet --version
9.0.100-rc.2.24426.11

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions