microsoft / microsoft/CsWin32

Generate PreserveSig=false p/invoke methods

Open
#566 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
2.5k
Forks
123
Avg merge
1d 3h
Merged PRs (30d)
9

Description

Actual behavior

The ole32 dll exports many methods that return HRESULT, and .NET interop allows for folks to declare extern methods with [DllImport(PreserveSig = false)] in order to return the out parameter instead.

Expected behavior

CsWin32 should do this by default, as it does for COM interface methods.

Repro steps

GetRunningObjectTable is one such function.

Context
  • CsWin32 version: [e.g. 0.4.422-beta]
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: [e.g. netstandard2.0]
  • LangVersion (if explicitly set by project): [e.g. 9]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the generated declaration for the GetRunningObjectTable entry point and compare its behavior with COM interface methods that use PreserveSig=false. Done means CsWin32-generated P/Invoke methods for applicable HRESULT-returning functions expose the out parameter behavior by default, with coverage for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.