< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 73
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
IsDigit(...)100%110%
TryParseThrowFormatException(...)100%110%
TryParseThrowFormatException(...)100%110%
TryParseThrowFormatException(...)100%110%

File(s)

C:\h\w\9FD50923\w\C0A20A61\e\runtime-utils\Runner\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\ParserHelpers.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Diagnostics.CodeAnalysis;
 6using System.Runtime.CompilerServices;
 7
 8namespace System.Buffers.Text
 9{
 10    internal static class ParserHelpers
 11    {
 12        public const int ByteOverflowLength = 3;
 13        public const int ByteOverflowLengthHex = 2;
 14        public const int UInt16OverflowLength = 5;
 15        public const int UInt16OverflowLengthHex = 4;
 16        public const int UInt32OverflowLength = 10;
 17        public const int UInt32OverflowLengthHex = 8;
 18        public const int UInt64OverflowLength = 20;
 19        public const int UInt64OverflowLengthHex = 16;
 20
 21        public const int SByteOverflowLength = 3;
 22        public const int SByteOverflowLengthHex = 2;
 23        public const int Int16OverflowLength = 5;
 24        public const int Int16OverflowLengthHex = 4;
 25        public const int Int32OverflowLength = 10;
 26        public const int Int32OverflowLengthHex = 8;
 27        public const int Int64OverflowLength = 19;
 28        public const int Int64OverflowLengthHex = 16;
 29
 30        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 31        public static bool IsDigit(int i)
 32        {
 033            return (uint)(i - '0') <= ('9' - '0');
 34        }
 35
 36        //
 37        // Enable use of ThrowHelper from TryParse() routines without introducing dozens of non-code-coveraged "value= d
 38        //
 39        public static bool TryParseThrowFormatException(out int bytesConsumed)
 40        {
 041            bytesConsumed = 0;
 042            ThrowHelper.ThrowFormatException_BadFormatSpecifier();
 43            return false;
 44        }
 45
 46        //
 47        // Enable use of ThrowHelper from TryParse() routines without introducing dozens of non-code-coveraged "value= d
 48        //
 49        public static bool TryParseThrowFormatException<T>(out T value, out int bytesConsumed) where T : struct
 50        {
 051            value = default;
 052            return TryParseThrowFormatException(out bytesConsumed);
 53        }
 54
 55        //
 56        // Enable use of ThrowHelper from TryParse() routines without introducing dozens of non-code-coveraged "value= d
 57        //
 58        [DoesNotReturn]
 59        [StackTraceHidden]
 60        public static bool TryParseThrowFormatException<T>(ReadOnlySpan<byte> _, out T value, out int bytesConsumed) whe
 61        {
 62            // The parameters to this method are ordered the same as our callers' parameters
 63            // allowing the JIT to avoid unnecessary register swapping or spilling.
 64
 065            Unsafe.SkipInit(out value); // bypass language initialization rules since we're about to throw
 066            Unsafe.SkipInit(out bytesConsumed);
 067            ThrowHelper.ThrowFormatException_BadFormatSpecifier();
 68
 69            Debug.Fail("Control should never reach this point.");
 70            return false;
 71        }
 72    }
 73}