< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)100%110%
Trace()100%110%
Finalize()0%220%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/Common/src/System/Net/DebugSafeHandle.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 Microsoft.Win32.SafeHandles;
 5
 6namespace System.Net
 7{
 8#if DEBUG
 9    //
 10    // This is a helper class for debugging GC-ed handles that we define.
 11    // As a general rule normal code path should always destroy handles explicitly
 12    //
 13    internal abstract class DebugSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
 14    {
 15        private string? _trace;
 16
 017        protected DebugSafeHandle(bool ownsHandle) : base(ownsHandle)
 018        {
 019            Trace();
 020        }
 21
 022        protected DebugSafeHandle(IntPtr invalidValue, bool ownsHandle) : base(ownsHandle)
 023        {
 024            SetHandle(invalidValue);
 025            Trace();
 026        }
 27
 28        private void Trace()
 029        {
 030            _trace = "WARNING! GC-ed  >>" + this.GetType().ToString() + "<< (should be explicitly closed) \r\n";
 031        }
 32
 33        ~DebugSafeHandle()
 034        {
 035            if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, _trace);
 036        }
 37    }
 38#endif // DEBUG
 39}
 40