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

Missing error codes in WIN32_ERROR enum. #1311

Closed
ArakawaHenri opened this issue Oct 12, 2022 · 2 comments
Closed

Missing error codes in WIN32_ERROR enum. #1311

ArakawaHenri opened this issue Oct 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ArakawaHenri
Copy link

Actual behavior

The generated WIN32_ERROR enum is missing some error codes.

Expected behavior

An enum containing complete enumerated Win32 Error Codes.

Repro steps

For example, trying to determine whether the program is packaged:

  1. NativeMethods.txt content:
GetCurrentPackageFullName
  1. CSharp Code:
uint length = 0;

bool IsPackaged = PInvoke.GetCurrentPackageFullName(ref length, null) != Windows.Win32.Foundation.WIN32_ERROR.APPMODEL_ERROR_NO_PACKAGE;

But it seems that there isn't APPMODEL_ERROR_NO_PACKAGE (15700) in WIN32_ERROR:
1

Context

  • CsWin32 version: 0.2.63-beta
  • Target Framework: net6.0-windows10.0.22621.0
@ArakawaHenri ArakawaHenri added the bug Something isn't working label Oct 12, 2022
@AArnott AArnott transferred this issue from microsoft/CsWin32 Oct 13, 2022
@elachlan
Copy link
Contributor

API Reference: https://learn.microsoft.com/en-us/windows/win32/api/appmodel/nf-appmodel-getcurrentpackagefullname

Should the WIN32_ERROR enum include APPMODEL_ERROR_* constants then?

Another issue is WIN32_ERROR is uint whereas the return type on GetCurrentPackageFullName is long.

@ArakawaHenri
Copy link
Author

ArakawaHenri commented Oct 15, 2022

I think they should be included, as they are listed on official docs.
It seems that the generated code defines the type of the return value of the GetCurrentPackageFullName function as WIN32_ERROR, so that it may return a value that does not exist in the enumeration.

BTW, GetCurrentPackageFullName does return an Error Code as long, according to Microsoft's documentation. But the Error Code should be uint (as GetLastError returns DWORD). I don't think there's anything we can do about this, since it's Microsoft's fault, and this doesn't seem to cause any problems, the type conversion happens automatically.

@mikebattista mikebattista self-assigned this Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants