< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 28
Coverable lines: 28
Total lines: 66
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 20
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(...)0%16160%
ToString()0%440%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/Common/src/Interop/Windows/SspiCli/SecurityPackageInfoClass.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.Globalization;
 5using System.Runtime.InteropServices;
 6
 7namespace System.Net
 8{
 9    // _SecPkgInfoW in sspi.h.
 10    internal sealed class SecurityPackageInfoClass
 11    {
 12        internal int Capabilities;
 13        internal short Version;
 14        internal short RPCID;
 15        internal int MaxToken;
 16        internal string? Name;
 17        internal string? Comment;
 18
 19        /*
 20            This is to support SSL with no client cert.
 21            Important: safeHandle should not be Disposed during construction of this object.
 22
 23            _SecPkgInfoW in sspi.h
 24         */
 025        internal unsafe SecurityPackageInfoClass(SafeHandle safeHandle, int index)
 026        {
 027            if (safeHandle.IsInvalid)
 028            {
 029                if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"Invalid handle: {safeHandle}");
 030                return;
 31            }
 32
 033            IntPtr unmanagedAddress = safeHandle.DangerousGetHandle() + (sizeof(SecurityPackageInfo) * index);
 034            if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"unmanagedAddress: {unmanagedAddress}");
 35
 036            SecurityPackageInfo* pSecurityPackageInfo = (SecurityPackageInfo*)unmanagedAddress;
 37
 038            Capabilities = pSecurityPackageInfo->Capabilities;
 039            Version = pSecurityPackageInfo->Version;
 040            RPCID = pSecurityPackageInfo->RPCID;
 041            MaxToken = pSecurityPackageInfo->MaxToken;
 42
 43            IntPtr unmanagedString;
 44
 045            unmanagedString = pSecurityPackageInfo->Name;
 046            if (unmanagedString != IntPtr.Zero)
 047            {
 048                Name = Marshal.PtrToStringUni(unmanagedString);
 049                if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"Name: {Name}");
 050            }
 51
 052            unmanagedString = pSecurityPackageInfo->Comment;
 053            if (unmanagedString != IntPtr.Zero)
 054            {
 055                Comment = Marshal.PtrToStringUni(unmanagedString);
 056                if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"Comment: {Comment}");
 057            }
 58
 059            if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, this.ToString());
 060        }
 61
 62        public override string ToString() =>
 063            $"Capabilities:0x{Capabilities:x} Version:{Version} RPCID:{RPCID} MaxToken:{MaxToken} Name:{Name ?? "(null)"
 64    }
 65}
 66