Skip to content

Use trim-safe reflection patterns for runtime dependency resolution, and deprecate GlobalRuntimeDependencyRegistry. #4354

@teo-tsirpanis

Description

@teo-tsirpanis

Describe the feature

When an AWS SDK library has a dependency to another one, it resolves it either by using the GlobalRuntimeDependencyRegistry class, or by performing some reflection. The former method exists because the reflection employed is not compatible with trimming or Native AOT.

However, it is possible to use trim-friendly reflection patterns (centered arround passing a string literal to Type.GetType(string)), and eliminate the need for GlobalRuntimeDependencyRegistry.

Use Case

  • Reduce barriers of using the AWS SDK with trimming or Native AOT.
  • Increase reliability and trim-safety, by reducing the amount of UnconditionalSuppressMessageAttribute uses.
  • Simplify the codebase.

Proposed Solution

  • Add new overloads to ServiceClientHelpers methods, that accept a single string parameter with the type's assembly-qualified name (e.g. Amazon.SecurityToken.AmazonSecurityTokenServiceClient, Amazon.SecurityToken), and appropriately annotate them so that the trimmer keeps these types.
    • Update code to use these overloads.
    • Remove [UnconditionalSuppressMessage] where no longer necessary.
  • Obsolete all methods of GlobalRuntimeDependencyRegistry, suggesting that they are no longer necessary to call, and guide users to just reference the respective NuGet package.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

AWSSDK.Core V4
AWSSDK.DynamoDBv2 V4 (for its S3 Link feature)

Targeted .NET Platform

All supported frameworks, particularly modern .NET with trimming or NativeAOT

Operating System and version

All supported operating systems

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions