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

feat: support .NET 8.0 | Remove BinaryFormatter from TestingException #383

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -26,6 +26,7 @@ public TestingException(string message, Exception inner)
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Initializes a new instance of <see cref="TestingException" /> for serialization.
/// <para />
Expand All @@ -35,4 +36,5 @@ protected TestingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
#if !NET8_0_OR_GREATER
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Testably.Abstractions.Testing.FileSystemInitializer;

Expand All @@ -18,15 +19,16 @@ public void
byte[] buffer = new byte[4096];
using MemoryStream ms = new(buffer);
using MemoryStream ms2 = new(buffer);
#pragma warning disable SYSLIB0011 //BinaryFormatter serialization is obsolete - only used in unit test
BinaryFormatter formatter = new();
#pragma warning disable SYSLIB0011 //BinaryFormatter serialization is obsolete - only used in unit test
formatter.Serialize(ms, originalException);
TestingException deserializedException =
(TestingException)formatter.Deserialize(ms2);
#pragma warning restore SYSLIB0011
#pragma warning restore SYSLIB0011

Assert.Equal(originalException.InnerException?.Message,
deserializedException.InnerException?.Message);
Assert.Equal(originalException.Message, deserializedException.Message);
}
}
#endif
Loading