dotnet / dotnet/wpf

MarkupCompilePass2 shouldn't zero GeneratedInternalTypeHelper.g.cs

Open
#2,281 4 comments 1 reaction 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

This is for .NET Framework but it looks like it might be a problem for .NET Core as well.

Sometimes (and under circumstances unclear to me) MarkupCompilePass2 decides that the internal type helper is not necessary and it zeroes out the file:

https://github.com/dotnet/wpf/blob/1570c84797250fcb0efa1f00d4d7c14c694a6213/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs#L663-L687

From what I can see this is a race condition with MarkupCompilePass1 and/or design-time builds which write into the file.

The problem is that the presence or absence of the `GeneratedInternalTypeHelper` class in the assembly changes its public API. In scenarios where reference assemblies are used for better incremental builds (by setting `ProduceReferenceAssembly` property to `true`) this public API change results in a different reference assembly, thus invalidating the entire dependency tree and causing all dependent projects to rebuild unnecessarily.

I'm not entirely certain whether this generated type is really required and when it is actually used, and why is it generated in the first place (nothing in the file looks like it couldn't be in a framework type). But if we are generating it, we should always be generating it deterministically, such that the public API surface doesn't flip flop between having this type and not having it.

See related:
https://github.com/microsoft/msbuild/issues/4217

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.