< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AsAsync()100%22100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Features;
 4using ZeroC.Slice;
 5
 6namespace IceRpc.Slice.Ice;
 7
 8/// <summary>Provides an extension method for interface <see cref="IProxy" />.</summary>
 9public static class ProxyExtensions
 10{
 11    /// <summary>Tests whether the target service implements the Slice interface associated with
 12    /// <typeparamref name="TProxy" />. This method is a wrapper for <see cref="IIceObject.IceIsAAsync" />.
 13    /// All services implemented with Ice automatically provide this operation. Services implemented with IceRPC provide
 14    /// this operation only when they implement Slice interface <c>Ice::Object</c> explicitly.</summary>
 15    /// <typeparam name="TProxy">The type of the target proxy struct.</typeparam>
 16    /// <param name="proxy">The source proxy being tested.</param>
 17    /// <param name="features">The invocation features.</param>
 18    /// <param name="cancellationToken">A cancellation token that receives the cancellation requests.</param>
 19    /// <returns>A new <typeparamref name="TProxy" /> instance when <see cref="IIceObject.IceIsAAsync"/> returns
 20    /// <see langword="true"/>; otherwise, <see langword="null" />.</returns>
 21    /// <remarks>This method is equivalent to the "checked cast" methods provided by Ice. </remarks>
 22    public static async Task<TProxy?> AsAsync<TProxy>(
 23        this IProxy proxy,
 24        IFeatureCollection? features = null,
 25        CancellationToken cancellationToken = default) where TProxy : struct, IProxy =>
 226        await proxy.ToProxy<IceObjectProxy>().IceIsAAsync(typeof(TProxy).GetSliceTypeId()!, features, cancellationToken)
 227            .ConfigureAwait(false) ?
 228            proxy.ToProxy<TProxy>() : null;
 29}

Methods/Properties

AsAsync()