Skip to content

Commit

Permalink
Add test for using native pointers for LocalFree method
Browse files Browse the repository at this point in the history
A test case for #709
  • Loading branch information
AArnott committed Oct 5, 2022
1 parent efd8836 commit 0253c26
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 @@ -2754,6 +2754,18 @@ public void ContainsIllegalCharactersForAPIName_AllActualAPINames()
}
}

[Fact]
public void UsePointersNotNintForPointers()
{
this.generator = this.CreateGenerator(DefaultTestGeneratorOptions with { UseSafeHandles = false });
Assert.True(this.generator.TryGenerate("LocalFree", CancellationToken.None));
this.CollectGeneratedCode(this.generator);
this.AssertNoDiagnostics();
MethodDeclarationSyntax friendlyOverload = Assert.Single(this.FindGeneratedMethod("LocalFree"));
Assert.True(friendlyOverload.ParameterList.Parameters[0].Type is PointerTypeSyntax { ElementType: PredefinedTypeSyntax { Keyword: { RawKind: (int)SyntaxKind.VoidKeyword } } });
Assert.True(friendlyOverload.ReturnType is PointerTypeSyntax { ElementType: PredefinedTypeSyntax { Keyword: { RawKind: (int)SyntaxKind.VoidKeyword } } });
}

[Fact]
public void AvoidSafeHandles()
{
Expand Down

0 comments on commit 0253c26

Please sign in to comment.