Skip to content

Commit

Permalink
Switch to System.Formats.Nrbf (#9465)
Browse files Browse the repository at this point in the history
* install the System.Formats.Nrbf package

* switch to the new API

* remove unused methods

* remove everything related to parsing NRBF payloads and records that don't support writing

* try to fix and update the tests

* remove more unused code
  • Loading branch information
adamsitnik authored Jul 30, 2024
1 parent cf89480 commit 4c0bdd0
Show file tree
Hide file tree
Showing 59 changed files with 490 additions and 2,570 deletions.
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<SystemDiagnosticsEventLogPackageVersion>9.0.0-rc.1.24379.3</SystemDiagnosticsEventLogPackageVersion>
<SystemDrawingCommonVersion>9.0.0-rc.1.24379.3</SystemDrawingCommonVersion>
<SystemDirectoryServicesVersion>9.0.0-rc.1.24379.3</SystemDirectoryServicesVersion>
<SystemFormatsNrbfVersion>9.0.0-rc.1.24379.3</SystemFormatsNrbfVersion>

This comment has been minimized.

Copy link
@ericstj

ericstj Aug 1, 2024

Member

It looks like you might have missed adding to Version.Details.xml

<SystemIOPackagingVersion>9.0.0-rc.1.24379.3</SystemIOPackagingVersion>
<SystemReflectionMetadataLoadContextVersion>9.0.0-rc.1.24379.3</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionTypeExtensionsPackageVersion>4.6.0-preview4.19176.11</SystemReflectionTypeExtensionsPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,15 @@
<Compile Include="System\Windows\BinaryFormat\BinaryFormatWriterScope.cs" />
<Compile Include="System\Windows\BinaryFormat\ExceptionExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryObjectString.cs" />
<Compile Include="System\Windows\BinaryFormat\IBinaryFormatParseable.cs" />
<Compile Include="System\Windows\BinaryFormat\IBinaryWriteable.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberTypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\Id.cs" />
<Compile Include="System\Windows\BinaryFormat\IRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\RecordMap.cs" />
<Compile Include="System\Windows\BinaryFormat\RecordType.cs" />
<Compile Include="System\Windows\BinaryFormat\NullableAttributes.cs" />
<Compile Include="System\Windows\BinaryFormat\ListConverterHelper.cs" />
<Compile Include="System\Windows\BinaryFormat\FormatterConverterStub.cs" />
<Compile Include="System\Windows\BinaryFormat\SerializationExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObject.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObjectExtensions.cs" />
<Compile Include="System\Windows\Nrbf\SerializationRecordExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\MessageEnd.cs" />
<Compile Include="System\Windows\BinaryFormat\Record.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryType.cs" />
Expand All @@ -366,19 +362,14 @@
<Compile Include="System\Windows\BinaryFormat\BinaryLibrary.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberReference.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberPrimitiveTyped.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryArray.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithMembersAndTypes.cs" />
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembersAndTypes.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithId.cs" />
<Compile Include="System\Windows\BinaryFormat\TypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithMembers.cs" />
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembers.cs" />
<Compile Include="System\Windows\BinaryFormat\SerializationHeader.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassTypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryArrayType.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryReaderExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryWriterExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\IntrinsicExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\NullRecord.ObjectNullMultiple.cs" />
Expand Down Expand Up @@ -1480,6 +1471,7 @@
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="$(SystemRuntimeSerializationFormattersPackageVersion)" PrivateAssets="contentfiles;analyzers;build" />
<PackageReference Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
<PackageReference Include="System.Formats.Nrbf" Version="$(SystemFormatsNrbfVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ public ArrayInfo(Id objectId, Count length)
ObjectId = objectId;
}

public static ArrayInfo Parse(BinaryReader reader, out Count length)
{
ArrayInfo arrayInfo = new(reader.ReadInt32(), reader.ReadInt32());
length = arrayInfo.Length;
return arrayInfo;
}

public readonly void Write(BinaryWriter writer)
{
writer.Write(ObjectId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@ namespace System.Windows
/// </see>
/// </para>
/// </remarks>
internal sealed class ArraySingleObject : ArrayRecord, IRecord<ArraySingleObject>
internal sealed class ArraySingleObject : ArrayRecord
{
public static RecordType RecordType => RecordType.ArraySingleObject;

public ArraySingleObject(ArrayInfo arrayInfo, IReadOnlyList<object> arrayObjects)
: base(arrayInfo, arrayObjects)
{ }

static ArraySingleObject IBinaryFormatParseable<ArraySingleObject>.Parse(
BinaryReader reader,
RecordMap recordMap)
{
ArraySingleObject record = new(
ArrayInfo.Parse(reader, out Count length),
ReadRecords(reader, recordMap, length));

recordMap[record.ObjectId] = record;
return record;
}

public override void Write(BinaryWriter writer)
{
writer.Write((byte)RecordType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace System.Windows
/// </see>
/// </para>
/// </remarks>
internal sealed class ArraySinglePrimitive : ArrayRecord, IRecord<ArraySinglePrimitive>
internal sealed class ArraySinglePrimitive : ArrayRecord
{
public PrimitiveType PrimitiveType { get; }

Expand All @@ -28,22 +28,6 @@ public ArraySinglePrimitive(ArrayInfo arrayInfo, PrimitiveType primitiveType, IR
PrimitiveType = primitiveType;
}

static ArraySinglePrimitive IBinaryFormatParseable<ArraySinglePrimitive>.Parse(
BinaryReader reader,
RecordMap recordMap)
{
ArrayInfo arrayInfo = ArrayInfo.Parse(reader, out Count length);
PrimitiveType primitiveType = (PrimitiveType)reader.ReadByte();

ArraySinglePrimitive record = new(
arrayInfo,
primitiveType,
ReadPrimitiveTypes(reader, primitiveType, length));

recordMap[record.ObjectId] = record;
return record;
}

public override void Write(BinaryWriter writer)
{
writer.Write((byte)RecordType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,14 @@ namespace System.Windows
/// </see>
/// </para>
/// </remarks>
internal sealed class ArraySingleString : ArrayRecord, IRecord<ArraySingleString>
internal sealed class ArraySingleString : ArrayRecord
{
public static RecordType RecordType => RecordType.ArraySingleString;

public ArraySingleString(ArrayInfo arrayInfo, IReadOnlyList<object> arrayObjects)
: base(arrayInfo, arrayObjects)
{ }

static ArraySingleString IBinaryFormatParseable<ArraySingleString>.Parse(
BinaryReader reader,
RecordMap recordMap)
{
ArraySingleString record = new(
ArrayInfo.Parse(reader, out Count length),
ReadRecords(reader, recordMap, length));

recordMap[record.ObjectId] = record;
return record;
}

public override void Write(BinaryWriter writer)
{
writer.Write((byte)RecordType);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4c0bdd0

Please sign in to comment.