< Summary

Information
Class: System.Net.Security.AuthenticatedStream
Assembly: System.Net.Security
File(s): D:\runner\runtime\src\libraries\System.Net.Security\src\System\Net\Security\AuthenticatedStream.cs
Line coverage
53%
Covered lines: 24
Uncovered lines: 21
Coverable lines: 45
Total lines: 91
Line coverage: 53.3%
Branch coverage
50%
Covered branches: 7
Total branches: 14
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%8863.63%
Dispose(...)75%4482.35%
DisposeAsync()0%220%

File(s)

D:\runner\runtime\src\libraries\System.Net.Security\src\System\Net\Security\AuthenticatedStream.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.IO;
 5using System.Threading.Tasks;
 6
 7namespace System.Net.Security
 8{
 9    // A public contract for a base abstract authenticated stream.
 10    public abstract class AuthenticatedStream : Stream
 11    {
 12        private readonly Stream _innerStream;
 13        private readonly bool _leaveStreamOpen;
 14
 3815        protected AuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen)
 3816        {
 3817            if (innerStream == null || innerStream == Stream.Null)
 018            {
 019                throw new ArgumentNullException(nameof(innerStream));
 20            }
 21
 3822            if (!innerStream.CanRead || !innerStream.CanWrite)
 023            {
 024                throw new ArgumentException(SR.net_io_must_be_rw_stream, nameof(innerStream));
 25            }
 26
 3827            _innerStream = innerStream;
 3828            _leaveStreamOpen = leaveInnerStreamOpen;
 3829        }
 30
 31        public bool LeaveInnerStreamOpen
 32        {
 33            get
 034            {
 035                return _leaveStreamOpen;
 036            }
 37        }
 38
 39        protected Stream InnerStream
 40        {
 41            get
 10242            {
 10243                return _innerStream;
 10244            }
 45        }
 46
 47        protected override void Dispose(bool disposing)
 3848        {
 49            try
 3850            {
 3851                if (disposing)
 3852                {
 3853                    if (_leaveStreamOpen)
 054                    {
 055                        _innerStream.Flush();
 056                    }
 57                    else
 3858                    {
 3859                        _innerStream.Dispose();
 3860                    }
 3861                }
 3862            }
 63            finally
 3864            {
 3865                base.Dispose(disposing);
 3866            }
 3867        }
 68
 69        public override ValueTask DisposeAsync()
 070        {
 71            try
 072            {
 073                ValueTask vt = _leaveStreamOpen ?
 074                    new ValueTask(_innerStream.FlushAsync()) :
 075                    _innerStream.DisposeAsync();
 076                GC.SuppressFinalize(this);
 077                return vt;
 78            }
 079            catch (Exception exc)
 080            {
 081                return ValueTask.FromException(exc);
 82            }
 083        }
 84
 85        public abstract bool IsAuthenticated { get; }
 86        public abstract bool IsMutuallyAuthenticated { get; }
 87        public abstract bool IsEncrypted { get; }
 88        public abstract bool IsSigned { get; }
 89        public abstract bool IsServer { get; }
 90    }
 91}