-
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 1 commit
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); | ||||||||||||||||||||||||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed "Callback" to "Handler" because I think that's more idiomatic in C# |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| 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
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); |
florelis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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); |
florelis marked this conversation as resolved.
Show resolved
Hide resolved
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.
florelis marked this conversation as resolved.
Show resolved
Hide resolved
florelis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
florelis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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.
C# equivalent type: What we could use if we define it in C# directly.
C# projected type: What we would get if we use CsWinRT to get a projection from the .idl.
florelis marked this conversation as resolved.
Show resolved
Hide resolved
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 is an array of strings in the C API. I changed it to match the C# Process type.
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.
florelis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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
Outdated
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.
These are a single function in the C API. For WinRT there is no generic Stream type that can do both AFAICT, but if we do direct C# implementation it can be a System.IO.Stream and a single function to match.
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.