The generated content of GeneratedInternalTypeHelper.g.cs is not stable
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
**Problem description:**
Since switching WPF projects in Roslyn repo to Microsoft.NET.Sdk.WindowsDesktop the design time build is failing intermittently.

This is because we use Public API analyzer that checks public API list against a baseline. The public types defined in `GeneratedInternalTypeHelper.g.cs` are not listed in the baseline, but appear sometimes in the build.
I observed that during command line build `GeneratedInternalTypeHelper.g.cs` is created with a declaration of class `GeneratedInternalTypeHelper` and a few moments later it is replaced with an empty file. It seems likely that this sometimes does not happen during design time build.
**Actual behavior:**
Binary log for the design time build here:
`\\mlangfs1\public\jorobich\GenerateInternalTypeHelper`
**Expected behavior:**
The public types are either always generated or never generated.
In addition, I'd expect source file content to not be rewritten during build. An alternative approach to do this is to always generate the code but enclose it in `#if`. Then you can define a conditional compilation symbol and pass it to the compiler depending on whether the type should be active or not.
**Minimal repro:**
This is an intermittent issue happening during work in Roslyn.sln.
Contributor guide
Assessment
This issue has not been assessed yet.