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
Native AoT warning from AWSSDK.Core #3173
Comments
Odd that didn't show before. I'll take a look to see what is going on. |
Also getting this issue with AWSSDK.Core 3.7.302.20 targeting linux-x64 (building from macOS-x64) I was originally getting
but then adding
I can make a full reproduciton of library and show my testing if needed. My library targets just net8.0 and I am using the following AWS nugets:
Doing a brute force of removing nugets (and erroring code) I can narrow it down to using Within my code itself I was able to narrow it down to these lines var simpleSystemsManagementClient = new AmazonSimpleSystemsManagementClient(RegionEndpoint.APSoutheast2);
var getParameterRequest = new GetParameterRequest()
{
Name = "some/thing",
WithDecryption = true,
};
var getParameterResponse = await simpleSystemsManagementClient.GetParameterAsync(getParameterRequest); If I remove the call to I also added Console.WriteLine(simpleSystemsManagementClient);
Console.WriteLine(getParameterRequest); assuming I was linking away the problem from unused code. I've seen that we should not be using <?xml version="1.0" encoding="utf-8"?>
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="AWSSDK.Core" Dynamic="Required All"></Assembly>
<Assembly Name="AWSSDK.SecretsManager" Dynamic="Required All"></Assembly>
<Assembly Name="AWSSDK.SecurityToken" Dynamic="Required All"></Assembly>
<Assembly Name="AWSSDK.SimpleSystemsManagement" Dynamic="Required All"></Assembly>
<Assembly Name="Amazon.Lambda.Core" Dynamic="Required All"></Assembly>
</Application>
</Directives> Elsewhere I've seen that using From that above link I followed through to the benchmarking samples which have us adding
I am not entierly sure what I am meant to do (or if I can even do anything) to avoid this, or if I am just meant to test test test and ignore the warning for now. |
Describe the bug
Doing some testing on an application to see what changes need making for it to be published using native AoT, I observed the following warning during
dotnet publish
:C:\codebuild\tmp\output\src3970990199\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\ConstantClass.cs(84): Trim analysis warning IL2072: Amazon.Runtime.ConstantClass.Intern(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields' in call to 'Amazon.Runtime.ConstantClass.LoadFields(Type)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
Expected Behavior
No trim warnings are emitted from trim analysis of the AWSSDK.Core assembly.
Current Behavior
An IL2072 warning is emitted due to the use of
this.GetType()
here:aws-sdk-net/sdk/src/Core/Amazon.Runtime/ConstantClass.cs
Line 84 in 4aa0c67
Reproduction Steps
I'm not sure what specifically my application does that triggers this code path, but you can see by tracing the code that the caller does not provide the guarantees required of the
LoadFields()
method.Possible Solution
Annotate/suppress the code as-appropriate to safely resolve the warning and have the code work as expected at runtime in an application compiled for native AoT.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.Core 3.7.302.6
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered: