Skip to content

Commit b3b6af9

Browse files
adamsitnikericstj
authored andcommitted
Switch to System.Formats.Nrbf (#9465)
* 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 Fixed conflict in Versions.props, and added missing entry to Version.Details.xml
1 parent a4eda13 commit b3b6af9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+498
-2574
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
<Uri>https://github.com/dotnet/runtime</Uri>
9696
<Sha>bdcf3ef75e11d22e4973bf37f2d5b660b73aa266</Sha>
9797
</Dependency>
98+
<Dependency Name="System.Formats.Nrbf" Version="9.0.0-preview.7.24376.15" CoherentParentDependency="Microsoft.Private.Winforms">
99+
<Uri>https://github.com/dotnet/runtime</Uri>
100+
<Sha>bdcf3ef75e11d22e4973bf37f2d5b660b73aa266</Sha>
101+
</Dependency>
98102
<Dependency Name="System.IO.Packaging" Version="9.0.0-preview.7.24376.15" CoherentParentDependency="Microsoft.Private.Winforms">
99103
<Uri>https://github.com/dotnet/runtime</Uri>
100104
<Sha>bdcf3ef75e11d22e4973bf37f2d5b660b73aa266</Sha>

eng/Versions.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<SystemDiagnosticsEventLogPackageVersion>9.0.0-preview.7.24376.15</SystemDiagnosticsEventLogPackageVersion>
3535
<SystemDrawingCommonVersion>9.0.0-preview.7.24379.1</SystemDrawingCommonVersion>
3636
<SystemDirectoryServicesVersion>9.0.0-preview.7.24376.15</SystemDirectoryServicesVersion>
37+
<SystemFormatsNrbfVersion>9.0.0-preview.7.24376.15</SystemFormatsNrbfVersion>
3738
<SystemIOPackagingVersion>9.0.0-preview.7.24376.15</SystemIOPackagingVersion>
3839
<SystemReflectionMetadataLoadContextVersion>9.0.0-preview.7.24376.15</SystemReflectionMetadataLoadContextVersion>
3940
<SystemReflectionTypeExtensionsPackageVersion>4.6.0-preview4.19176.11</SystemReflectionTypeExtensionsPackageVersion>
@@ -66,14 +67,14 @@
6667
<PropertyGroup>
6768
<MicrosoftBuildFrameworkPackageVersion>15.9.20</MicrosoftBuildFrameworkPackageVersion>
6869
<MicrosoftBuildUtilitiesCorePackageVersion>15.9.20</MicrosoftBuildUtilitiesCorePackageVersion>
69-
<!--
70-
Also in global.json
71-
Used in Wpf.Cpp.PrivateTools.props/targets
70+
<!--
71+
Also in global.json
72+
Used in Wpf.Cpp.PrivateTools.props/targets
7273
<MsvcurtC1xxVersion>0.0.1.2</MsvcurtC1xxVersion>
7374
-->
7475
<!--
7576
This is the version of the test infrastructure package is compiled against. This should be
76-
removed as part of https://github.com/dotnet/wpf/issues/816
77+
removed as part of https://github.com/dotnet/wpf/issues/816
7778
-->
7879
<MicrosoftDotNetWpfTestPackageVersion>1.0.0-beta.19263.1</MicrosoftDotNetWpfTestPackageVersion>
7980
<!-- These versions are specified in global.json -->

src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,15 @@
338338
<Compile Include="System\Windows\BinaryFormat\BinaryFormatWriterScope.cs" />
339339
<Compile Include="System\Windows\BinaryFormat\ExceptionExtensions.cs" />
340340
<Compile Include="System\Windows\BinaryFormat\BinaryObjectString.cs" />
341-
<Compile Include="System\Windows\BinaryFormat\IBinaryFormatParseable.cs" />
342341
<Compile Include="System\Windows\BinaryFormat\IBinaryWriteable.cs" />
343342
<Compile Include="System\Windows\BinaryFormat\MemberTypeInfo.cs" />
344343
<Compile Include="System\Windows\BinaryFormat\Id.cs" />
345344
<Compile Include="System\Windows\BinaryFormat\IRecord.cs" />
346-
<Compile Include="System\Windows\BinaryFormat\RecordMap.cs" />
347345
<Compile Include="System\Windows\BinaryFormat\RecordType.cs" />
348-
<Compile Include="System\Windows\BinaryFormat\NullableAttributes.cs" />
349346
<Compile Include="System\Windows\BinaryFormat\ListConverterHelper.cs" />
350347
<Compile Include="System\Windows\BinaryFormat\FormatterConverterStub.cs" />
351348
<Compile Include="System\Windows\BinaryFormat\SerializationExtensions.cs" />
352-
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObject.cs" />
353-
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObjectExtensions.cs" />
349+
<Compile Include="System\Windows\Nrbf\SerializationRecordExtensions.cs" />
354350
<Compile Include="System\Windows\BinaryFormat\MessageEnd.cs" />
355351
<Compile Include="System\Windows\BinaryFormat\Record.cs" />
356352
<Compile Include="System\Windows\BinaryFormat\BinaryType.cs" />
@@ -366,19 +362,14 @@
366362
<Compile Include="System\Windows\BinaryFormat\BinaryLibrary.cs" />
367363
<Compile Include="System\Windows\BinaryFormat\MemberReference.cs" />
368364
<Compile Include="System\Windows\BinaryFormat\MemberPrimitiveTyped.cs" />
369-
<Compile Include="System\Windows\BinaryFormat\BinaryArray.cs" />
370365
<Compile Include="System\Windows\BinaryFormat\ClassWithMembersAndTypes.cs" />
371366
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembersAndTypes.cs" />
372367
<Compile Include="System\Windows\BinaryFormat\ClassInfo.cs" />
373368
<Compile Include="System\Windows\BinaryFormat\ClassRecord.cs" />
374369
<Compile Include="System\Windows\BinaryFormat\ClassWithId.cs" />
375370
<Compile Include="System\Windows\BinaryFormat\TypeInfo.cs" />
376-
<Compile Include="System\Windows\BinaryFormat\ClassWithMembers.cs" />
377-
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembers.cs" />
378371
<Compile Include="System\Windows\BinaryFormat\SerializationHeader.cs" />
379372
<Compile Include="System\Windows\BinaryFormat\ClassTypeInfo.cs" />
380-
<Compile Include="System\Windows\BinaryFormat\BinaryArrayType.cs" />
381-
<Compile Include="System\Windows\BinaryFormat\BinaryReaderExtensions.cs" />
382373
<Compile Include="System\Windows\BinaryFormat\BinaryWriterExtensions.cs" />
383374
<Compile Include="System\Windows\BinaryFormat\IntrinsicExtensions.cs" />
384375
<Compile Include="System\Windows\BinaryFormat\NullRecord.ObjectNullMultiple.cs" />
@@ -1480,6 +1471,7 @@
14801471
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="$(SystemRuntimeSerializationFormattersPackageVersion)" PrivateAssets="contentfiles;analyzers;build" />
14811472
<PackageReference Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
14821473
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
1474+
<PackageReference Include="System.Formats.Nrbf" Version="$(SystemFormatsNrbfVersion)" />
14831475
</ItemGroup>
14841476

14851477
<ItemGroup>

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ArrayInfo.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ public ArrayInfo(Id objectId, Count length)
2626
ObjectId = objectId;
2727
}
2828

