Bug: can't pass struct arrays to WinRT methods
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 665
- Forks
- 134
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 32
Description
Description
Passing a struct array (ie Color[]) to a WinRT exported method causes an exception to be thrown within CsWinRT:
Cannot provide IReferenceArray`1 support for element type 'Windows.UI.Color'.
This happens for any struct not explicitly referenced in ProvideIReferenceArray
Steps To Reproduce
- Export a WinRT method that accepts IVector<Windows.UI.Color>
- Pass a List to it, notice that everything works fine
- Pass a Color[] to it, notice that the call will fail
Expected Behavior
Passing around struct arrays causes no issues
Version Info
Happens with both stable and 2.3.0 prerelease
Additional Context
No response
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 in src/WinRT.Runtime/ComWrappersSupport.cs around ProvideIReferenceArray and reproduce the failure with an exported WinRT method accepting IVector<Windows.UI.Color>. Compare the working List path with the failing Color[] path. Done means struct arrays such as Color[] pass successfully without the reported IReferenceArray exception, with regression coverage for the scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100