< Summary

Class:SharpHoundRPC.Shared.SharedStructs
Assembly:SharpHoundRPC
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\SharpHoundRPC\Shared\SharedStructs.cs
Covered lines:0
Uncovered lines:16
Coverable lines:16
Total lines:38
Line coverage:0% (0 of 16)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%200%
Dispose()0%200%
ToString()0%400%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\SharpHoundRPC\Shared\SharedStructs.cs

#LineLine coverage
 1using System;
 2using System.Runtime.InteropServices;
 3
 4namespace SharpHoundRPC.Shared
 5{
 6    public class SharedStructs
 7    {
 8        [StructLayout(LayoutKind.Sequential)]
 9        public struct UnicodeString : IDisposable
 10        {
 11            private readonly ushort Length;
 12            private readonly ushort MaximumLength;
 13            private IntPtr Buffer;
 14
 15            public UnicodeString(string s)
 016                : this()
 017            {
 018                if (s == null) return;
 019                Length = (ushort) (s.Length * 2);
 020                MaximumLength = (ushort) (Length + 2);
 021                Buffer = Marshal.StringToHGlobalUni(s);
 022            }
 23
 24            public void Dispose()
 025            {
 026                if (Buffer == IntPtr.Zero) return;
 027                Marshal.FreeHGlobal(Buffer);
 028                Buffer = IntPtr.Zero;
 029            }
 30
 31            public override string ToString()
 032            {
 033                return (Buffer != IntPtr.Zero ? Marshal.PtrToStringUni(Buffer, Length / 2) : null) ??
 034                       throw new InvalidOperationException();
 035            }
 36        }
 37    }
 38}