microsoft / microsoft/CsWin32

Provide RAII helpers for COM pointers

Open
#1,596 0 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

Is your feature request related to a problem? Please describe.

When I want to use a COM interface pointer in the non-marshal mode with CsWin32, you have to IUnknown::Release it manually. However, in C++, it's normal to use the RAII helpers, such as ComPtr, ComHeapPtr, etc.

Describe the solution you'd like

Generate RAII helpers for COM, such as ComPtr, ComHeapPtr, etc.

Describe alternatives you've considered

Do not implement this and let users of CsWin32 manually release COM pointers.

Additional context

Here's some sample implementations.

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 reading the linked ComPtr and ComHeapPtr sample implementations to understand the proposed RAII patterns and how they release COM resources. Then inspect the CsWin32 generation entry points and determine the scope of the requested helpers; the work is done when suitable helpers are generated for non-marshal COM pointers.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.