2019-06-19 13:50:11 +00:00
|
|
|
using System;
|
2019-06-05 15:50:01 +00:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace PorygonSharp.DiagnosticHandling
|
|
|
|
{
|
2019-06-19 13:50:11 +00:00
|
|
|
public class DiagnosticItem
|
2019-06-05 15:50:01 +00:00
|
|
|
{
|
2019-06-19 13:50:11 +00:00
|
|
|
[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<InternalRepresentation>(_handle);
|
|
|
|
}
|
|
|
|
_initialed = true;
|
|
|
|
return _internalRepresentation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal DiagnosticItem(IntPtr handle)
|
|
|
|
{
|
|
|
|
_handle = handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal IntPtr GetHandle()
|
|
|
|
{
|
|
|
|
return _handle;
|
|
|
|
}
|
2019-06-05 15:50:01 +00:00
|
|
|
|
|
|
|
public DiagnosticCode GetCode()
|
|
|
|
{
|
2019-06-19 13:50:11 +00:00
|
|
|
return Internal.GetCode();
|
2019-06-05 15:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|