-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Definition for SDK projection / object model #40121
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
base: feature/wsl-for-apps
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,348 @@ | ||||||||||||||||||||||||||||||||||||
| /*++ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Copyright (c) Microsoft. All rights reserved. | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Module Name: | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| wslcsdk.idl | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Abstract: | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| This file contains the public WSL Container SDK api definitions. | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| --*/ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| namespace Microsoft.WSL.Containers | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| [flags] | ||||||||||||||||||||||||||||||||||||
| enum SessionFeatureFlags | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| None = 0x00000000, | ||||||||||||||||||||||||||||||||||||
| EnableGpu = 0x00000004 | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| enum SessionTerminationReason | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| Unknown = 0, | ||||||||||||||||||||||||||||||||||||
| Shutdown = 1, | ||||||||||||||||||||||||||||||||||||
| Crashed = 2, | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| delegate void SessionTerminationHandler(Session session, SessionTerminationReason reason); | ||||||||||||||||||||||||||||||||||||
|
florelis marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| runtimeclass SessionSettings | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| SessionSettings(String name, String storagePath); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| String Name { get; }; | ||||||||||||||||||||||||||||||||||||
| String StoragePath { get; }; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| UInt32 CpuCount { get; set; }; | ||||||||||||||||||||||||||||||||||||
| UInt32 MemoryMb { get; set; }; | ||||||||||||||||||||||||||||||||||||
| UInt32 TimeoutMS { get; set; }; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| UInt32 TimeoutMS { get; set; }; | |
| UInt32 TimeoutMs { get; set; }; |
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.
The C API uses a HANDLE for the image content. I changed it to a stream based on what I understood from how it's used, but I may be wrong.
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.
I don't think we can easily do that unfortunately, since the actual implementation of this API will have no way to "transform" a stream back to a handle to give it to the service
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.
I see. For now I'll assume we're okay if the method looks like void ImportImage(T image, ImportImageOptions options), possibly with multiple overloads, and try to find types that better map to each type of handle once I'm looking at the actual implementation.
Copilot
AI
Apr 7, 2026
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.
ImportImage only takes an IInputStream, but the underlying WSLC APIs require a content length (COM IWSLCSession::ImportImage takes ContentLength). IInputStream doesn’t reliably expose length, so implementations may be forced to buffer the entire stream. Consider using a size-bearing WinRT type (e.g., IRandomAccessStream/IRandomAccessStreamReference) or add an explicit UInt64 contentLength parameter.
| void ImportImage(String imageName, Windows.Storage.Streams.IInputStream imageStream, ImportImageOptions options); | |
| void ImportImage(String imageName, Windows.Storage.Streams.IInputStream imageStream, UInt64 contentLength, ImportImageOptions options); |
Copilot
AI
Apr 7, 2026
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.
LoadImage only takes an IInputStream, but the underlying WSLC APIs require a content length (COM IWSLCSession::LoadImage takes ContentLength). IInputStream doesn’t reliably expose length, so implementations may be forced to buffer the entire stream. Consider using a size-bearing WinRT type (e.g., IRandomAccessStream/IRandomAccessStreamReference) or add an explicit UInt64 contentLength parameter.
| void LoadImage(Windows.Storage.Streams.IInputStream imageStream, LoadImageOptions options); | |
| void LoadImage(Windows.Storage.Streams.IInputStream imageStream, UInt64 contentLength, LoadImageOptions options); |
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.
This one I didn't know how to map, so I left it as a TODO for now.
Copilot
AI
Apr 7, 2026
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.
The API exposes both callback-style process I/O (ProcessSettings.EventHandlers) and stream-style I/O (Process.GetOutputStream/GetInputStream). In the existing C SDK these are mutually exclusive (callbacks consume the stdio handles), so the WinRT surface should either enforce the same exclusivity (fail fast if streams are requested when handlers are set) or clearly document which takes precedence to avoid surprising runtime failures.
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.
In this direction I think returning a stream is the right thing to do for C#, but doing so will prevent the caller from doing asynchronous IO on stdout & stderr.
I'm not sure that there's an easy way to represent this in C#, but maybe what we could do could be to return a subclass of IInputStream that has a "GetHandle()" method to get the best of both worlds
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.
Why would it prevent the caller from doing asynchronous IO? Whether this ends up being a C# Stream or a WinRT IInputStream, it will have a ReadyAsync() method. Are you thinking of IStream?
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.
I did a bit of research on this, and it's looking like ReadyAsync() specifically handles overlapped IO, which is what we use, so I think this should work, although this is definitely something that we should test
Copilot
AI
Apr 7, 2026
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.
The comments indicate these methods project to System.IO.Stream, but the WinRT signatures return IInputStream/IOutputStream. Unless your projection layer adds custom adapters, CsWinRT will surface WinRT stream interfaces here, so the comment may be inaccurate. Consider clarifying in the comment how .NET callers should obtain a Stream (or adjust the API surface accordingly).
| // C# type: System.IO.Stream | |
| Windows.Storage.Streams.IInputStream GetOutputStream(ProcessOutputHandle ioHandle); | |
| // C# type: System.IO.Stream | |
| // C# projected type: Windows.Storage.Streams.IInputStream | |
| // .NET callers can adapt this to System.IO.Stream using the standard WinRT stream extension methods if needed. | |
| Windows.Storage.Streams.IInputStream GetOutputStream(ProcessOutputHandle ioHandle); | |
| // C# projected type: Windows.Storage.Streams.IOutputStream | |
| // .NET callers can adapt this to System.IO.Stream using the standard WinRT stream extension methods if needed. |
Copilot
AI
Apr 7, 2026
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.
GetOutputStream returns an IInputStream (read end) and GetInputStream returns an IOutputStream (write end). The names are easy to misread as “stream you write output to” vs “stream you read input from”. Consider renaming to make direction explicit (e.g., GetStdOutStream/GetStdErrStream/GetStdInStream) so callers don’t accidentally invert read/write usage.
| Windows.Storage.Streams.IInputStream GetOutputStream(ProcessOutputHandle ioHandle); | |
| // C# type: System.IO.Stream | |
| Windows.Storage.Streams.IOutputStream GetInputStream(); | |
| Windows.Storage.Streams.IInputStream GetStandardIoOutputReader(ProcessOutputHandle ioHandle); | |
| // C# type: System.IO.Stream | |
| Windows.Storage.Streams.IOutputStream GetStandardInputWriter(); |
Copilot
AI
Apr 7, 2026
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.
RegistryAuthenticationInformation currently exposes a Placeholder property. If this IDL is intended to be a public SDK surface, shipping a placeholder member is likely to become a breaking-change trap when real auth fields are introduced. Consider either omitting AuthInfo until the shape is defined, or defining a minimal but real contract (e.g., auth scheme + token/username/password) now.
| runtimeclass RegistryAuthenticationInformation | |
| { | |
| // TBD | |
| String Placeholder {get; set;}; | |
| enum RegistryAuthenticationScheme | |
| { | |
| None = 0, | |
| Basic = 1, | |
| BearerToken = 2, | |
| }; | |
| runtimeclass RegistryAuthenticationInformation | |
| { | |
| RegistryAuthenticationScheme Scheme { get; set; }; | |
| String Username { get; set; }; | |
| String Password { get; set; }; | |
| String Token { get; set; }; |
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.
Header comment has
Module Name: wslcsdk.idl, but the file iswslcsdk-winrt.idl. Consider updating the module name to match the actual filename to avoid confusion when this is referenced in build/scripts.