< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.Framing.ServerSessionConnectionReaderMiddleware
Assembly: CoreWCF.NetFramingBase
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetFramingBase/src/CoreWCF/Channels/Framing/ServerSessionConnectionReaderMiddleware.cs
Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 64
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
OnConnectedAsync()100%22100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetFramingBase/src/CoreWCF/Channels/Framing/ServerSessionConnectionReaderMiddleware.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.Collections.Generic;
 5using System.Threading.Tasks;
 6using CoreWCF.Configuration;
 7using Microsoft.Extensions.Hosting;
 8using Microsoft.Extensions.DependencyInjection;
 9using System.Collections;
 10using CoreWCF.Runtime;
 11
 12namespace CoreWCF.Channels.Framing
 13{
 14    internal class ServerSessionConnectionReaderMiddleware
 15    {
 16        private readonly HandshakeDelegate _next;
 17        private readonly IServiceScopeFactory _servicesScopeFactory;
 18        private readonly IApplicationLifetime _appLifetime;
 8319        private readonly Hashtable _transportSettingsCache = new Hashtable();
 8320        private readonly object _lock = new object();
 21
 8322        public ServerSessionConnectionReaderMiddleware(HandshakeDelegate next, IServiceScopeFactory servicesScopeFactory
 23        {
 8324            _next = next;
 8325            _servicesScopeFactory = servicesScopeFactory;
 8326            _appLifetime = appLifetime;
 8327        }
 28
 29        public async Task OnConnectedAsync(FramingConnection connection)
 30        {
 31            ITransportFactorySettings settings;
 6432            if (_transportSettingsCache.Contains(connection.ServiceDispatcher))
 33            {
 1534                settings = (ITransportFactorySettings)_transportSettingsCache[connection.ServiceDispatcher];
 35            }
 36            else
 37            {
 4938                lock (_lock)
 39                {
 40                    // Double locked checking not necessary as there's no functional harm to having multiple instances
 4941                    BindingElementCollection be = connection.ServiceDispatcher.Binding.CreateBindingElements();
 4942                    TransportBindingElement tbe = be.Find<TransportBindingElement>();
 4943                    settings = new NetFramingTransportSettings
 4944                    {
 4945                        CloseTimeout = connection.ServiceDispatcher.Binding.CloseTimeout,
 4946                        OpenTimeout = connection.ServiceDispatcher.Binding.OpenTimeout,
 4947                        ReceiveTimeout = connection.ServiceDispatcher.Binding.ReceiveTimeout,
 4948                        SendTimeout = connection.ServiceDispatcher.Binding.SendTimeout,
 4949                        ManualAddressing = tbe.ManualAddressing,
 4950                        BufferManager = connection.BufferManager,
 4951                        MaxReceivedMessageSize = tbe.MaxReceivedMessageSize,
 4952                        MessageEncoderFactory = connection.MessageEncoderFactory
 4953                    };
 4954                    _transportSettingsCache[connection.ServiceDispatcher] = settings;
 4955                }
 56            }
 57
 6458            var channel = new ServerFramingDuplexSessionChannel(connection, settings, false, _servicesScopeFactory.Creat
 6459            channel.ChannelDispatcher = await connection.ServiceDispatcher.CreateServiceChannelDispatcherAsync(channel);
 6460            await channel.StartReceivingAsync();
 6361            await channel.CloseAsync();
 6362        }
 63    }
 64}