Skip to content

Commit

Permalink
Merge pull request #686 from microsoft/fix675
Browse files Browse the repository at this point in the history
Prefer System.IO.SeekOrigin over STREAM_SEEK
  • Loading branch information
AArnott authored Sep 7, 2022
2 parents d1cf168 + 2b4e2f5 commit fef9088
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Generator : IDisposable
{ "OVERLAPPED", ParseTypeName("global::System.Threading.NativeOverlapped") },
{ "POINT", ParseTypeName("global::System.Drawing.Point") },
{ "POINTF", ParseTypeName("global::System.Drawing.PointF") },
{ "STREAM_SEEK", ParseTypeName("global::System.IO.SeekOrigin") },
};

/// <summary>
Expand Down
13 changes: 13 additions & 0 deletions test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,19 @@ public void ParametersIncludeSizeParamIndex()
Assert.Equal("0", ((LiteralExpressionSyntax)sizeParamIndex!.Expression).Token.ValueText);
}

[Fact]
public void SeekOriginEnumPreferred()
{
this.generator = this.CreateGenerator();
Assert.True(this.generator.TryGenerateType("IStream"));
this.CollectGeneratedCode(this.generator);
this.AssertNoDiagnostics();

MethodDeclarationSyntax seekMethod = Assert.Single(this.FindGeneratedMethod("Seek"));
QualifiedNameSyntax seekParamType = Assert.IsType<QualifiedNameSyntax>(seekMethod.ParameterList.Parameters[1].Type);
Assert.Equal(nameof(SeekOrigin), seekParamType.Right.Identifier.ValueText);
}

private static string ConstructGlobalConfigString(bool omitDocs = false)
{
StringBuilder globalConfigBuilder = new();
Expand Down

0 comments on commit fef9088

Please sign in to comment.