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

[release/6.0] Fix NETStandard library using JSON source gen #63520

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Jan 7, 2022

Fixes #61737

Customer Impact

Customers cannot use JSON source generators defined in a netstandard library from a net6.0 app. This will fail with MissingMethodException.

Testing

Added tests to catch this scenario. Tests fail without fix, succeed with. Searched repo for any other instances.

Risk

Very low. We are merely adding a typeforward to System.Text.Json for IsExternalInit.

NETStandard libraries using JSON source gen would fail to load on
.NETCore due to missing IsExternalInit in the assembly.

On .NETCore this is defined, whereas on .NETStandard JSON carries an
internal copy.  The compiler emits references to the internal type when
a NETStandard library calls init-only setters in JSON types, but these
references are not satisfied when the library runs on .NETCore.

Fix this by adding a type forward to JSON for the IsExternalInit type.
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Jan 7, 2022

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

Issue Details

Fixes #61737

Customer Impact

Customers cannot use JSON source generators defined in a netstandard library from a net6.0 app. This will fail with MissingMethodException.

Testing

Added tests to catch this scenario. Tests fail without fix, succeed with. Searched repo for any other instances.

Risk

Very low. We are merely adding a typeforward to System.Text.Json for IsExternalInit.

Author: ericstj
Assignees: -
Labels:

area-System.Text.Json, new-api-needs-documentation

Milestone: -

@ericstj
Copy link
Member Author

ericstj commented Jan 10, 2022

Approved over email

@terrajobst
Copy link
Member

I don't understand what the issue is? I thought the compiler doesn't care about the type identity of the attribute, only about the name of the applied attribute. What causes this to be an issue during reflection?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants