Proposal: Extensibility hooks in generated main #3632
Labels
API suggestion
Early API idea and discussion, it is NOT ready for implementation
Design Discussion
Ongoing discussion about design without consensus
Milestone
Proposal: Extensibility hooks in generated main
Summary
Optionally add hooks in the generated main code for developers to provide code to execute before any WPF code. Bonus points for hooks at the end of the generated main and other useful points for developers to add functionality without manually editing or otherwise hacking generated files in fragile ways.
Rationale
MSIX Dynamic Dependencies supports non-packaged processes using Framework package goods by calling APIs at runtime, accomplishing what packaged apps do via
<PackageDependency>
in theirappxmanifest.xml
. For non-packaged apps to use WPF via a Framework package the app needs to call APIs before accessing WPF.This is currently impossible with WPF's generated main method. There's no opportunity for the developer to provide code to execute before the generated main uses WPF (not without fragile manual editing of the generated main). Per microsoft/WindowsAppSDK#89 (comment)
The generated main should have extensibility hooks, e.g. the generated main has pre() and post() calls to InsertYourCodeHere? Maybe a new main-extensions.cpp is created with a new WPF project with void WpfMainPre() { /insert code here/ } and WpfMainPost() for devs to inject logic into their app's startup flow?
There may be other reasons (e.g. a crash handler).
See Proposal: Extensibility hooks in generated main #3408 for the equivalent ask of XAML.
Scope
Open Questions
Are there other desirable extension points in generated files/code?
The text was updated successfully, but these errors were encountered: