< Summary

Information
Class: IceRpc.Extensions.DependencyInjection.Internal.ServiceAdapter<T>
Assembly: IceRpc.Extensions.DependencyInjection
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Extensions.DependencyInjection/Internal/ServiceAdapter.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 20
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage
100%
Covered methods: 1
Total methods: 1
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
DispatchAsync(...)50%22100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Extensions.DependencyInjection/Internal/ServiceAdapter.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace IceRpc.Extensions.DependencyInjection.Internal;
 6
 7/// <summary>Adapts a service managed by the DI container to an IDispatcher.</summary>
 8internal class ServiceAdapter<TService> : IDispatcher where TService : notnull
 9{
 10    public ValueTask<OutgoingResponse> DispatchAsync(IncomingRequest request, CancellationToken cancellationToken)
 9111    {
 9112        IServiceProviderFeature feature = request.Features.Get<IServiceProviderFeature>() ??
 9113            throw new InvalidOperationException(
 9114                $"There is no {nameof(IServiceProviderFeature)} in the request features.");
 15
 9116        TService service = feature.ServiceProvider.GetRequiredService<TService>();
 17
 9118        return ((IDispatcher)service).DispatchAsync(request, cancellationToken);
 9119    }
 20}