[release/8.0-preview4] Add suppression message to JSON serialization #47910
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.
Backport of #47908 to release/8.0-preview4
/cc @eerhardt
Add suppression message to JSON serialization
Adds trimming and AOT suppressions in the Minimal API source generated code
Description
With the latest aspnetcore and Minimal API Source Generator, Native AOT users are getting a warning coming from generated code:
The issue that this warning is alerting us to is handled through the
JsonSerializer.IsReflectionEnabledByDefault
feature switch and can be suppressed.Customer Impact
With Native AOT (and trimming), the warnings are the main communication to the app developer that their app might not work after publishing. If an app doesn't contain warnings, we guarantee the app will continue to work as it did before publishing.
By always having an errant warning coming from generated code, developers will be confused and think they are doing something wrong. This makes the AOT experience unacceptable. The warnings need to be actionable by the developer.
Regression?
8.0-preview3 didn't have any AOT warnings in the
dotnet new api --aot
template. Without this change, it does now.Risk
The change is just adding a warning suppression to the Minimal API source generated code. There is already the same suppression in another place. Adding it in one more is very unlikely to cause problems.
Verification
Packaging changes reviewed?