Skip to content

The generated content of GeneratedInternalTypeHelper.g.cs is not stable #2690

@tmat

Description

@tmat

Problem description:

Since switching WPF projects in Roslyn repo to Microsoft.NET.Sdk.WindowsDesktop the design time build is failing intermittently.

image

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.

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions