Skip to content

Mark project as not Native AoT readyΒ #173

@boarnoah

Description

@boarnoah

Describe the bug

With #168 there was bump for AWSSDK.Extensions.NETCore.Setup from 3.7.1 (2021) to 3.7.300 (2023).

In the interim AWSSDK.Extensions.NETCore.Setup has been marked not trimming safe for Native AoT (aws/aws-sdk-net#3044) with .NET 8.

I think that means, Amazon.Extensions.Configuration.SystemsManager should also be marked not trimming friendly for Native AoT now? Since with .NET 7.0 on-wards IIUC libraries need to opt out of trimming support.

Since there are now trimming warnings when including this package in a NativeAoT application + runtime errors.

Expected Behavior

Amazon.Extensions.Configuration.SystemsManager should not be trimmed since it doesn't support trimming

Current Behavior

Build succeeds with trim warnings,
With package 6.1.0+:

    <PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="6.2.0" />

we now get trim warnings on a successful build:

warning IL2104: Assembly 'Amazon.Extensions.Configuration.SystemsManager' produced trim warnings.

here is the same warning with <TrimmerSingleWarn>false</TrimmerSingleWarn>:

ILC : Trim analysis warning IL2026: Amazon.Extensions.Configuration.SystemsManager.Internal.AwsOptionsProvider.GetAwsOptions(IConfigurationBuilder): Using member 'Microsoft.Extensions.Configuration.ConfigurationExtensions.GetAWSOptions(IConfiguration)' which has 'RequiresUnrefer
encedCodeAttribute' can break functionality when trimming application code. The AWSSDK.Extensions.NETCore.Setup package has not been updated to support Native AOT compilations.

There is runtime errors in the application as a result ex:

System.NullReferenceException: Object reference not set to an instance of an object.\n at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateConfig(Type, AWSOptions) + 0x8a\n at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateServiceClient(ILogger, Type, AWSOptions) + 0x8f\n at Amazon.Extensions.NETCore.Setup.AWSOptions.CreateServiceClient[T]() + 0x2c\n at Amazon.Extensions.Configuration.SystemsManager.Internal.SystemsManagerProcessor.<GetParametersByPathAsync>d__6.MoveNex

Reproduction Steps

Sorry, setting a Native AoT project is a little involved, I can cook up a PoC if its really needed.

  1. Include Amazon.Extensions.Configuration.SystemsManager > 6.1.0 in project
  2. Setup project for Native AoT build
  3. Notice null reference exceptions w/ the package

Possible Solution

I believe we can mark the project with:

<IsAotCompatible>false</IsAotCompatible>

https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net8plus#aot-compatibility-analyzers

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Extensions.Configuration.SystemsManager 6.1.0+

Targeted .NET Platform

.NET 8

Operating System and version

AmazonLinux, scratch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions