microsoft / microsoft/CsWinRT

Bug: can't pass struct arrays to WinRT methods

Open
#2,287 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Export a WinRT method that accepts IVector<Windows.UI.Color>
  2. Pass a List to it, notice that everything works fine
  3. 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.