< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 41
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
.ctor(...)100%110%
Branch(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/SwitchInstructionEncoder.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;
 5
 6namespace System.Reflection.Metadata.Ecma335
 7{
 8    /// <summary>
 9    /// Encodes the branches of an IL <c>switch</c> instruction.
 10    /// </summary>
 11    /// <remarks>
 12    /// See <see cref="InstructionEncoder.Switch(int)"/> for usage guidelines.
 13    /// </remarks>
 14    public readonly struct SwitchInstructionEncoder
 15    {
 16        private readonly InstructionEncoder _encoder;
 17
 18        private readonly int _ilOffset, _instructionEnd;
 19
 20        internal SwitchInstructionEncoder(InstructionEncoder encoder, int ilOffset, int instructionEnd)
 021        {
 022            Debug.Assert(encoder.ControlFlowBuilder is not null);
 023            _encoder = encoder;
 024            _ilOffset = ilOffset;
 025            _instructionEnd = instructionEnd;
 026        }
 27
 28        /// <summary>
 29        /// Encodes a branch that is part of a switch instruction.
 30        /// </summary>
 31        /// <remarks>
 32        /// See <see cref="InstructionEncoder.Switch(int)"/> for usage guidelines.
 33        /// </remarks>
 34        public void Branch(LabelHandle label)
 035        {
 036            _encoder.ControlFlowBuilder!.SwitchBranchAdded();
 037            _encoder.LabelOperand(ILOpCode.Switch, label, _instructionEnd - _encoder.Offset, _ilOffset);
 038        }
 39    }
 40}
 41