System.Formats.Nrbf 11.0.0-preview.7.26381.103

About

System.Formats.Nrbf exposes only one component: NrbfDecoder: a stateless, forward-only decoder class that can decode .NET Remoting Binary Format (NRBF) binary data from a stream.

You can think of NrbfDecoder as being the equivalent of using a JSON/XML reader without the deserializer.

How to Use

The NRBF payload consists of serialization records that represent the serialized objects and their metadata. To read the whole payload and get the root record, you need to call one of the NrbfDecoder.Decode methods.

The Decode method returns a SerializationRecord instance. SerializationRecord is an abstract class that represents the serialization record and provides three properties: Id, RecordType, and TypeName. It exposes one method, TypeNameMatches, which compares the type name read from the payload (and exposed via TypeName property) against the specified type. This method ignores assembly names, so you don't need to worry about type forwarding and assembly versioning. It also does not consider member names or their types (because getting this information would require type loading).

using System.Formats.Nrbf;

public class Sample
{
    public int Integer;
    public string? Text;
    public byte[]? ArrayOfBytes;
    public Sample? ClassInstance;
}

ClassRecord rootRecord = NrbfDecoder.DecodeClassRecord(payload);
Sample output = new()
{
    // using the dedicated methods to read primitive values
    Integer = rootRecord.GetInt32(nameof(Sample.Integer)),
    Text = rootRecord.GetString(nameof(Sample.Text)),
    // using dedicated method to read an array of bytes
    ArrayOfBytes = ((SZArrayRecord<byte>)rootRecord.GetArrayRecord(nameof(Sample.ArrayOfBytes))).GetArray(),
    // using GetClassRecord to read a class record
    ClassInstance = new()
    {
        Text = rootRecord
            .GetClassRecord(nameof(Sample.ClassInstance))!
            .GetString(nameof(Sample.Text))
    }
};

Main Types

There are more than a dozen different serialization record types. This library provides a set of abstractions, so you only need to learn a few of them:

  • PrimitiveTypeRecord<T>: describes all primitive types natively supported by the NRBF (string, bool, byte, sbyte, char, short, ushort, int, uint, long, ulong, float, double, decimal, TimeSpan, and DateTime).
    • Exposes the value via the Value property.
    • PrimitiveTypeRecord<T> derives from the non-generic PrimitiveTypeRecord, which also exposes a Value property. But on the base class, the value is returned as object (which introduces boxing for value types).
  • ClassRecord: describes all class and struct besides the aforementioned primitive types.
  • ArrayRecord: describes all array records, including jagged and multi-dimensional arrays.
  • SZArrayRecord<T>: describes single-dimensional, zero-indexed array records, where T can be either a primitive type or a SerializationRecord.
SerializationRecord rootObject = NrbfDecoder.Decode(payload); // payload is a Stream

if (rootObject is PrimitiveTypeRecord primitiveRecord)
{
    Console.WriteLine($"It was a primitive value: '{primitiveRecord.Value}'");
}
else if (rootObject is ClassRecord classRecord)
{
    Console.WriteLine($"It was a class record of '{classRecord.TypeName.AssemblyQualifiedName}' type name.");
}
else if (rootObject is SZArrayRecord<byte> arrayOfBytes)
{
    Console.WriteLine($"It was an array of `{arrayOfBytes.Length}`-many bytes.");
}

Additional Documentation

Feedback & Contributing

System.Formats.Nrbf is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on System.Formats.Nrbf.

Packages Downloads
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild.
114
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild.
115
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild.
118
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild.
125
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild.
147
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
108
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
111
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
112
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
113
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
121
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
122
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
123
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
125
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
131
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
132
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
133
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
141
System.Resources.Extensions
Provides classes which read and write resources in a format that supports non-primitive objects. Commonly Used Types: System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter
155

https://go.microsoft.com/fwlink/?LinkID=799421

.NET 10.0

.NET 11.0

  • No dependencies.

.NET Framework 4.6.2

.NET Standard 2.0

Version Downloads Last updated
11.0.0-preview.7.26381.103 9 08/15/2026
11.0.0-preview.6.26359.118 15 07/17/2026
11.0.0-preview.5.26302.115 17 06/11/2026
11.0.0-preview.4.26230.115 16 05/14/2026
11.0.0-preview.3.26207.106 28 04/14/2026
11.0.0-preview.2.26159.112 41 03/12/2026
11.0.0-preview.1.26104.118 38 02/13/2026
10.0.11 10 08/15/2026
10.0.10 16 07/20/2026
10.0.9 17 06/11/2026
10.0.8 22 05/14/2026
10.0.7 31 04/21/2026
10.0.6 35 04/14/2026
10.0.5 37 03/13/2026
10.0.4 33 03/12/2026
10.0.3 36 02/13/2026
10.0.2 42 01/13/2026
10.0.1 50 12/11/2025
10.0.0 80 11/12/2025
10.0.0-rc.2.25502.107 79 10/15/2025
10.0.0-rc.1.25451.107 105 09/10/2025
10.0.0-preview.7.25380.108 96 08/14/2025
10.0.0-preview.6.25358.103 88 07/16/2025
10.0.0-preview.5.25277.114 111 06/10/2025
10.0.0-preview.4.25258.110 98 05/16/2025
10.0.0-preview.3.25171.5 107 04/12/2025
10.0.0-preview.2.25163.2 107 04/02/2025
10.0.0-preview.1.25080.5 105 04/04/2025
9.0.19 9 08/15/2026
9.0.18 13 07/19/2026
9.0.17 15 06/11/2026
9.0.16 21 05/14/2026
9.0.15 26 04/14/2026
9.0.14 34 03/12/2026
9.0.13 37 02/13/2026
9.0.12 48 01/13/2026
9.0.11 68 11/12/2025
9.0.10 96 10/15/2025
9.0.9 86 09/10/2025
9.0.8 93 08/09/2025
9.0.7 101 07/11/2025
9.0.6 112 06/12/2025
9.0.5 127 05/17/2025
9.0.4 106 04/12/2025
9.0.3 104 04/01/2025
9.0.2 120 04/01/2025
9.0.1 127 04/01/2025
9.0.0 133 11/14/2024
9.0.0-rc.2.24473.5 115 10/23/2024
9.0.0-rc.1.24431.7 118 10/21/2024
9.0.0-preview.7.24405.7 113 08/21/2024
9.0.0-preview.6.24327.7 123 07/22/2024