Improve start-up time by not figuring out NetFX version for AppContext switches #9711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
All WPF apps will spend now spend considerable time on startup evaluating whether they're running on NetFX or not by initializing
AppContextDefaultValues
in each assembly (PresentationCore
/PresentationFramework
/WindowsBase
), queryingTargetFrameworkName
property via reflection on AppDomain/AppContext (depends which runtime, one forwards the other).The only place where the check makes sense is in
PresentationBuildTasks
on net472, which can be easily opted-in by using a preprocessor macro, rest of the assemblies do not need it and can confidently init as.NETCoreApp
, version doesn't matter.PBT
onnet472
via preprocessor condition and omit it from core buildsTargetFrameworkName
via reflection on any target framework anymoreWhile I could have removed the cases in core libraries for NetFX, I presume we can do it in a different PR that cleans-up the whole logic for all of them, this is supposed to be neat and clean in-place solution.
Customer Impact
Improved start-up time, decreased start-up allocations.
Regression
No.
Testing
Local build.
Risk
Low, this merely removes basically dead code on core libraries.
Microsoft Reviewers: Open in CodeFlow