dotnet / dotnet/wpf

`System.Text.Json` SG is run twice in WPF projects

Open
#10,175 6 comments 0 reactions 1 assignee Claimed by @Kuldeep-MS View on GitHub
Investigate regression
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Similar to https://github.com/dotnet/extensions/issues/4969, the SG is included twice in a compilation, resulting in duplicate definition errors and build failure due to the way WPF is built, involving a temporary project.

### Reproduction Steps

* Start a new WPF project.
* Create a SG-enabled JSON serialization context, the target type and options do not matter, it should just be minimally functional.
* Try to build. The Output pane lists the errors twice, once for the temporary project and once, verbatim, for the actual one.

### Expected behavior

SG is included only once.

### Actual behavior

SG is included twice and prevents the build from finishing successfully.

### Regression?

I can't say, sorry. There was one other issue previously but because of two SGs being active at once.

### Known Workarounds

I can't say, unless switching back to reflection is considered one.

### Configuration

I target `net9-windows` on Windows 10 x64. It shouldn't be specific to that configuration but I don't know for sure.

### Other information

AS I said already, it shows up twice in output, once per each project in the compilation, even though IMO the temp. WPF project shouldn't run the JSON SG at all, so preventing it from running in either when building a WPF application should fix the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.