Skip to content

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.
@ghost
Copy link

ghost commented Jan 7, 2022

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 ghost assigned ericstj Jan 7, 2022
@ericstj ericstj added the Servicing-consider Issue for next servicing release review label Jan 7, 2022
@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
Contributor

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