< Summary

Information
Class: IceRpc.Slice.SliceEncodingExtensions
Assembly: IceRpc.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/SliceEncodingExtensions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 23
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage
100%
Covered methods: 2
Total methods: 2
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
CreateEmptyStructPayload(...)50%22100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/SliceEncodingExtensions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Buffers;
 4using System.IO.Pipelines;
 5using ZeroC.Slice;
 6
 7namespace IceRpc.Slice;
 8
 9/// <summary>Provides an extension method for <see cref="SliceEncoding" /> to create an empty struct payload.</summary>
 10public static class SliceEncodingExtensions
 11{
 12    // 4 = varuint62 encoding of the size (1)
 13    // 252 = varint32 encoding of the Slice2 tag end marker (-1)
 114    private static readonly ReadOnlySequence<byte> _emptyStructPayload = new(new byte[] { 4, 252 });
 15
 16    /// <summary>Creates the payload of an empty struct.</summary>
 17    /// <param name="encoding">The Slice encoding.</param>
 18    /// <returns>The payload of an empty struct.</returns>
 19    public static PipeReader CreateEmptyStructPayload(this SliceEncoding encoding) =>
 1220        encoding != SliceEncoding.Slice1 ? PipeReader.Create(_emptyStructPayload) :
 1221            throw new NotSupportedException(
 1222                $"{nameof(CreateEmptyStructPayload)} is only available for stream-capable Slice encodings.");
 23}