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

Implement an AppContext compatibility switch re-enabling reflection fallback in STJ source generators. #75694

Conversation

eiriktsarpalis
Copy link
Member

Backport of #75615 to release/7.0-rc2.

Customer Impact

.NET 7 introduced an intentional breaking change which removes silent fallback to reflection-based serialization in System.Text.Json source generators. Based on early feedback we have been receiving from customers and partner teams, it appears that quite a few users have (mostly accidentally) taken a dependency on the fallback behavior (see dotnet/aspnetcore#43894, dotnet/aspnetcore#43236 for a few examples).

Even though a workaround for the breaking change has been documented, it still requires a code change which might not be possible in certain scenaria. This PR introduces an AppContext compatibility switch (named System.Text.Json.Serialization.EnableSourceGenReflectionFallback) that brings back the reflection fallback logic for source generators.

Testing

Added unit tests validating behavior with the compatibility switch enabled.

Risk

Low. Makes minimal adaptations to product code that only kicks in when the switch is enabled.

…allback in STJ source generators. (dotnet#75615)

* Implement an AppContext compatibility switch re-enabling reflection fallback in sourcegen.

* address feedback
@ghost
Copy link

ghost commented Sep 15, 2022

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

Issue Details

Backport of #75615 to release/7.0-rc2.

Customer Impact

.NET 7 introduced an intentional breaking change which removes silent fallback to reflection-based serialization in System.Text.Json source generators. Based on early feedback we have been receiving from customers and partner teams, it appears that quite a few users have (mostly accidentally) taken a dependency on the fallback behavior (see dotnet/aspnetcore#43894, dotnet/aspnetcore#43236 for a few examples).

Even though a workaround for the breaking change has been documented, it still requires a code change which might not be possible in certain scenaria. This PR introduces an AppContext compatibility switch (named System.Text.Json.Serialization.EnableSourceGenReflectionFallback) that brings back the reflection fallback logic for source generators.

Testing

Added unit tests validating behavior with the compatibility switch enabled.

Risk

Low. Makes minimal adaptations to product code that only kicks in when the switch is enabled.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@teo-tsirpanis teo-tsirpanis added this to the 7.0.0 milestone Sep 15, 2022
@eiriktsarpalis eiriktsarpalis added the Servicing-consider Issue for next servicing release review label Sep 15, 2022
@eiriktsarpalis
Copy link
Member Author

PR has been approved by tactics.

@eiriktsarpalis eiriktsarpalis added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 16, 2022
@carlossanlop
Copy link
Member

Approved, signed off, CI green. Ready to merge. :shipit:

@carlossanlop carlossanlop merged commit f0eb5ce into dotnet:release/7.0-rc2 Sep 16, 2022
@eiriktsarpalis eiriktsarpalis deleted the backport-appcontext-reflection-fallback branch September 16, 2022 18:09
@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants