microsoft / microsoft/CsWin32

Add explicit nint cast operator to `PWSTR`.

Open Beginner friendly
#1,660 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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

It's common to need to work with the underlying pointer.

Describe the solution you'd like

public static explicit operator nint(PWSTR pwstr)
{
    unsafe
    {
        return (nint)pwstr.Value;
    }
}

Describe alternatives you've considered

I can add an extension method for this, but I can't add extension operators. This means i can't use a natural cast like I can with other pointed to types.

Additional context
N/A

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 locating the PWSTR type and its existing conversion operators. Add the requested explicit nint conversion using the underlying Value pointer, then run the repository's relevant build or tests to confirm the type compiles and the cast works.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.