Skip to content

Commit

Permalink
Add test to verify that a friendly GetObject(SafeHandle) overload i…
Browse files Browse the repository at this point in the history
…s generated.

Regression test for #275. It currently fails.
  • Loading branch information
AArnott committed Jun 16, 2022
1 parent a79abbd commit c79065c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,18 @@ public void ObsoleteAttributePropagated()
Assert.Contains(field!.Value.Field.AttributeLists, al => IsAttributePresent(al, "Obsolete"));
}

[Fact]
public void GetObjectAcceptsSafeHandle()
{
this.generator = new Generator(this.metadataStream, DefaultTestGeneratorOptions, this.compilation, this.parseOptions);
Assert.True(this.generator.TryGenerate("GetObject", CancellationToken.None));
this.CollectGeneratedCode(this.generator);
this.AssertNoDiagnostics();
Assert.Contains(
this.FindGeneratedMethod("GetObject"),
method => method.ParameterList.Parameters[0].Type is QualifiedNameSyntax { Right: { Identifier: { ValueText: "SafeHandle" } } });
}

[Fact]
public void ReleaseMethodGeneratedWithHandleStruct()
{
Expand Down

0 comments on commit c79065c

Please sign in to comment.