29-
public static ArrayInfo Parse(BinaryReader reader, out Count length)
30-
{
31-
ArrayInfo arrayInfo = new(reader.ReadInt32(), reader.ReadInt32());
32-
length = arrayInfo.Length;
33-
return arrayInfo;
34-
}
35-
3629
public readonly void Write(BinaryWriter writer)
3730
{
3831
writer.Write(ObjectId);

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ArraySingleObject.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,14 @@ namespace System.Windows
1616
/// </see>
1717
/// </para>
1818
/// </remarks>
19-
internal sealed class ArraySingleObject : ArrayRecord, IRecord<ArraySingleObject>
19+
internal sealed class ArraySingleObject : ArrayRecord
2020
{
2121
public static RecordType RecordType => RecordType.ArraySingleObject;
2222

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

27-
static ArraySingleObject IBinaryFormatParseable<ArraySingleObject>.Parse(
28-
BinaryReader reader,
29-
RecordMap recordMap)
30-
{
31-
ArraySingleObject record = new(
32-
ArrayInfo.Parse(reader, out Count length),
33-
ReadRecords(reader, recordMap, length));
34-
35-
recordMap[record.ObjectId] = record;
36-
return record;
37-
}
38-
3927
public override void Write(BinaryWriter writer)
4028
{
4129
writer.Write((byte)RecordType);

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ArraySinglePrimitive.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace System.Windows
1616
/// </see>
1717
/// </para>
1818
/// </remarks>
19-
internal sealed class ArraySinglePrimitive : ArrayRecord, IRecord<ArraySinglePrimitive>
19+
internal sealed class ArraySinglePrimitive : ArrayRecord
2020
{
2121
public PrimitiveType PrimitiveType { get; }
2222

@@ -28,22 +28,6 @@ public ArraySinglePrimitive(ArrayInfo arrayInfo, PrimitiveType primitiveType, IR
2828
PrimitiveType = primitiveType;
2929
}
3030

31-
static ArraySinglePrimitive IBinaryFormatParseable<ArraySinglePrimitive>.Parse(
32-
BinaryReader reader,
33-
RecordMap recordMap)
34-
{
35-
ArrayInfo arrayInfo = ArrayInfo.Parse(reader, out Count length);
36-
PrimitiveType primitiveType = (PrimitiveType)reader.ReadByte();
37-
38-
ArraySinglePrimitive record = new(
39-
arrayInfo,
40-
primitiveType,
41-
ReadPrimitiveTypes(reader, primitiveType, length));
42-
43-
recordMap[record.ObjectId] = record;
44-
return record;
45-
}
46-
4731
public override void Write(BinaryWriter writer)
4832
{
4933
writer.Write((byte)RecordType);

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ArraySingleString.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,14 @@ namespace System.Windows
1717
/// </see>
1818
/// </para>
1919
/// </remarks>
20-
internal sealed class ArraySingleString : ArrayRecord, IRecord<ArraySingleString>
20+
internal sealed class ArraySingleString : ArrayRecord
2121
{
2222
public static RecordType RecordType => RecordType.ArraySingleString;
2323

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

28-
static ArraySingleString IBinaryFormatParseable<ArraySingleString>.Parse(
29-
BinaryReader reader,
30-
RecordMap recordMap)
31-
{
32-
ArraySingleString record = new(
33-
ArrayInfo.Parse(reader, out Count length),
34-
ReadRecords(reader, recordMap, length));
35-
36-
recordMap[record.ObjectId] = record;
37-
return record;
38-
}
39-
4028
public override void Write(BinaryWriter writer)
4129
{
4230
writer.Write((byte)RecordType);

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/BinaryArray.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/BinaryArrayType.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/BinaryFormattedObject.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)