Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Swift bindings] Add Swift code generation doc #2816
base: feature/swift-bindings
Are you sure you want to change the base?
[Swift bindings] Add Swift code generation doc #2816
Changes from 2 commits
54a3503
cdc50e2
a3e671b
c8e5294
27dfbd1
0c7aa00
3a62e79
fbd1da3
f68084e
0e1e48c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
How can Apple use these in Apple OS APIs when they are unstable?
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.
Referring to runtime-generated features, such as vtable in the case of generics. Additionally, this would require reverse-engineering async and closure contexts.
It's likely we'll encounter cases that are hard to represent directly in C#. Even if we manage to do so, the maintenance cost would be high. Swift wrappers can address this issue by leveraging the Swift compiler/runtime to bridge the gap.
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 do not think "unstable ABI" is the right word to describe this. Unstable ABI is expected to break from version to version. OS APIs that apps depend on cannot have unstable ABI - it holds independent on .NET.
I would call this "ABI details that are too complex to project to .NET". Does this suggestion describe the problem well?
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.
Alternative: "poorly documented ABI details that are too complex to project to .NET".
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.
Yes, sounds good.
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 would expect that async Swift APIs are going to be exposed as async methods in C#.
"Sync-over-async" is a well-known antipattern that results in poor performance. (It is possible that it is not a real problem for the set of Swift APIs that we are looking at the moment.)
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.
We want to offer a solution for async in StoreKit2: https://developer.apple.com/documentation/storekit/product/3851116-products
We would be able to support callconv requirements for the Swift async. I am concerned about the context the layout is unknown/unstable. To resolve this, we could use a think Swift wrapper to represent the context, but project it as
IAsyncStateMachine
in C#.I will explore options and update this proposal accordingly.
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.
We just need to be able to create a C#
Task
on top of the underlying swift. There are many ways to do that on the C# side - we just need to find what we can get from Swift (for example, being able to register a callback which is called when the async operation is finished would be enough to build aTask
out of it on the C# side).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.
It's worth noting that there are very, very few uses of classes in idiomatic Swift (as opposed to Swift written to be compatible with ObjC) and as a result, binding classes can be considered, necessary but a lower priority.
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'm not sure I understand this section's wording. I presume we are talking only about the situations when we project the protocol into c#, and then we create a new type on the c# side which implements the said protocol. And then we:
Do I get this right?
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.
Yes, the text is missing here. Let me update this section.