Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map LARGE_INTEGER structs to 64-bit int types on .NET #99

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ public class Generator : IDisposable
{
{ nameof(System.Runtime.InteropServices.ComTypes.FILETIME), ParseTypeName("System.Runtime.InteropServices.ComTypes.FILETIME") },
{ nameof(Guid), ParseTypeName("System.Guid") },
{ "OLD_LARGE_INTEGER", PredefinedType(Token(SyntaxKind.LongKeyword)) },
{ "LARGE_INTEGER", PredefinedType(Token(SyntaxKind.LongKeyword)) },
{ "ULARGE_INTEGER", PredefinedType(Token(SyntaxKind.ULongKeyword)) },
};

internal static readonly Dictionary<string, string> BannedAPIs = new Dictionary<string, string>
{
{ "GetLastError", "Do not generate GetLastError. Call Marshal.GetLastWin32Error() instead. Learn more from https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error" },
{ "OLD_LARGE_INTEGER", "Use the C# long keyword instead." },
{ "LARGE_INTEGER", "Use the C# long keyword instead." },
{ "ULARGE_INTEGER", "Use the C# ulong keyword instead." },
};

private const string SystemRuntimeCompilerServices = "System.Runtime.CompilerServices";
Expand Down
1 change: 1 addition & 0 deletions test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void SimplestMethod()
[InlineData("DsGetDcOpen")] // allocates a handle with a release function that returns HRESULT
[InlineData("DXVAHDSW_CALLBACKS")] // pointers to handles
[InlineData("HBITMAP_UserMarshal")] // in+out handle pointer
[InlineData("GetDiskFreeSpaceExW")] // ULARGE_INTEGER replaced with keyword: ulong.
public void InterestingAPIs(string api)
{
this.generator = new Generator(this.metadataStream, options: new GeneratorOptions { EmitSingleFile = true }, compilation: this.compilation, parseOptions: this.parseOptions);
Expand Down