Skip to content

Move the SDK API to its own IDL file#40784

Open
OneBlue wants to merge 6 commits into
masterfrom
user/oneblue/sdk-api
Open

Move the SDK API to its own IDL file#40784
OneBlue wants to merge 6 commits into
masterfrom
user/oneblue/sdk-api

Conversation

@OneBlue

@OneBlue OneBlue commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings June 11, 2026 22:49
Comment thread msipackage/package.wix.in
</RegistryKey>

<!-- IWSLCSDKTerminationCallback-->
<RegistryKey Root="HKCR" Key="Interface\{86A807EA-F2A1-4382-93E5-09FB5F2F4A31}">

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove once #40767 is merged

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the WSLC SDK-facing COM surface by moving it into a separate IDL contract (WSLCCompat.idl) and adds a compatibility layer so the service can continue using wslc.idl internally while the SDK consumes the compat contract.

Changes:

  • Introduces WSLCCompat.idl and wires it into IDL generation + proxy/stub build outputs.
  • Updates the service COM objects (session/container/process/session manager) to also implement IWSLCCompat* interfaces and forward compat calls to existing implementations via conversion helpers.
  • Updates the SDK and tests to use IWSLCCompat* interfaces/types instead of the internal wslc.idl types.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/windows/WslcSdkWinRTTests.cpp Updates tests to obtain an IWSLCSession via QI from the SDK’s compat session.
test/windows/WslcSdkTests.cpp Updates tests to use QI from compat session to the internal session interface for launching.
src/windows/wslcsession/WSLCSession.h Makes WSLCSession implement IWSLCCompatSession and declares forwarding methods.
src/windows/wslcsession/WSLCSession.cpp Adds IWSLCCompatSession forwarding implementations using the compat conversion layer.
src/windows/wslcsession/WSLCProcess.h Makes WSLCProcess implement IWSLCCompatProcess and declares forwarding methods.
src/windows/wslcsession/WSLCProcess.cpp Implements IWSLCCompatProcess forwarding methods.
src/windows/wslcsession/WSLCContainer.h Makes WSLCContainer implement IWSLCCompatContainer and declares forwarding methods.
src/windows/wslcsession/WSLCContainer.cpp Implements IWSLCCompatContainer forwarding methods.
src/windows/WslcSDK/WslcsdkPrivate.h Switches SDK internals to store compat COM interfaces (IWSLCCompat*).
src/windows/WslcSDK/wslcsdk.cpp Updates SDK implementation to use compat types/interfaces and adds handle conversion for compat contract.
src/windows/WslcSDK/TerminationCallback.h Switches termination callback COM interface to compat version.
src/windows/WslcSDK/TerminationCallback.cpp Updates termination callback implementation for compat reason enum.
src/windows/WslcSDK/ProgressCallback.h Switches progress callback COM interface to compat version.
src/windows/WslcSDK/ProgressCallback.cpp Updates progress callback implementation comments to compat interface name.
src/windows/WslcSDK/IOCallback.h Switches IO callback plumbing to use IWSLCCompatProcess and compat handle type.
src/windows/WslcSDK/IOCallback.cpp Updates IO callback implementation to use compat process/handle APIs.
src/windows/WslcSDK/CrashDumpCallback.h Switches crash dump callback COM interface to compat version.
src/windows/WslcSDK/CrashDumpCallback.cpp Updates crash dump callback implementation comments to compat interface name.
src/windows/service/stub/CMakeLists.txt Adds generated compat proxy/stub sources to the stub target.
src/windows/service/inc/WSLCCompat.idl New SDK-facing IDL contract defining IWSLCCompat* interfaces and types.
src/windows/service/inc/wslc.idl Annotates intended usage and adds a coclass decl guard shared with compat IDL.
src/windows/service/inc/CMakeLists.txt Adds WSLCCompat.idl to IDL generation.
src/windows/service/exe/WSLCSessionManager.h Makes WSLCSessionManager implement IWSLCCompatSessionManager and declares forwarding methods.
src/windows/service/exe/WSLCSessionManager.cpp Implements IWSLCCompatSessionManager forwarding using conversion helpers.
src/windows/common/CMakeLists.txt Adds APICompat.{h,cpp} to the common library build.
src/windows/common/APICompat.h Declares conversion helpers and owning conversion wrappers bridging compat <-> internal contracts.
src/windows/common/APICompat.cpp Implements compat <-> internal enum/struct/callback conversions and owning wrapper conversions.
msipackage/package.wix.in Registers the new compat interface IIDs for proxy/stub marshaling.

Comment thread src/windows/common/APICompat.cpp Outdated
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread src/windows/common/APICompat.h

cpp_quote("#ifdef __cplusplus")
cpp_quote("class DECLSPEC_UUID(\"a9b7a1b9-0671-405c-95f1-e0612cb4ce8f\") WSLCSessionManager;")
cpp_quote("class DECLSPEC_UUID(\"9FCD2067-9FC6-4EFA-9EB0-698169EBF7D3\") WSLCSessionFactory;")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the casing here while I was reviewing this

@@ -922,10 +919,8 @@
object

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this method from that interface because it's only useful to the SDK

@OneBlue OneBlue marked this pull request as ready for review June 12, 2026 18:06
@OneBlue OneBlue requested a review from a team as a code owner June 12, 2026 18:06
Copilot AI review requested due to automatic review settings June 12, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/common/APICompat.cpp
@JohnMcPMS

Copy link
Copy Markdown
Member

I don't really understand the rationale here, but my best guess is to create a more obvious "you will be breaking things if you change this" set of interfaces so that you can freely modify the "internal only" interfaces without caring about compat. While this can work, we will need to update the "Compat" layer with new SDK visible items using standard COM versioning practices anyway. So you end up managing two copies of the same interface.

A better layout might be to split out the "unstable" portions into *Internal interfaces. The regular interfaces are fixed on ship as normal for COM, and updated with *2 versions etc. The *Internal can be changed at any time. At least with this pattern you don't have to maintain a stable and unstable version of the SDK facing bits. You could also always have the *Internal interfaces derive from the latest *N so you never have to do more than 1 QI and can pass around internals internally.

@OneBlue

OneBlue commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

A better layout might be to split out the "unstable" portions into *Internal interfaces.

The thinking behind this is to make it easy to update the "internal" version of the COM API, which we'll likely have to change as we add features to wslc.exe (which we expect to require a lot more changes than the SDK API).

And yeah the main objective is to reduce the risk of us incorrectly assuming that a method / structure / flag can be changed without affecting the SDK, while it actually does.

With this design, we know that WSLC.idl is always safe to change, and all changes in WSLSDK.idl require backwards compatible changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants