-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
GenericsTest.ReadOnlySpanL.cs
45 lines (34 loc) · 1.86 KB
/
GenericsTest.ReadOnlySpanL.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
44
45
// 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 = "GetSpanL")]
public static extern ReadOnlySpan<long> GetReadOnlySpanL(long e00);
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanLOut")]
public static extern void GetReadOnlySpanLOut(long e00, out ReadOnlySpan<long> value);
[DllImport(nameof(GenericsNative), EntryPoint = "GetSpanLPtr")]
public static extern ref readonly ReadOnlySpan<long> GetReadOnlySpanLRef(long e00);
[DllImport(nameof(GenericsNative), EntryPoint = "AddSpanL")]
public static extern ReadOnlySpan<long> AddReadOnlySpanL(ReadOnlySpan<long> lhs, ReadOnlySpan<long> rhs);
[DllImport(nameof(GenericsNative), EntryPoint = "AddSpanLs")]
public static extern ReadOnlySpan<long> AddReadOnlySpanLs(in ReadOnlySpan<long> pValues, int count);
}
public unsafe partial class GenericsTest
{
[Fact]
[ActiveIssue("https://github.com/dotnet/runtimelab/issues/177", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))]
public static void TestReadOnlySpanL()
{
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanL(1L));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanLOut(1L, out ReadOnlySpan<long> value3));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.GetReadOnlySpanLRef(1L));
Assert.Throws<MarshalDirectiveException>(() => GenericsNative.AddReadOnlySpanL(default, default));
Assert.Throws<MarshalDirectiveException>(() => {
ReadOnlySpan<long> value = default;
GenericsNative.AddReadOnlySpanLs(in value, 1);
});
}
}