-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathRuntimeHelpersTests.cs
More file actions
68 lines (59 loc) · 2.31 KB
/
Copy pathRuntimeHelpersTests.cs
File metadata and controls
68 lines (59 loc) · 2.31 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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.CompilerServices;
using nanoFramework.TestFramework;
namespace NFUnitTestSystemLib
{
[TestClass]
class RuntimeHelpersTests
{
[TestMethod]
public static void IsReferenceOrContainsReferences()
{
Assert.IsFalse(RuntimeHelpers.IsReferenceOrContainsReferences<int>());
Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<string>());
Assert.IsFalse(RuntimeHelpers.IsReferenceOrContainsReferences<Guid>());
Assert.IsFalse(RuntimeHelpers.IsReferenceOrContainsReferences<StructWithoutReferences>());
Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<StructWithReferences>());
Assert.IsFalse(RuntimeHelpers.IsReferenceOrContainsReferences<RefStructWithoutReferences>());
Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<RefStructWithReferences>());
Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<Span<char>>());
Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<ReadOnlySpan<char>>());
//Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<RefStructWithRef>());
//Assert.IsTrue(RuntimeHelpers.IsReferenceOrContainsReferences<RefStructWithNestedRef>());
}
private struct StructWithoutReferences
{
public int a, b, c;
}
private struct StructWithReferences
{
public int a, b, c;
public object d;
}
private ref struct RefStructWithoutReferences
{
public int a;
public long b;
}
private ref struct RefStructWithReferences
{
public int a;
public object b;
}
// TODO: add after checking viability of ref fields in ref structs
//private ref struct RefStructWithRef
//{
// public ref int a;
// internal RefStructWithRef(ref int aVal)
// {
// a = ref aVal;
// }
//}
//private ref struct RefStructWithNestedRef
//{
// public Span<char> a;
//}
}
}