BridgeWire class

Namespace Runic.Application.Views · Runic.Application 0.7.0-preview.5

public static class BridgeWire

Static, allocation-conscious JSON primitives used by generated bridge codecs. Values whose JavaScript number representation can lose precision are represented as invariant strings on the wire.

Methods

Canonicalize

public static byte[] Canonicalize(ReadOnlySpan<byte> json)

Returns a canonical UTF-8 encoding for a complete JSON document.

Canonicalize

public static byte[] Canonicalize(JsonElement value)

Returns a canonical UTF-8 encoding for one JSON value.

EncodeCanonical

public static string EncodeCanonical(Action<Utf8JsonWriter> write)

Writes a complete canonical JSON value.

Exceptions

FormatException

The value has a duplicate member name or an out-of-range number.

Remarks

Object members are sorted by ordinal name, duplicate names are rejected, and numbers are written by exact value (1.0 and 1e0 are both 1). A number whose decimal exponent exceeds ±100,000 is rejected.

Invalid

public static FormatException Invalid(string message)

Creates a consistent invalid-wire exception for generated readers.

ReadBigInteger

public static BigInteger ReadBigInteger(JsonElement value)

Reads an exact arbitrary-precision integer represented as an invariant string.

ReadBoolean

public static bool ReadBoolean(JsonElement value)

Reads a JSON Boolean.

ReadDateOnly

public static DateOnly ReadDateOnly(JsonElement value)

Reads an ISO yyyy-MM-dd date string.

ReadDateTime

public static DateTime ReadDateTime(JsonElement value)

Reads an ISO date-time while preserving its UTC/local/unspecified kind.

ReadDateTimeOffset

public static DateTimeOffset ReadDateTimeOffset(JsonElement value)

Reads an ISO date-time with an explicit offset or Z, preserving the offset.

ReadDecimal

public static decimal ReadDecimal(JsonElement value)

Reads an exact decimal represented as an invariant string.

ReadDouble

public static double ReadDouble(JsonElement value)

Reads a finite JSON number as a double-precision value.

ReadEnum

public static TEnum ReadEnum<TEnum>(JsonElement value) where TEnum : struct, Enum

Reads a declared enum name.

ReadGuid

public static Guid ReadGuid(JsonElement value)

Reads a GUID string in D format.

ReadInt16

public static short ReadInt16(JsonElement value)

Reads a JSON number as a 16-bit integer.

ReadInt32

public static int ReadInt32(JsonElement value)

Reads a JSON number as a 32-bit integer.

ReadInt64

public static long ReadInt64(JsonElement value)

Reads an exact 64-bit integer represented as an invariant string.

ReadInt64String

public static long ReadInt64String(JsonElement value)

ReadInt8

public static sbyte ReadInt8(JsonElement value)

Reads a JSON number as a signed 8-bit integer.

ReadNullableString

public static string? ReadNullableString(JsonElement value)

Reads a JSON string or null.

ReadRequiredString

public static string ReadRequiredString(JsonElement value)

Compatibility spelling for a non-null JSON string.

ReadSingle

public static float ReadSingle(JsonElement value)

Reads a finite JSON number as a single-precision value.

ReadString

public static string ReadString(JsonElement value)

Reads a non-null JSON string.

ReadTimeOnly

public static TimeOnly ReadTimeOnly(JsonElement value)

Reads an ISO time string with zero to seven fractional digits.

ReadTimeSpan

public static TimeSpan ReadTimeSpan(JsonElement value)

Reads an invariant c-format time span string.

ReadUInt16

public static ushort ReadUInt16(JsonElement value)

Reads a JSON number as an unsigned 16-bit integer.

ReadUInt32

public static uint ReadUInt32(JsonElement value)

Reads a JSON number as an unsigned 32-bit integer.

ReadUInt64

public static ulong ReadUInt64(JsonElement value)

Reads an exact unsigned 64-bit integer represented as an invariant string.

ReadUInt64String

public static ulong ReadUInt64String(JsonElement value)

ReadUInt8

public static byte ReadUInt8(JsonElement value)

Reads a JSON number as an unsigned 8-bit integer.

RequiredProperty

public static JsonElement RequiredProperty(JsonElement value, string name)

Reads a named property from a JSON object.

StructuralEquals

public static bool StructuralEquals(string left, string right)

Compares two complete JSON documents after canonicalization.

StructuralEquals

public static bool StructuralEquals(JsonElement left, JsonElement right)

Compares two JSON values after canonicalization.

WriteBigInteger

public static void WriteBigInteger(Utf8JsonWriter writer, BigInteger value)

Writes an arbitrary-precision integer as an invariant JSON string.

WriteDateOnly

public static void WriteDateOnly(Utf8JsonWriter writer, DateOnly value)

Writes an ISO yyyy-MM-dd date string.

WriteDateTime

public static void WriteDateTime(Utf8JsonWriter writer, DateTime value)

Writes an ISO date-time while preserving its UTC/local/unspecified kind.

WriteDateTimeOffset

public static void WriteDateTimeOffset(Utf8JsonWriter writer, DateTimeOffset value)

Writes an ISO round-trip date-time string that keeps the offset.

WriteDecimal

public static void WriteDecimal(Utf8JsonWriter writer, decimal value)

Writes a decimal as an invariant JSON string.

WriteDouble

public static void WriteDouble(Utf8JsonWriter writer, double value)

Writes a finite double-precision JSON number.

WriteEnum

public static void WriteEnum<TEnum>(Utf8JsonWriter writer, TEnum value) where TEnum : struct, Enum

Writes a declared enum name.

WriteFiniteNumber

public static void WriteFiniteNumber(Utf8JsonWriter writer, float value)

Writes a finite single-precision JSON number.

WriteFiniteNumber

public static void WriteFiniteNumber(Utf8JsonWriter writer, double value)

Writes a finite double-precision JSON number.

WriteGuid

public static void WriteGuid(Utf8JsonWriter writer, Guid value)

Writes a GUID string in D format.

WriteInt64

public static void WriteInt64(Utf8JsonWriter writer, long value)

Writes a 64-bit integer as an invariant JSON string.

WriteIntegerString

public static void WriteIntegerString<TInteger>(Utf8JsonWriter writer, TInteger value) where TInteger : IBinaryInteger<TInteger>

Writes an exact integer as an invariant JSON string.

WriteNullableString

public static void WriteNullableString(Utf8JsonWriter writer, string? value)

Writes a JSON string or null.

WriteSingle

public static void WriteSingle(Utf8JsonWriter writer, float value)

Writes a finite single-precision JSON number.

WriteTimeOnly

public static void WriteTimeOnly(Utf8JsonWriter writer, TimeOnly value)

Writes an ISO round-trip time string.

WriteTimeSpan

public static void WriteTimeSpan(Utf8JsonWriter writer, TimeSpan value)

Writes an invariant c-format time span string.

WriteUInt64

public static void WriteUInt64(Utf8JsonWriter writer, ulong value)

Writes an unsigned 64-bit integer as an invariant JSON string.