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

Add new API docs for System.Runtime.InteropServices #106208

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public void FromUnmanaged(TUnmanagedElement* unmanaged)
/// <summary>
/// Returns the managed value representing the native array.
/// </summary>
/// <returns>A span over managed values of the array.</returns>
public ReadOnlySpan<T> ToManaged()
{
return new ReadOnlySpan<T>(_managedValues!);
Expand All @@ -196,6 +197,7 @@ public ReadOnlySpan<T> ToManaged()
/// <summary>
/// Returns a span that points to the memory where the unmanaged elements of the array are stored.
/// </summary>
/// <param name="numElements">The number of elements in the array.</param>
/// <returns>A span over unmanaged values of the array.</returns>
public ReadOnlySpan<TUnmanagedElement> GetUnmanagedValuesSource(int numElements)
{
Expand All @@ -205,6 +207,7 @@ public ReadOnlySpan<TUnmanagedElement> GetUnmanagedValuesSource(int numElements)
/// <summary>
/// Returns a span that points to the memory where the managed elements of the array should be stored.
/// </summary>
/// <param name="numElements">The number of elements in the array.</param>
/// <returns>A span where managed values of the array should be stored.</returns>
public Span<T> GetManagedValuesDestination(int numElements)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SwiftSelf(void* value)
/// Represents the Swift 'self' context when the argument is Swift frozen struct T, which is either enregistered into multiple registers,
/// or passed by reference in the 'self' register.
/// </summary>
/// <typeparam name="T">The type of the frozen struct to pass in the 'self' context.</typeparam>
/// <remarks>
/// <para>
/// This struct is used to pass the Swift frozen struct T to Swift functions in the context of interop with .NET.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public static partial class ComVariantMarshaller
// VARIANT_BOOL constants.
private const short VARIANT_TRUE = -1;
private const short VARIANT_FALSE = 0;

/// <summary>
/// Converts a managed object to an unmanaged <see cref="ComVariant"/>.
/// </summary>
/// <param name="managed">The managed object.</param>
/// <returns>A <see cref="ComVariant" /> that represents the provided managed object.</returns>
/// <exception cref="ArgumentException">The type of <paramref name="managed"/> is not supported.</exception>
public static ComVariant ConvertToUnmanaged(object? managed)
{
if (managed is null)
Expand Down Expand Up @@ -103,6 +110,12 @@ private static unsafe bool TryCreateOleVariantForInterfaceWrapper(object managed
}
#pragma warning restore CA1416 // Validate platform compatibility

/// <summary>
/// Converts an unmanaged <see cref="ComVariant"/> to a managed object.
/// </summary>
/// <param name="unmanaged">The unmanaged variant.</param>
/// <returns>A managed object that represents the same value as <paramref name="unmanaged"/>.</returns>
/// <exception cref="ArgumentException">The type of data stored in <paramref name="unmanaged"/> is not supported.</exception>
public static unsafe object? ConvertToManaged(ComVariant unmanaged)
{
#pragma warning disable CS0618 // Type or member is obsolete
Expand Down Expand Up @@ -195,6 +208,10 @@ private static unsafe bool TryCreateOleVariantForInterfaceWrapper(object managed
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
/// Disposes the unmanaged <see cref="ComVariant"/>.
/// </summary>
/// <param name="unmanaged">The object to dispose.</param>
public static void Free(ComVariant unmanaged) => unmanaged.Dispose();

/// <summary>
Expand Down
Loading