Skip to content
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

Introduce SwiftSelf<T> and SwiftIndirectResult structs #102717

Merged
merged 6 commits into from
Jun 7, 2024

Conversation

kotlarmilos
Copy link
Member

Description

This PR introduces SwiftSelf<T> and SwiftIndirectResult structs to facilitate interop with Swift structs. Runtime support along with the corresponding test cases (#102079 and #102082) will be added in subsequent PRs.

The idea is to keep both SwiftSelf and SwiftSelf<T> for now, as SwiftSelf will be utilized for class support and closure context.

Fixes #100543

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

…pServices/Swift/SwiftTypes.cs

Co-authored-by: Matous Kozak <55735845+matouskozak@users.noreply.github.com>
kotlarmilos and others added 2 commits May 29, 2024 09:15
…pServices/Swift/SwiftTypes.cs

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
…pServices/Swift/SwiftTypes.cs

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
@@ -13904,6 +13904,19 @@ namespace System.Runtime.InteropServices.Swift
public unsafe SwiftSelf(void* value) { throw null; }
public unsafe void* Value { get { throw null; } }
}
public readonly partial struct SwiftSelf<T> where T: unmanaged
{
private readonly int _dummyPrimitive;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private readonly int _dummyPrimitive;
private readonly T _dummyPrimitive;

Using T here allows the C# compiler to detect infinite generic expansion at build time.

@kotlarmilos kotlarmilos merged commit ab604e9 into dotnet:main Jun 7, 2024
142 of 146 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce SwiftSelf<T> and SwiftIndirectResult to represent Swift structs and enums in C#
5 participants