Skip to content

Commit 00608e4

Browse files
committed
switch
1 parent 39dd889 commit 00608e4

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.ComponentModel;
55
using System.IO;
6+
using System.Resources.Extensions.BinaryFormat;
67
using System.Runtime.Serialization;
78
using System.Runtime.Serialization.Formatters.Binary;
89

@@ -12,11 +13,6 @@ public partial class DeserializingResourceReader
1213
{
1314
private bool _assumeBinaryFormatter;
1415

15-
// Issue https://github.com/dotnet/runtime/issues/39292 tracks finding an alternative to BinaryFormatter
16-
#pragma warning disable SYSLIB0011
17-
private BinaryFormatter? _formatter;
18-
#pragma warning restore SYSLIB0011
19-
2016
private bool ValidateReaderType(string readerType)
2117
{
2218
// our format?
@@ -41,12 +37,13 @@ private bool ValidateReaderType(string readerType)
4137
#pragma warning disable SYSLIB0011
4238
private object ReadBinaryFormattedObject()
4339
{
44-
_formatter ??= new BinaryFormatter()
45-
{
46-
Binder = new UndoTruncatedTypeNameSerializationBinder()
47-
};
40+
BinaryFormattedObject binaryFormattedObject = new BinaryFormattedObject(_store.BaseStream,
41+
new BinaryFormattedObject.Options()
42+
{
43+
Binder = new UndoTruncatedTypeNameSerializationBinder()
44+
});
4845

49-
return _formatter.Deserialize(_store.BaseStream);
46+
return binaryFormattedObject.Deserialize();
5047
}
5148
#pragma warning restore SYSLIB0011
5249

0 commit comments

Comments
 (0)