-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
GenericsTest.ReadOnlySpanB.cs
43 lines (32 loc) · 1.71 KB
/
GenericsTest.ReadOnlySpanB.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
using Xunit;
unsafe partial class GenericsNative
{
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanB")]
public static extern ReadOnlySpan<bool> GetReadOnlySpanB(bool e00);
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanBOut")]
public static extern void GetReadOnlySpanBOut(bool e00, out ReadOnlySpan<bool> value);
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanBPtr")]
public static extern ref readonly ReadOnlySpan<bool> GetReadOnlySpanBRef(bool e00);
[DllImport(nameof(GenericsNative), EntryPoint = "AddSpanB")]
public static extern ReadOnlySpan<bool> AddReadOnlySpanB(ReadOnlySpan<bool> lhs, ReadOnlySpan<bool> rhs);
[DllImport(nameof(GenericsNative), EntryPoint = "AddSpanBs")]
public static extern ReadOnlySpan<bool> AddReadOnlySpanBs(in ReadOnlySpan<bool> pValues, int count);
}
unsafe partial class GenericsTest
{
private static void TestReadOnlySpanB()
{
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanB(true));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanBOut(true, out ReadOnlySpan<bool> value3));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanBRef(true));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.AddReadOnlySpanB(default, default));
Assert.Throws<MarshalDirectiveException>(() => {
ReadOnlySpan<bool> value = default;
GenericsNative.AddReadOnlySpanBs(in value, 1);
});
}
}