MarkupCompilePass2 shouldn't zero GeneratedInternalTypeHelper.g.cs
- 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
Assessment
This issue has not been assessed yet.