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

Referencing System.Text.Json 9.0.0 in a NativeAOT app targeting 8.0, with the 8.0 SDK, results in trim issues #110187

Closed
mmesdag opened this issue Nov 26, 2024 · 2 comments

Comments

@mmesdag
Copy link

mmesdag commented Nov 26, 2024

Description

I have a native AOT project targeting 8.0 that I upgraded System.Text.Json to 9.0.0 in. When this app is published using the 8 sdk, a missing method warning shows up, and the app fails at runtime.

If the app is built using the 9 sdk, or System.Text.Json is not upgraded, there are no warnings, and everything runs as expected.

Is using the updated STJ intended to be supported if you're not using the newest sdk?

Reproduction Steps

  • Create a new project using the web api aot template (dotnet new webapiaot)
  • Make sure you're using the .net 8 SDK (I used global.json)
  • Add the System.Text.Json 9.0.0 nuget package to the project
  • Run dotnet publish

Expected behavior

Publish completes with no missing method warnings

Actual behavior

Warning shown: ILC: Method '[STJIssue]AppJsonSerializerContext.Create_Todo(JsonSerializerOptions)' will always throw because: Missing method 'Void System.Text.Json.Serialization.Metadata.JsonObjectInfoValues1.set_ConstructorAttributeProviderFactory(System.Func1<System.Reflection.ICustomAttributeProvider>)'

Regression?

No response

Known Workarounds

Don't upgrade System.Text.Json to 9.0, or use the 9 sdk

Configuration

Repro is from an arm64 Mac. Issue was first noticed when building in a linux arm64 container

Other information

The app is deployed to AWS Lambda, so unfortunately there is no easy way for me to update the SDK used in the docker image their build tooling uses.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 26, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Nov 26, 2024

Thank you for reporting this issue. It will be fixed in one of upcoming .NET 8 serving updates by #110059.

@jkotas jkotas closed this as completed Nov 26, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants