< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.ChannelBindingUtility
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/Common/src/CoreWCF/Channels/ChannelBindingUtility.cs
Line coverage
11%
Covered lines: 2
Uncovered lines: 15
Coverable lines: 17
Total lines: 55
Line coverage: 11.7%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
GetToken(...)100%110%
GetToken(...)0%220%
TryAddToMessage(...)0%220%
Dispose(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/Common/src/CoreWCF/Channels/ChannelBindingUtility.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.Net;
 6using System.Net.Security;
 7using System.Security.Authentication.ExtendedProtection;
 8
 9namespace CoreWCF.Channels
 10{
 11    internal static class ChannelBindingUtility
 12    {
 113        private static readonly ExtendedProtectionPolicy s_disabledPolicy = new ExtendedProtectionPolicy(PolicyEnforceme
 14
 615        public static ExtendedProtectionPolicy DefaultPolicy { get; } = s_disabledPolicy;
 16
 17        public static ChannelBinding GetToken(SslStream stream)
 18        {
 019            return GetToken(stream.TransportContext);
 20        }
 21
 22        public static ChannelBinding GetToken(TransportContext context)
 23        {
 024            ChannelBinding token = null;
 025            if (context != null)
 26            {
 027                token = context.GetChannelBinding(ChannelBindingKind.Endpoint);
 28            }
 029            return token;
 30        }
 31
 32        public static void TryAddToMessage(ChannelBinding channelBindingToken, Message message, bool messagePropertyOwns
 33        {
 034            if (channelBindingToken != null)
 35            {
 036                ChannelBindingMessageProperty property = new ChannelBindingMessageProperty(channelBindingToken, messageP
 037                property.AddTo(message);
 038                ((IDisposable)property).Dispose(); //message.Properties.Add() creates a copy...
 39            }
 040        }
 41
 42        public static void Dispose(ref ChannelBinding channelBinding)
 43        {
 44            // Explicitly cast to IDisposable to avoid the SecurityException.
 45            // I don't think this is relevant on .Net Core but I don't believe
 46            // it will emit any extra code from the JIT.
 047            IDisposable disposable = (IDisposable)channelBinding;
 048            channelBinding = null;
 049            if (disposable != null)
 50            {
 051                disposable.Dispose();
 52            }
 053        }
 54    }
 55}