microsoft / microsoft/CsWin32

Static 'Initialize' factory method on structs with cbSize fields

Open
#108 20 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Instead of:

var cursorInfo = new CURSORINFO { cbSize = (uint)Marshal.SizeOf(typeof(CURSORINFO)) };

What if we could write:

var cursorInfo = CURSORINFO.Initialize();

And Initialize would use either sizeof or a constant calculated at compile time whenever possible rather than calling Marshal.SizeOf?

(Allowing structs to have default constructors is being discussed for future C# versions.)

BITMAPINFOHEADER has biSize rather than cbSize.

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 with the issue examples for CURSORINFO and BITMAPINFOHEADER and inspect the repository to find where these supporting structs are generated. Determine the intended generated Initialize API and how compile-time size calculation would apply. Done means the proposed behavior is implemented consistently for cbSize and biSize cases, with coverage for the generated results.

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.