• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / U8String / 6002426550

28 Aug 2023 04:29PM UTC coverage: 18.326% (-0.03%) from 18.353%
6002426550

push

github

neon-sunset
refactor: move unsafe extensions to a separate class

134 of 1038 branches covered (0.0%)

Branch coverage included in aggregate %.

64 of 64 new or added lines in 3 files covered. (100.0%)

479 of 2307 relevant lines covered (20.76%)

35688.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/Extensions/UnsafeExtensions.cs
1
using System.Diagnostics;
2
using System.Runtime.InteropServices;
3

4
namespace U8Primitives;
5

6
internal static class UnsafeExtensions
7
{
8
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
9
    internal static ref T AsRef<T>(this Span<T> value)
10
        where T : struct
11
    {
12
        return ref MemoryMarshal.GetReference(value);
5✔
13
    }
14

15
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
16
    internal static ref T AsRef<T>(this ReadOnlySpan<T> value)
17
        where T : struct
18
    {
19
        return ref MemoryMarshal.GetReference(value);
×
20
    }
21

22
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
23
    internal static ref T AsRef<T>(this T[] value, int offset)
24
        where T : struct
25
    {
26
        Debug.Assert((uint)offset < (uint)value.Length);
27
        return ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(value), (nint)(uint)offset);
56,858✔
28
    }
29

30
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
31
    internal static ref T AsRef<T>(this Span<T> value, int offset)
32
        where T : struct
33
    {
34
        Debug.Assert((uint)offset < (uint)value.Length);
35
        return ref Unsafe.Add(ref MemoryMarshal.GetReference(value), (nint)(uint)offset);
×
36
    }
37

38
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
39
    internal static ref T Add<T>(this ref T value, int offset)
40
        where T : struct
41
    {
42
        Debug.Assert(offset >= 0);
43
        return ref Unsafe.Add(ref value, (nint)(uint)offset);
3,346,103✔
44
    }
45

46
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
47
    internal static ref T Add<T>(this ref T value, nuint offset)
48
        where T : struct
49
    {
50
        return ref Unsafe.Add(ref value, offset);
246✔
51
    }
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc