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

Method "SetSuspendState" is not translated correctly (BOOLEAN => byte instead of bool) #354

Closed
KChZellemann opened this issue Aug 9, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@KChZellemann
Copy link

Actual behavior

CsWin32 translate the BOOLEAN values of the method SetSuspendState to byte instead to bool.

The definition of method SetSuspendState in powrprof.h is as follows:

STDAPI_(BOOLEAN) SetSuspendState(_In_ BOOLEAN bHibernate, _In_ BOOLEAN bForce, _In_ BOOLEAN bWakeupEventsDisabled);

Generated C# method signature:

[DllImport("PowrProf", ExactSpelling = true,SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)][SupportedOSPlatform("windows5.1.2600")]internal static extern bool SetSuspendState(byte bHibernate, byte bForce, byte bWakeupEventsDisabled);

Expected behavior

[DllImport("PowrProf", ExactSpelling = true,SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)][SupportedOSPlatform("windows5.1.2600")]internal static extern bool SetSuspendState(bool bHibernate, bool bForce, bool bWakeupEventsDisabled);

Repro steps

  1. NativeMethods.txt content:
SetSuspendState

Context

  • CsWin32 version: 0.1.506-beta
  • Target Framework: net5.0
@KChZellemann KChZellemann added the bug Something isn't working label Aug 9, 2021
@AArnott
Copy link
Member

AArnott commented Jun 15, 2022

The latest CsWin32 version (and metadata that it brings in) uses BOOLEAN instead of byte here. It won't be bool because the ABI isn't equivalent in every case. But with #586, BOOLEAN becomes much easier to work with and can implicitly convert with bool too.

@AArnott AArnott closed this as completed Jun 15, 2022
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

2 participants