Nullable: System.Runtime.InteropServices.CustomMarshalers/WindowsRuntime (#23930)
[platform/upstream/coreclr.git] / src / System.Private.CoreLib / src / System / Runtime / InteropServices / WindowsRuntime / IVector.cs
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 #nullable enable
6 using System.Collections.Generic;
7
8 // Windows.Foundation.Collections.IVector`1 and IVectorView`1 cannot be referenced from managed
9 // code because they're hidden by the metadata adapter. We redeclare the interfaces manually
10 // to be able to talk to native WinRT objects.
11
12 namespace System.Runtime.InteropServices.WindowsRuntime
13 {
14     [ComImport]
15     [Guid("913337e9-11a1-4345-a3a2-4e7f956e222d")]
16     [WindowsRuntimeImport]
17     internal interface IVector<T> : IIterable<T>
18     {
19         T GetAt(uint index);
20         uint Size { get; }
21         IReadOnlyList<T> GetView();  // Really an IVectorView<T>.
22         bool IndexOf(T value, out uint index);
23         void SetAt(uint index, T value);
24         void InsertAt(uint index, T value);
25         void RemoveAt(uint index);
26         void Append(T value);
27         void RemoveAtEnd();
28         void Clear();
29         uint GetMany(uint startIndex, [Out] T[] items);
30         void ReplaceAll(T[] items);
31     }
32
33     // Same as IVector - the only difference is that GetView returns IVectorView<T>
34     [ComImport]
35     [Guid("913337e9-11a1-4345-a3a2-4e7f956e222d")]
36     [WindowsRuntimeImport]
37     internal interface IVector_Raw<T> : IIterable<T>
38     {
39         T GetAt(uint index);
40         uint Size { get; }
41         IVectorView<T> GetView();
42         bool IndexOf(T value, out uint index);
43         void SetAt(uint index, T value);
44         void InsertAt(uint index, T value);
45         void RemoveAt(uint index);
46         void Append(T value);
47         void RemoveAtEnd();
48         void Clear();
49     }
50
51     [ComImport]
52     [Guid("bbe1fa4c-b0e3-4583-baef-1f1b2e483e56")]
53     [WindowsRuntimeImport]
54     internal interface IVectorView<T> : IIterable<T>
55     {
56         T GetAt(uint index);
57         uint Size { get; }
58         bool IndexOf(T value, out uint index);
59         uint GetMany(uint startIndex, [Out] T[] items);
60     }
61
62     [ComImport]
63     [Guid("393de7de-6fd0-4c0d-bb71-47244a113e93")]
64     [WindowsRuntimeImport]
65     internal interface IBindableVector : IBindableIterable
66     {
67         object? GetAt(uint index);
68         uint Size { get; }
69         IBindableVectorView GetView();
70         bool IndexOf(object value, out uint index);
71         void SetAt(uint index, object value);
72         void InsertAt(uint index, object value);
73         void RemoveAt(uint index);
74         void Append(object value);
75         void RemoveAtEnd();
76         void Clear();
77     }
78
79     [ComImport]
80     [Guid("346dd6e7-976e-4bc3-815d-ece243bc0f33")]
81     [WindowsRuntimeImport]
82     internal interface IBindableVectorView : IBindableIterable
83     {
84         object? GetAt(uint index);
85         uint Size { get; }
86         bool IndexOf(object value, out uint index);
87     }
88 }