Skip to content

Error in the return type of the GetProp and RemoveProp function #1674

@aetos382

Description

@aetos382

Actual behavior

Win32Cs uses SafeFileHandle as the return type for the GetProp and RemoveProp functions.

Expected behavior

The return type of these functions is an arbitrary HANDLE—not necessarily a file handle—and in fact, it could be any integer value.

Therefore, the most appropriate return type for the managed versions of these functions is IntPtr (or UIntPtr).

Even if reflecting the original signature where the return type is HANDLE, it should be SafeHandle.
In that case, its actual type is that the IsInvalid property always returns false, and the ReleaseHandle method does nothing.

Repro steps

  1. NativeMethods.txt content:
GetProp
RemoveProp
  1. NativeMethods.json content (if present):
{
  "$schema": "https://aka.ms/CsWin32.schema.json",
  "allowMarshaling": false
}
  1. Any of your own code that should be shared?
    none

Context

  • CsWin32 version: 0.3.269
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: net10.0-windows10.0.19041.0
  • LangVersion (if explicitly set by project): latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions