Skip to content

Commit bf29c66

Browse files
committed
Implement serialization for exceptions.
1 parent cde35a2 commit bf29c66

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/MySqlConnector/MySqlConversionException.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
using System;
2+
#if !NETSTANDARD1_3
3+
using System.Runtime.Serialization;
4+
#endif
25

36
namespace MySqlConnector
47
{
58
/// <summary>
69
/// <see cref="MySqlConversionException"/> is thrown when a MySQL value can't be converted to another type.
710
/// </summary>
11+
#if !NETSTANDARD1_3
12+
[Serializable]
13+
#endif
814
public class MySqlConversionException : Exception
915
{
1016
/// <summary>
@@ -15,5 +21,12 @@ public MySqlConversionException(string message)
1521
: base(message)
1622
{
1723
}
24+
25+
#if !NETSTANDARD1_3
26+
private MySqlConversionException(SerializationInfo info, StreamingContext context)
27+
: base(info, context)
28+
{
29+
}
30+
#endif
1831
}
1932
}

src/MySqlConnector/MySqlProtocolException.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
using System;
2+
#if !NETSTANDARD1_3
3+
using System.Runtime.Serialization;
4+
#endif
25
using MySqlConnector.Utilities;
36

47
namespace MySqlConnector
58
{
69
/// <summary>
710
/// <see cref="MySqlProtocolException"/> is thrown when there is an internal protocol error communicating with MySQL Server.
811
/// </summary>
12+
#if !NETSTANDARD1_3
13+
[Serializable]
14+
#endif
915
public sealed class MySqlProtocolException : InvalidOperationException
1016
{
1117
/// <summary>
@@ -17,6 +23,13 @@ public sealed class MySqlProtocolException : InvalidOperationException
1723
internal static MySqlProtocolException CreateForPacketOutOfOrder(int expectedSequenceNumber, int packetSequenceNumber) =>
1824
new MySqlProtocolException("Packet received out-of-order. Expected {0}; got {1}.".FormatInvariant(expectedSequenceNumber, packetSequenceNumber));
1925

26+
#if !NETSTANDARD1_3
27+
private MySqlProtocolException(SerializationInfo info, StreamingContext context)
28+
: base(info, context)
29+
{
30+
}
31+
#endif
32+
2033
private MySqlProtocolException(string message)
2134
: base(message)
2235
{

0 commit comments

Comments
 (0)