Add warning about possible trimmed nested types for DataModel #3668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
For the Native AOT support with the Object Persistence Model high level library for DynamoDB we used the
DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)
. That assumed by usingDynamicallyAccessedMemberTypes.All
for the type being used with the library nothing for that type would be trimmed. It is possible for nested types referenced by the type being used with DynamoDB it is possible they could be trimmed. That seems surprising behavior that needs investigating but for the now the work around is for users wanting to use Native AOT and run into this problem is to add the[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(<nested-type>))]
in some method or constructor or code that is for sure not being trimmed.To help users know they need to do this when this situation arises the error message for when we can't instantiate an object has been updated to give them direction on adding the attribute.
Motivation and Context
#3646
Testing
Since the problem only happens with Native AOT I relied on manually testing. I recreated the problem by deploying a Lambda function using Native AOT and got the expected error message. Then followed the error message's direction of adding the
DynamicDependency
on the constructor of the parent type and redeployed. The redeployed version was successful