Fix NETStandard library using JSON source gen (#63520)
authorEric StJohn <ericstj@microsoft.com>
Mon, 10 Jan 2022 22:35:08 +0000 (14:35 -0800)
committerGitHub <noreply@github.com>
Mon, 10 Jan 2022 22:35:08 +0000 (14:35 -0800)
commit7a2649268835f73396748267fed4320a10d9f61f
tree17482f92e90ac8516c7721ad896255e4ffee9b8c
parent749c02bbfbd75b642da072807978b0c1aee1b321
Fix NETStandard library using JSON source gen (#63520)

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.
12 files changed:
src/libraries/System.Text.Json/ref/System.Text.Json.Typeforwards.netcoreapp.cs [new file with mode: 0644]
src/libraries/System.Text.Json/ref/System.Text.Json.csproj
src/libraries/System.Text.Json/src/System.Text.Json.Typeforwards.netcoreapp.cs [new file with mode: 0644]
src/libraries/System.Text.Json/src/System.Text.Json.csproj
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.TestLibrary/System.Text.Json.TestLibrary.Roslyn3.11.csproj [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.TestLibrary/System.Text.Json.TestLibrary.Roslyn4.0.csproj [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.TestLibrary/System.Text.Json.TestLibrary.targets [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.TestLibrary/TestClasses.cs [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/NETStandardContextTests.cs [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn4.0.Tests.csproj
src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets