Skip to content

Unactionable trim warning when using MySqlStringConnectionBuilder #1607

@sbomer

Description

@sbomer

When using MySqlStringConnectionBuilder together with options binding source generation it's possible to hit warnings like:

/_/src/MySqlConnector/MySqlConnectionStringBuilder.cs(879,3): Trim analysis error IL2112: MySqlConnector.MySqlConnectionStringBuilder.GetProperties(Hashtable): 'DynamicallyAccessedMembersAttribute' on 'MySqlConnector.MySqlConnectionStringBuilder' or one of its base types references 'MySqlConnector.MySqlConnectionStringBuilder.GetProperties(Hashtable)' which requires unreferenced code. PropertyDescriptor's PropertyType cannot be statically discovered. 

This came up in microsoft/mcp#1112.

dotnet/runtime#121718 describes the root cause for this warning. For now the best fix is to suppress the IL2112 on MySqlConnectionStringBuilder.GetProperties.

This should have been caught when adding the native aot test app. The test app should follow the recommendations in https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming#show-all-warnings-with-test-app and set TrimmerRootAssembly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions