Skip to content

Commit

Permalink
Update Marshal.QueryInterface() argument modifier (#91984)
Browse files Browse the repository at this point in the history
Change "in" modifier to "ref readonly" to avoid warnings
in existing interop code.

Co-authored-by: Aaron R Robinson <[email protected]>
Co-authored-by: Carlos Sánchez López <[email protected]>
  • Loading branch information
3 people authored Sep 14, 2023
1 parent 834593b commit 8ed11a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static int SizeOf<T>()
return SizeOfHelper(t, throwIfNotMarshalable: true);
}

public static unsafe int QueryInterface(IntPtr pUnk, in Guid iid, out IntPtr ppv)
public static unsafe int QueryInterface(IntPtr pUnk, ref readonly Guid iid, out IntPtr ppv)
{
ArgumentNullException.ThrowIfNull(pUnk);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ public static void PtrToStructure(System.IntPtr ptr, object structure) { }
public static object? PtrToStructure(System.IntPtr ptr, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors| System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type structureType) { throw null; }
public static T? PtrToStructure<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]T>(System.IntPtr ptr) { throw null; }
public static void PtrToStructure<T>(System.IntPtr ptr, [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T structure) { }
public static int QueryInterface(System.IntPtr pUnk, in System.Guid iid, out System.IntPtr ppv) { throw null; }
public static int QueryInterface(System.IntPtr pUnk, ref readonly System.Guid iid, out System.IntPtr ppv) { throw null; }
public static byte ReadByte(System.IntPtr ptr) { throw null; }
public static byte ReadByte(System.IntPtr ptr, int ofs) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the object might not be available")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public unsafe interface IIUnknownStrategy
/// <param name="iid">The IID (Interface ID) to query for.</param>
/// <param name="ppObj">The resulting interface.</param>
/// <returns>Returns an HRESULT represents the success of the operation.</returns>
/// <seealso cref="Marshal.QueryInterface(nint, in Guid, out nint)"/>
/// <seealso cref="Marshal.QueryInterface(nint, ref readonly Guid, out nint)"/>
public int QueryInterface(void* instancePtr, in Guid iid, out void* ppObj);

/// <summary>
Expand Down

0 comments on commit 8ed11a2

Please sign in to comment.