-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
GenericsTest.SpanL.cs
43 lines (32 loc) · 1.44 KB
/
GenericsTest.SpanL.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))]
public static extern Span<long> GetSpanL(long e00);
[DllImport(nameof(GenericsNative))]
public static extern void GetSpanLOut(long e00, out Span<long> value);
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanLPtr")]
public static extern ref readonly Span<long> GetSpanLRef(long e00);
[DllImport(nameof(GenericsNative))]
public static extern Span<long> AddSpanL(Span<long> lhs, Span<long> rhs);
[DllImport(nameof(GenericsNative))]
public static extern Span<long> AddSpanLs(in Span<long> pValues, int count);
}
unsafe partial class GenericsTest
{
private static void TestSpanL()
{
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetSpanL(1L));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetSpanLOut(1L, out Span<long> value3));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetSpanLRef(1L));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.AddSpanL(default, default));
Assert.Throws<MarshalDirectiveException>(() => {
Span<long> value = default;
GenericsNative.AddSpanLs(in value, 1);
});
}
}