Skip to content

Commit

Permalink
Merge pull request #974 from microsoft/fix969
Browse files Browse the repository at this point in the history
Fix user requests for special types
  • Loading branch information
AArnott committed Jun 23, 2023
2 parents 1d9b174 + a453f71 commit 0bccff3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public bool TryGenerateType(string possiblyQualifiedName, out IReadOnlyList<stri
return false;
}

if (SpecialTypeDefNames.Contains(typeName))
if (this.InputAssemblyName.Equals("Windows.Win32", StringComparison.OrdinalIgnoreCase) && SpecialTypeDefNames.Contains(typeName))
{
string? fullyQualifiedName = null;
this.volatileCode.GenerationTransaction(() => this.RequestSpecialTypeDefStruct(typeName, out fullyQualifiedName));
Expand Down
13 changes: 13 additions & 0 deletions test/Microsoft.Windows.CsWin32.Tests/StructTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ public void FieldWithAssociatedEnum()
Assert.Equal("SHDID_ID", Assert.IsType<IdentifierNameSyntax>(property.Type).Identifier.ValueText);
}

[Theory]
[InlineData("PCSTR")]
public void SpecialStruct_ByRequest(string structName)
{
this.generator = this.CreateGenerator();
Assert.True(this.generator.TryGenerate(structName, out IReadOnlyList<string> preciseApi, CancellationToken.None));
Assert.Single(preciseApi);
this.CollectGeneratedCode(this.generator);
this.AssertNoDiagnostics();

var type = (StructDeclarationSyntax)Assert.Single(this.FindGeneratedType(structName));
}

[Theory]
[CombinatorialData]
public void InterestingStructs(
Expand Down

0 comments on commit 0bccff3

Please sign in to comment.