Commit 8b2cbfd
Qualify PCWSTR correctly in ReadOnlySpan<string> array marshaling
The friendly overload that projects a counted array of const strings
(`[Const, NativeArrayInfo] PCWSTR*`) as `ReadOnlySpan<string>` marshals via
`GCHandle`/`ArrayPool<PCWSTR>`. The temporary `ArrayPool<PCWSTR>` used the
`PCWSTRTypeSyntax` helper, which was hard-coded to the `winmdroot` alias.
For the Win32 SDK itself `winmdroot` is `Windows.Win32`, so this was correct.
But when projecting other metadata (whose `winmdroot` aliases a different
assembly, e.g. `global::OSClient`), `winmdroot.Foundation.PCWSTR` resolves to a
non-existent `OSClient.Foundation.PCWSTR` and fails to compile -- even though the
COM signature itself correctly references `global::Windows.Win32.Foundation.PCWSTR`.
Qualify the ArrayPool element type via `Win32NamespacePrefix` (as HRESULT and
other well-known types already do), so it resolves to
`global::Windows.Win32.Foundation.PCWSTR` outside the Win32 SDK and remains
`winmdroot.Foundation.PCWSTR` within it.
Extends the StringArrayInterop fixture with a counted-array interface and adds
MultiMetadataTests.StringArrayFriendlyOverloadQualifiesPcwstrCorrectly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 773b3bf commit 8b2cbfd
4 files changed
Lines changed: 68 additions & 18 deletions
File tree
- src/Microsoft.Windows.CsWin32
- test/Microsoft.Windows.CsWin32.Tests
- ExternalMetadata
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| |||
815 | 821 | | |
816 | 822 | | |
817 | 823 | | |
818 | | - | |
| 824 | + | |
819 | 825 | | |
820 | 826 | | |
821 | 827 | | |
| |||
891 | 897 | | |
892 | 898 | | |
893 | 899 | | |
894 | | - | |
| 900 | + | |
895 | 901 | | |
896 | 902 | | |
897 | 903 | | |
| |||
Lines changed: 35 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
12 | 6 | | |
13 | 7 | | |
14 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
Binary file not shown.
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
68 | 91 | | |
0 commit comments