Suggestion: support C# collection expressions for creating `VariableLengthInlineArray`s
Nobody has claimed this yet.
- 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.
When using CsWin32 to call the AdjustTokenPrivileges API, it took me a little while to realize how to create a new VariableLengthInlineArray (partly due to my lack of experience with ref types in C#).
Even after finding it out, I think that having to create an inline array by using an object initializer or assigning each member manually is quite unintuitive. It would be better if the library allowed to create such arrays using collection expressions introduced in C# 12.
Describe the solution you'd like
Instead of having to use this syntax to instantiate a VariableLengthInlineArray
var array = new VariableLengthInlineArray<Struct> {
[0] = new Struct(),
[1] = new Struct()
}
I'd like to be able to do it like this:
VariableLengthInlineArray<Struct> array = [new Struct(), new Struct()]
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 by locating the generation and supporting-type implementation for VariableLengthInlineArray, then inspect any tests covering its current object-initializer or indexed-assignment syntax. Add coverage showing that C# 12 collection expressions create the array, while confirming the existing initialization behavior remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100