Skip to content

Commit 3388e3e

Browse files
Copilotadamsitnik
andauthored
Remove ArrayRecord comment and allocation test
Co-authored-by: adamsitnik <[email protected]>
1 parent 4402d26 commit 3388e3e

2 files changed

Lines changed: 0 additions & 63 deletions

File tree

‎src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayRecord.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ private void HandleNext(object value, NextInfo info, int size)
114114

115115
internal abstract (AllowedRecordTypes allowed, PrimitiveType primitiveType) GetAllowedRecordType();
116116

117-
// Every record represents a single value, except for the Multiple Null Records which represent more than one null.
118-
// When nulls are allowed, Multiple Null Records are permitted and the record count is not expected to match the total element count.
119117
private protected void CheckExpectedRecordCount(List<SerializationRecord> records, bool allowNulls)
120118
{
121119
if (!allowNulls && ArrayInfo.FlattenedLength != records.Count)

‎src/libraries/System.Formats.Nrbf/tests/ArrayOfSerializationRecordsTests.cs‎

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -513,66 +513,5 @@ private static void Verify(Array input, ArrayRecord arrayRecord, Array output,
513513
}
514514
}
515515

516-
#if !NETFRAMEWORK
517-
// GC.GetAllocatedBytesForCurrentThread() is not available on Full Framework.
518-
[Theory]
519-
[InlineData(SerializationRecordType.ArraySingleObject)]
520-
[InlineData(SerializationRecordType.ArraySingleString)]
521-
[InlineData(SerializationRecordType.BinaryArray)]
522-
public void GetArray_AllowNullsFalse_DoesNotAllocateLargeArray_WhenMultipleNullRecordIsPresent(SerializationRecordType recordType)
523-
{
524-
// The test needs to ensure that 2GB+ array does not get allocated.
525-
// 200k is enough to get the job done and avoid getting false positives.
526-
const long AllocationThreshold = 200_000;
527-
528-
using MemoryStream stream = new();
529-
BinaryWriter writer = new(stream, Text.Encoding.UTF8);
530-
531-
WriteSerializedStreamHeader(writer);
532-
533-
writer.Write((byte)recordType);
534-
writer.Write(1); // object ID
535-
536-
if (recordType is SerializationRecordType.BinaryArray)
537-
{
538-
writer.Write((byte)BinaryArrayType.Single);
539-
writer.Write(1); // rank
540-
writer.Write(Array.MaxLength); // length
541-
writer.Write((byte)3); // BinaryType.SystemClass
542-
writer.Write("System.Exception"); // element type name
543-
}
544-
else
545-
{
546-
writer.Write(Array.MaxLength); // length
547-
}
548-
549-
writer.Write((byte)SerializationRecordType.ObjectNullMultiple);
550-
writer.Write(Array.MaxLength); // null count
551-
writer.Write((byte)SerializationRecordType.MessageEnd);
552-
553-
stream.Position = 0;
554-
555-
SerializationRecord serializationRecord = NrbfDecoder.Decode(stream);
556-
Assert.Equal(recordType, serializationRecord.RecordType);
557-
558-
long before = GC.GetAllocatedBytesForCurrentThread();
559-
560-
Assert.Throws<SerializationException>(() =>
561-
{
562-
if (serializationRecord is SZArrayRecord<string> arrayOfStrings)
563-
{
564-
arrayOfStrings.GetArray(allowNulls: false);
565-
}
566-
else
567-
{
568-
((SZArrayRecord<SerializationRecord>)serializationRecord).GetArray(allowNulls: false);
569-
}
570-
});
571-
572-
long after = GC.GetAllocatedBytesForCurrentThread();
573-
574-
Assert.InRange(after, before, before + AllocationThreshold);
575-
}
576-
#endif
577516
}
578517
}

0 commit comments

Comments
 (0)