Skip to content

Commit 489c66a

Browse files
adamsitnikbartonjs
andauthored
Apply suggestions from code review
Co-authored-by: Jeremy Barton <[email protected]>
1 parent d524a92 commit 489c66a

File tree

7 files changed

+21
-16
lines changed

7 files changed

+21
-16
lines changed

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/ArrayRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private protected ArrayRecord(ArrayInfo arrayInfo)
6363
/// otherwise, <see langword="false" />.
6464
/// </param>
6565
/// <returns>An array filled with the data provided in the serialized records.</returns>
66-
/// <exception cref="InvalidOperationException"><paramref name="expectedArrayType" /> does not match the data from payload.</exception>
66+
/// <exception cref="InvalidOperationException"><paramref name="expectedArrayType" /> does not match the data from the payload.</exception>
6767
[RequiresDynamicCode("The code for an array of the specified type might not be available.")]
6868
public Array GetArray(Type expectedArrayType, bool allowNulls = true)
6969
{

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/ArraySinglePrimitiveRecord.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal static IReadOnlyList<T> DecodePrimitiveTypes(BinaryReader reader, int c
8383

8484
// Most of the tests use MemoryStream or FileStream and they both allow for executing the fast path.
8585
// To ensure the slow path is tested as well, the fast path is executed only for optimized builds.
86-
#if NETCOREAPP
86+
#if NET
8787
if (typeof(T) != typeof(decimal) && typeof(T) != typeof(DateTime) && typeof(T) != typeof(TimeSpan) // not optimized
8888
&& reader.IsDataAvailable(count * Unsafe.SizeOf<T>()))
8989
{
@@ -165,7 +165,7 @@ private static List<T> DecodePrimitiveTypesToList(BinaryReader reader, int count
165165
return values;
166166
}
167167

168-
#if NETCOREAPP
168+
#if NET
169169
private static T[] DecodePrimitiveTypesToArray(BinaryReader reader, int count)
170170
{
171171
T[] result = new T[count];

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/ObjectNullMultipleRecord.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ internal sealed class ObjectNullMultipleRecord : NullsRecord
2222

2323
internal static ObjectNullMultipleRecord Decode(BinaryReader reader)
2424
{
25+
// 2.5.5 ObjectNullMultiple
26+
27+
// NullCount (4 bytes): An INT32 value ... The value MUST be a positive integer.
2528
int count = reader.ReadInt32();
2629
if (count <= 0)
2730
{

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/PrimitiveTypeRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace System.Runtime.Serialization.BinaryFormat;
1212
/// <remarks>
1313
/// <para>
1414
/// The NRBF specification considers the following types to be primitive:
15-
/// <see langword="string"/>, <see cref="bool"/>, <see cref="byte"/>, <see cref="sbyte"/>
15+
/// <see cref="String"/>, <see cref="bool"/>, <see cref="byte"/>, <see cref="sbyte"/>
1616
/// <see cref="char"/>, <see cref="short"/>, <see cref="ushort"/>,
1717
/// <see cref="int"/>, <see cref="uint"/>, <see cref="long"/>, <see cref="ulong"/>,
1818
/// <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/>,

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/RecordType.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ enum RecordType : byte
2424
/// </summary>
2525
SerializedStreamHeader = 0,
2626
/// <summary>
27-
/// A class information that references another class record's metadata.
27+
/// Class information that references another class record's metadata.
2828
/// </summary>
2929
ClassWithId = 1,
30+
3031
// SystemClassWithMembers and ClassWithMembers are not supported by design (require type loading)
32+
3133
/// <summary>
3234
/// A system class information with type info.
3335
/// </summary>
@@ -41,7 +43,7 @@ enum RecordType : byte
4143
/// </summary>
4244
BinaryObjectString = 6,
4345
/// <summary>
44-
/// An array other than single dimensional array of primitive types and <see cref="object" />.
46+
/// An array of any rank or element type.
4547
/// </summary>
4648
BinaryArray = 7,
4749
/// <summary>
@@ -53,19 +55,19 @@ enum RecordType : byte
5355
/// </summary>
5456
MemberReference = 9,
5557
/// <summary>
56-
/// A <see langword="null" />.
58+
/// A single <see langword="null" /> value.
5759
/// </summary>
5860
ObjectNull = 10,
5961
/// <summary>
6062
/// The record that marks the end of the binary format stream.
6163
/// </summary>
6264
MessageEnd = 11,
6365
/// <summary>
64-
/// A library is a named unit that contains a collection of types.
66+
/// A record that associates a numeric identifier with a named library.
6567
/// </summary>
6668
BinaryLibrary = 12,
6769
/// <summary>
68-
/// Multiple (less than 256) <see langword="null" />.
70+
/// Multiple (less than 256) <see langword="null" /> values.
6971
/// </summary>
7072
ObjectNullMultiple256 = 13,
7173
/// <summary>
@@ -77,11 +79,11 @@ enum RecordType : byte
7779
/// </summary>
7880
ArraySinglePrimitive = 15,
7981
/// <summary>
80-
/// A single dimensional array of <see cref="object" />.
82+
/// A single-dimensional array of <see cref="object" /> values.
8183
/// </summary>
8284
ArraySingleObject = 16,
8385
/// <summary>
84-
/// A single dimensional array of <see langword="string" />.
86+
/// A single-dimensional array of <see langword="string" /> values.
8587
/// </summary>
8688
ArraySingleString = 17
8789
}

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/RectangularOrCustomOffsetArrayRecord.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ private RectangularOrCustomOffsetArrayRecord(Type elementType, ArrayInfo arrayIn
2828
// A List<T> can hold as many objects as an array, so for multi-dimensional arrays
2929
// with more elements than Array.MaxLength we use LinkedList.
3030
// Testing that many elements takes a LOT of time, so to ensure that both code paths are tested,
31-
// we always use LinkedList code path for non-Release builds.
32-
#if RELEASE
31+
// we always use LinkedList code path for Debug builds.
32+
#if DEBUG
33+
_values = new LinkedList<object>();
34+
#else
3335
_values = arrayInfo.TotalElementsCount <= ArrayInfo.MaxArrayLength
3436
? new List<object>(canPreAllocate ? arrayInfo.GetSZArrayLength() : Math.Min(4, arrayInfo.GetSZArrayLength()))
3537
: new LinkedList<object>();
36-
#else
37-
_values = new LinkedList<object>();
3838
#endif
3939

4040
}

src/libraries/System.Runtime.Serialization.BinaryFormat/src/System/Runtime/Serialization/BinaryFormat/SerializationRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal SerializationRecord() // others can't derive from this type
4848
/// <para>This method does NOT take into account member names or their types.</para>
4949
/// </remarks>
5050
/// <param name="type">The type to compare against.</param>
51-
/// <returns>True if the serialized type and assembly name match provided type.</returns>
51+
/// <returns><see langword="true" /> if the serialized type and assembly name match provided type; otherwise, <see langword="false" />.</returns>
5252
public virtual bool IsTypeNameMatching(Type type) => false;
5353

5454
/// <summary>

0 commit comments

Comments
 (0)