< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.ServiceConfiguration<T>
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Configuration/ServiceConfiguration.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 49
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%
GetDispatchers()100%44100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Configuration/ServiceConfiguration.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;
 5using System.Collections.Generic;
 6using CoreWCF.Description;
 7using CoreWCF.Runtime;
 8
 9namespace CoreWCF.Configuration
 10{
 11    internal class ServiceConfiguration<TService> : IServiceConfiguration<TService> where TService : class
 12    {
 13        private readonly ServiceBuilder _serviceBuilder;
 14        private readonly IServiceProvider _services;
 15        private List<IServiceDispatcher> _dispatchers;
 58516        private object _lock = new object();
 17
 58518        public ServiceConfiguration(ServiceBuilder serviceBuilder, IServiceProvider services)
 19        {
 58520            _serviceBuilder = serviceBuilder;
 58521            _services = services;
 58522        }
 23
 58624        public Type ServiceType => typeof(TService);
 25
 234126        public List<ServiceEndpointConfiguration> Endpoints { get; } = new List<ServiceEndpointConfiguration>();
 27
 28        public List<IServiceDispatcher> GetDispatchers()
 29        {
 60930            if (_dispatchers == null)
 31            {
 32                // The services can't be Open'd until after ASP.NET Core is running and listening for requests. The Open
 33                // is started and allowed to run in the background. If a request comes in before the dispatchers have fi
 34                // being built, there are multiple problems which can occur such as adding an endpoint twice, or concurr
 35                // modification of collections, or trying to modify the service host after it has been opened.
 36                // This double check lock ensures this doesn't happen.
 58337                lock (_lock)
 38                {
 58339                    if (_dispatchers == null)
 40                    {
 58341                        _dispatchers = DispatcherBuilder.BuildDispatcher<TService>(this, _services);
 42                    }
 57343                }
 44            }
 45
 59946            return _dispatchers;
 47        }
 48    }
 49}