Skip to content

Commit 5b18482

Browse files
authored
Update NRBF docs with upcoming breaking change (#42735)
1 parent 03ad3fe commit 5b18482

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/standard/serialization/binaryformatter-migration-guide/read-nrbf-payloads.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ The API it provides:
135135
- <xref:System.Formats.Nrbf.ClassRecord.HasMember*> method that checks if member of given name was present in the payload. It was designed for handling versioning scenarios where given member could have been renamed.
136136
- A set of dedicated methods for retrieving primitive values of the provided member name: <xref:System.Formats.Nrbf.ClassRecord.GetString*>, <xref:System.Formats.Nrbf.ClassRecord.GetBoolean*>, <xref:System.Formats.Nrbf.ClassRecord.GetByte*>, <xref:System.Formats.Nrbf.ClassRecord.GetSByte*>, <xref:System.Formats.Nrbf.ClassRecord.GetChar*>, <xref:System.Formats.Nrbf.ClassRecord.GetInt16*>, <xref:System.Formats.Nrbf.ClassRecord.GetUInt16*>, <xref:System.Formats.Nrbf.ClassRecord.GetInt32*>, <xref:System.Formats.Nrbf.ClassRecord.GetUInt32*>, <xref:System.Formats.Nrbf.ClassRecord.GetInt64*>, <xref:System.Formats.Nrbf.ClassRecord.GetUInt64*>, <xref:System.Formats.Nrbf.ClassRecord.GetSingle*>, <xref:System.Formats.Nrbf.ClassRecord.GetDouble*>, <xref:System.Formats.Nrbf.ClassRecord.GetDecimal*>, <xref:System.Formats.Nrbf.ClassRecord.GetTimeSpan*>, and <xref:System.Formats.Nrbf.ClassRecord.GetDateTime*>.
137137
- <xref:System.Formats.Nrbf.ClassRecord.GetClassRecord*> and <xref:System.Formats.Nrbf.ClassRecord.GetArrayRecord*> methods to retrieve instance of given record types.
138-
- <xref:System.Formats.Nrbf.ClassRecord.GetSerializationRecord*> to retrieve any serialization record and <<xref:System.Formats.Nrbf.ClassRecord.GetRawValue*> to retrieve any serialization record or a raw primitive value.
138+
- <xref:System.Formats.Nrbf.ClassRecord.GetSerializationRecord*> to retrieve any serialization record and <xref:System.Formats.Nrbf.ClassRecord.GetRawValue*> to retrieve any serialization record or a raw primitive value.
139139

140140
The following code snippet shows <xref:System.Formats.Nrbf.ClassRecord> in action:
141141

@@ -185,7 +185,7 @@ int[,] array2d = (int[,])arrayRecord.GetArray(typeof(int[,]));
185185

186186
If there is a type mismatch (example: the attacker has provided a payload with an array of two billion strings), the method throws <xref:System.InvalidOperationException>.
187187

188-
[NrbfDecoder] does not load or instantiate any custom types, so in case of arrays of complex types, it returns an array of <xref:System.Formats.Nrbf.ClassRecord>.
188+
[NrbfDecoder] does not load or instantiate any custom types, so in case of arrays of complex types, it returns an array of <xref:System.Formats.Nrbf.SerializationRecord>.
189189

190190
```csharp
191191
[Serializable]
@@ -195,8 +195,8 @@ public class ComplexType3D
195195
}
196196

197197
ArrayRecord arrayRecord = (ArrayRecord)NrbfDecoder.Decode(payload);
198-
ClassRecord[] records = (ClassRecord[])arrayRecord.GetArray(expectedArrayType: typeof(ComplexType3D[]));
199-
ComplexType3D[] output = records.Select(classRecord => new ComplexType3D()
198+
SerializationRecord[] records = (SerializationRecord[])arrayRecord.GetArray(expectedArrayType: typeof(ComplexType3D[]));
199+
ComplexType3D[] output = records.OfType<ClassRecord>().Select(classRecord => new ComplexType3D()
200200
{
201201
I = classRecord.GetInt32(nameof(ComplexType3D.I)),
202202
J = classRecord.GetInt32(nameof(ComplexType3D.J)),
@@ -209,7 +209,7 @@ ComplexType3D[] output = records.Select(classRecord => new ComplexType3D()
209209

210210
#### SZArrayRecord
211211

212-
`SZArrayRecord<T>` defines the core behavior for NRBF single dimensional, zero-indexed array records and provides a base for derived classes. The `T` can be one of the natively supported primitive types or <xref:System.Formats.Nrbf.ClassRecord>.
212+
`SZArrayRecord<T>` defines the core behavior for NRBF single dimensional, zero-indexed array records and provides a base for derived classes. The `T` can be one of the natively supported primitive types or <xref:System.Formats.Nrbf.SerializationRecord>.
213213

214214
It provides a <xref:System.Formats.Nrbf.SZArrayRecord%601.Length> property and a <xref:System.Formats.Nrbf.SZArrayRecord%601.GetArray*> overload that returns `T[]`.
215215

0 commit comments

Comments
 (0)