Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PayloadReader in System.Resources.Extensions #102379

Merged
merged 40 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
241157e
add System.Runtime.Serialization.BinaryFormat with tests
adamsitnik May 17, 2024
fdbaf50
set IsPackable to false so the package is not published anywhere, mak…
adamsitnik May 17, 2024
1da4a10
reference System.Runtime.Serialization.BinaryFormat in System.Resourc…
adamsitnik May 17, 2024
ba62c25
copy-paste the System.Windows.Forms.BinaryFormat code as is with no m…
adamsitnik May 17, 2024
f0c20fc
fix compiler errors caused by lack of global usings and supporting ol…
adamsitnik May 17, 2024
39dd889
change the namespace from System.Windows.Forms.BinaryFormat to System…
adamsitnik May 17, 2024
00608e4
switch
adamsitnik May 17, 2024
6354a91
try to handle the type and assembly name mangling
adamsitnik May 20, 2024
ba41ff0
Revert "try to handle the type and assembly name mangling"
adamsitnik May 20, 2024
cde8100
use BinaryFormatter as a fallback when we get NotSupportedException e…
adamsitnik May 20, 2024
3a90452
fix the bugs I've introduced when porting the code to older monikers
adamsitnik May 20, 2024
37200dc
fix the build error and remove outdated comment
adamsitnik May 20, 2024
6a36687
add switch and Compat tests that simply reference existing tests
adamsitnik May 20, 2024
d4de6ee
copy WinForms tests
adamsitnik May 22, 2024
1cb10c1
make the WinForms tests compile and pass:
adamsitnik May 22, 2024
eb0270f
fix the build (when creating a trimmed list, the serialized size must…
adamsitnik May 23, 2024
3b4cda3
change public API: ArrayRecord can represent multi-dimensional array …
adamsitnik May 23, 2024
cabd585
address code review feedback:
adamsitnik May 23, 2024
a92a528
remove the fallback to BF
adamsitnik May 24, 2024
6f6d03f
handle the type name mangling
adamsitnik May 24, 2024
891365f
fix the build?
adamsitnik May 24, 2024
7a60a3f
Apply suggestions from code review
adamsitnik May 27, 2024
ec629c9
Apply suggestions from code review
adamsitnik May 27, 2024
6fb3a54
Apply suggestions from code review
adamsitnik May 27, 2024
0b10f6b
address code review feedback:
adamsitnik May 27, 2024
a8c3948
don't run drawing tests on systems where drawing is not supported
adamsitnik May 28, 2024
b57bc2a
add WebSocketException to the exclusion list (because it's implementa…
adamsitnik May 28, 2024
a7134ef
address code review feedback:
adamsitnik May 29, 2024
42e8199
Apply suggestions from code review
adamsitnik Jun 3, 2024
00cb0a8
Apply suggestions from code review
adamsitnik Jun 3, 2024
243ec2e
address code review feedback:
adamsitnik Jun 3, 2024
c485e4a
optimize perf for reading arrays of primitive types, but keep it safe…
adamsitnik Jun 4, 2024
3c1e72c
rename ToArray to GetArray and avoid allocating new array if possible…
adamsitnik Jun 4, 2024
f175ff6
solve last TODO: fix max size array support by avoiding Int32 overflo…
adamsitnik Jun 5, 2024
d524a92
fix the build
adamsitnik Jun 5, 2024
489c66a
Apply suggestions from code review
adamsitnik Jun 6, 2024
697cb0a
address code review feedback:
adamsitnik Jun 6, 2024
e3d1a7b
Merge remote-tracking branch 'upstream/main' into plan
adamsitnik Jun 6, 2024
fdbd424
improve arrays support:
adamsitnik Jun 7, 2024
3eefd4e
Don't check if serialized DataTable and DataSet produce exact same by…
adamsitnik Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,25 @@ private bool ValidateReaderType(string readerType)
#pragma warning disable SYSLIB0011
private object ReadBinaryFormattedObject()
{
BinaryFormattedObject binaryFormattedObject = new BinaryFormattedObject(_store.BaseStream,
new BinaryFormattedObject.Options()
long position = _store.BaseStream.CanSeek ? _store.BaseStream.Position : -1;

try
{
BinaryFormattedObject binaryFormattedObject = new BinaryFormattedObject(_store.BaseStream);
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved

return binaryFormattedObject.Deserialize();
}
catch (NotSupportedException) when (position >= 0)
{
_store.BaseStream.Position = position;

BinaryFormatter? formatter = new()
{
Binder = new UndoTruncatedTypeNameSerializationBinder()
});
};

return binaryFormattedObject.Deserialize();
return formatter.Deserialize(_store.BaseStream);
}
}
#pragma warning restore SYSLIB0011

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ internal static TypeName ReadTypeName(this BinaryReader binaryReader, PayloadOpt
string name = binaryReader.ReadString();
if (!TypeName.TryParse(name.AsSpan(), out TypeName? typeName, options.TypeNameParseOptions))
{
throw new SerializationException($"Invalid type name: '{name}'");
throw
#if SYSTEM_RUNTIME_SERIALIZATION_BINARYFORMAT
new SerializationException
#else
new NotSupportedException
#endif
($"Invalid type name: '{name}'");
}
else if (typeName.AssemblyName is not null)
{
Expand All @@ -83,7 +89,13 @@ internal static AssemblyNameInfo ReadLibraryName(this BinaryReader binaryReader)
string name = binaryReader.ReadString();
if (!AssemblyNameInfo.TryParse(name.AsSpan(), out AssemblyNameInfo? libraryName))
{
throw new SerializationException($"Invalid library name: '{name}'");
throw
#if SYSTEM_RUNTIME_SERIALIZATION_BINARYFORMAT
new SerializationException
#else
new NotSupportedException
#endif
($"Invalid library name: '{name}'");
}

return libraryName;
Expand Down