-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Remove explicit WinRT initialization/uninitialization #122940
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
Conversation
- Remove TSNC_WinRTInitialized flag from threads.h - Remove IsWinRTInitialized() and ResetWinRTInitialized() methods - Remove BaseWinRTUninitialize() method declaration and implementation - Remove all RoInitialize/RoUninitialize calls from CoreCLR - Remove ENABLE_WINRT conditional compilation from NativeAOT - Remove RuntimeObject.lib from all CMakeLists.txt files Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
@copilot FIx build break D:\a_work\1\s\src\coreclr\vm\threads.cpp(3724): error C3861: 'IsWinRTInitialized': identifier not found |
Removed the remaining reference to IsWinRTInitialized() at line 3724 in threads.cpp that was causing the build break. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Removed redundant IsCoInitialized() checks that were performed both before and inside the conditional blocks. Applied the same simplification in three locations in threads.cpp as requested in code review. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
Tagging subscribers to this area: @dotnet/interop-contrib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes redundant WinRT-specific initialization code from the runtime, consolidating all COM/WinRT interop to use standard COM initialization via CoInitializeEx/CoUninitialize.
Key Changes:
- Removed
TSNC_WinRTInitializedthread state flag and all WinRT-specific initialization/cleanup methods from CoreCLR - Eliminated
ENABLE_WINRTconditional compilation from NativeAOT, standardizing onCoInitializeEx - Removed
RuntimeObject.libdependency from all build configurations
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/threads.h | Removed TSNC_WinRTInitialized flag and WinRT-specific methods (IsWinRTInitialized, ResetWinRTInitialized, BaseWinRTUninitialize) |
| src/coreclr/vm/threads.cpp | Removed BaseWinRTUninitialize() implementation and all RoInitialize/RoUninitialize calls; simplified COM cleanup logic by removing redundant checks in CoUninitialize(), CleanupCOMState(), and SetApartment() |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs | Removed ENABLE_WINRT conditionals, now always using CoInitializeEx/CoUninitialize instead of RoInitialize/RoUninitialize |
| src/native/corehost/apphost/static/CMakeLists.txt | Removed RuntimeObject.lib linking dependency |
| src/coreclr/jit/CMakeLists.txt | Removed RuntimeObject.lib linking dependency |
| src/coreclr/ildasm/exe/CMakeLists.txt | Removed RuntimeObject.lib linking dependency |
| src/coreclr/ilasm/CMakeLists.txt | Removed RuntimeObject.lib linking dependency |
| src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | Removed RuntimeObject.lib linking dependency |
jkoritzinsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
/ba-g DeadLetter |
Description
Removes redundant WinRT initialization code. Standard COM initialization via
CoInitializeEx/CoUninitializeis sufficient for COM/WinRT interop.Changes:
TSNC_WinRTInitializedthread state flag and associated methods (IsWinRTInitialized,ResetWinRTInitialized,BaseWinRTUninitialize)RoInitialize/RoUninitializecalls from CoreCLR thread apartment setupENABLE_WINRTconditional compilation from NativeAOT - now always usesCoInitializeExRuntimeObject.libdependency from build configurations (no longer needed)IsCoInitialized()checks in three locationsFiles modified:
src/coreclr/vm/threads.{h,cpp}- Thread state and COM initialization cleanupsrc/coreclr/nativeaot/.../Thread.NativeAot.Windows.cs- NativeAOT COM initializationCustomer Impact
None. This is internal runtime cleanup with no customer-facing behavior changes. COM/WinRT interop continues to work through standard COM infrastructure.
Regression
No. This removes code, does not change existing behavior.
Testing
Risk
Low. Changes are deletions of redundant initialization code and simplification of conditional logic. COM initialization remains intact via
CoInitializeEx, which already handles COM/WinRT threading requirements.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.