Struct DebugData
- Namespace
- CStructSharp.Diagnostics
- Assembly
- CStructSharp.dll
Describes the byte range, path, type, and decoded value of one item read in debug mode.
public readonly struct DebugData : IEquatable<DebugData>
- Implements
- Inherited Members
Examples
Parse with byte-range information when you need to connect a result to its original bytes. ResolveAddress finds
the start of one field without changing the caller's stream position:
This InspectRanges check is compiled and executed with the other site examples:
private static void InspectRanges()
{
var layout = new CStruct("struct sample { uint8 tag; uint16 value; };");
using var stream = new MemoryStream([0xA1, 0x34, 0x12]);
(StructValue result, IReadOnlyList<DebugData> ranges) = layout.ParseWithDebug(stream, "sample");
Equal((byte)0xA1, result.Get<byte>("tag"));
True(ranges.Any(item => item.Start == 1 && item.End == 3), "Value range was not reported.");
stream.Position = 0;
Equal(1L, layout.ResolveAddress(stream, "sample.value"));
Equal(0L, stream.Position);
}
Remarks
Records are produced by ParseWithDebug(Stream, string?, IReadOnlyDictionary<string, int>?, ReadOptions?), its overloads, and ReadValueWithDebug.
Start is inclusive and End exclusive, both relative to the operation's origin
(the stream position or region start when the operation began). The record is immutable; a caller that
needs the bytes selects Start..End from its own input, except for a union read as raw storage, whose
bytes Bytes carries because they are not addressable through a single field.
Properties
Bytes
Gets the raw bytes of a union captured as storage; empty for every other item.
public ReadOnlyMemory<byte> Bytes { get; init; }
Property Value
End
Gets the exclusive zero-based end offset of the captured item.
public long End { get; init; }
Property Value
Length
Gets the number of bytes the item occupies.
public long Length { get; }
Property Value
Path
Gets the declaration path of the item, such as header.samples[2].value.
public string Path { get; }
Property Value
Start
Gets the inclusive zero-based start offset of the captured item.
public long Start { get; init; }
Property Value
TypeName
Gets the layout type spelling of the captured item, or null for a composite.
public string? TypeName { get; init; }
Property Value
Value
Gets the decoded value of the captured item.
public object? Value { get; init; }
Property Value
Methods
Equals(DebugData)
public bool Equals(DebugData other)
Parameters
otherDebugData
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
Formats the item for diagnostics.
public override string ToString()
Returns
- string
The path, byte range, type name, and value, such as
header.kind [0, 2) uint16 = 2.
Operators
operator ==(DebugData, DebugData)
public static bool operator ==(DebugData left, DebugData right)
Parameters
Returns
operator !=(DebugData, DebugData)
public static bool operator !=(DebugData left, DebugData right)