Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve start-up time by not figuring out NetFX version for AppContext switches #9711

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Contributor

@h3xds1nz h3xds1nz commented Sep 4, 2024

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), querying TargetFrameworkName 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.

  • We can keep the current code for PBT on net472 via preprocessor condition and omit it from core builds
  • We do not need to retrieve TargetFrameworkName via reflection on any target framework anymore

While 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

@h3xds1nz h3xds1nz requested review from a team as code owners September 4, 2024 17:46
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant