< Summary

Information
Class: IceRpc.Slice.Operations.SliceProxySliceDecoderExtensions
Assembly: IceRpc.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/Operations/SliceProxySliceDecoderExtensions.cs
Tag: 1321_24790053727
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 41
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage
100%
Covered methods: 2
Fully covered methods: 2
Total methods: 2
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
DecodeProxy(...)100%11100%
CreateProxy(...)100%66100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using ZeroC.Slice.Codec;
 4
 5namespace IceRpc.Slice.Operations;
 6
 7/// <summary>Provides extension methods for <see cref="SliceDecoder" /> to decode proxies.</summary>
 8public static class SliceProxySliceDecoderExtensions
 9{
 10    /// <summary>Decodes a proxy struct.</summary>
 11    /// <typeparam name="TProxy">The type of the proxy struct to decode.</typeparam>
 12    /// <param name="decoder">The Slice decoder.</param>
 13    /// <returns>The decoded proxy struct.</returns>
 14    public static TProxy DecodeProxy<TProxy>(this ref SliceDecoder decoder) where TProxy : struct, ISliceProxy =>
 2215        CreateProxy<TProxy>(decoder.DecodeServiceAddress(), decoder.DecodingContext);
 16
 17    private static TProxy CreateProxy<TProxy>(ServiceAddress serviceAddress, object? decodingContext)
 18        where TProxy : struct, ISliceProxy
 2219    {
 2220        if (decodingContext is null)
 1921        {
 1922            return new TProxy { Invoker = InvalidInvoker.Instance, ServiceAddress = serviceAddress };
 23        }
 24        else
 325        {
 326            var baseProxy = (ISliceProxy)decodingContext;
 327            if (serviceAddress.Protocol is null && baseProxy.ServiceAddress is not null)
 128            {
 29                // Convert the relative service address to an absolute service address:
 130                serviceAddress = baseProxy.ServiceAddress with { Path = serviceAddress.Path };
 131            }
 32
 333            return new TProxy
 334            {
 335                EncodeOptions = baseProxy.EncodeOptions,
 336                Invoker = baseProxy.Invoker,
 337                ServiceAddress = serviceAddress
 338            };
 39        }
 2240    }
 41}