using System; using System.Runtime.InteropServices; namespace PorygonSharp.DiagnosticHandling { public class DiagnosticItem { [StructLayout(LayoutKind.Sequential)] public struct InternalRepresentation { private readonly int _severity; private readonly DiagnosticCode _code; private readonly uint _start; private readonly uint _length; public DiagnosticCode GetCode() { return _code; } } private InternalRepresentation _internalRepresentation; private readonly IntPtr _handle; private bool _initialed; private InternalRepresentation Internal { get { if (!_initialed) { _internalRepresentation = Marshal.PtrToStructure(_handle); } _initialed = true; return _internalRepresentation; } } internal DiagnosticItem(IntPtr handle) { _handle = handle; } internal IntPtr GetHandle() { return _handle; } public DiagnosticCode GetCode() { return Internal.GetCode(); } } }