Static 'Initialize' factory method on structs with cbSize fields
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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