Skip to content

Commit

Permalink
Fix QueryInterface build break when friendly overloads are turned off
Browse files Browse the repository at this point in the history
Fixes #1332
  • Loading branch information
AArnott committed Jan 22, 2025
1 parent 52767bc commit 0b95dad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
internal unsafe global::Windows.Win32.Foundation.HRESULT QueryInterface<T>(out T* ppv)
where T : unmanaged
{
var hr = this.QueryInterface(typeof(T).GUID, out void* pv);
Guid guid = typeof(T).GUID;
void* pv;
var hr = this.QueryInterface(&guid, &pv);
if (hr.Succeeded)
{
ppv = (T*)pv;
Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.Windows.CsWin32.Tests/COMTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@ a is
}));
}

[Fact]
public void IUnknown_QueryInterfaceGenericHelper()
[Theory, PairwiseData]
public void IUnknown_QueryInterfaceGenericHelper(bool friendlyOverloads)
{
this.generator = this.CreateGenerator(new GeneratorOptions { AllowMarshaling = false });
this.generator = this.CreateGenerator(new GeneratorOptions { AllowMarshaling = false, FriendlyOverloads = new GeneratorOptions.FriendlyOverloadOptions { Enabled = friendlyOverloads } });

this.GenerateApi("IUnknown");
Assert.Contains(this.FindGeneratedMethod("QueryInterface"), m => m.TypeParameterList?.Parameters.Count == 1);
Expand Down

0 comments on commit 0b95dad

Please sign in to comment.