Skip to content
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

Fix #3173 trim warning for Constant Class #3466

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented Sep 4, 2024

Description

ConstantClass's Intern method is not trim compatible because we cannot guarantee that the object returned by GetType() will have its public fields untrimmed, which LoadFields expects. Since we cannot directly annotate System.GetType(), we have to apply the DynamicallyAccessedMembers attribute to ConstantClass itself to guarantee that LoadFields will receive an object with its public fields untrimmed.

Motivation and Context

Fixes #3173.

Testing

DRY_RUN successful
I created a simple console app with trimming enable and then ran dotnet publish --sc -f net8.0 and the warning went away.

using Amazon;
using Amazon.SimpleSystemsManagement;
using Amazon.SimpleSystemsManagement.Model;

using (var simpleSystemsManagementClient = new AmazonSimpleSystemsManagementClient(RegionEndpoint.USWest2))
{
    var putResponse = await simpleSystemsManagementClient.PutParameterAsync(new PutParameterRequest()
    {
        Name = "something",
        Value = "something",
        Type = ParameterType.String,
        Overwrite = true,
    }).ConfigureAwait(false);
    var getParameterRequest = new GetParameterRequest()
    {
        Name = "something",
        WithDecryption = true,
    };
    var getParameterResponse = await simpleSystemsManagementClient.GetParameterAsync(getParameterRequest).ConfigureAwait(false);
}

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@peterrsongg peterrsongg changed the base branch from main to main-staging September 4, 2024 23:08
@peterrsongg peterrsongg merged commit 0565c12 into main-staging Sep 5, 2024
2 of 7 checks passed
@dscpinheiro dscpinheiro deleted the petesong/git-3173 branch September 10, 2024 22:40
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.

Native AoT warning from AWSSDK.Core
3 participants