File tree Expand file tree Collapse file tree 4 files changed +53
-1
lines changed
src/MySqlConnector/MySql.Data.MySqlClient
tests/MySqlConnector.Tests Expand file tree Collapse file tree 4 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -146,3 +146,4 @@ The following bugs in Connector/NET are fixed by switching to MySqlConnector. (~
146
146
* [ #93220 ] ( https://bugs.mysql.com/bug.php?id=93220 ) : Can’t call FUNCTION when parameter name contains parentheses
147
147
* [ #93370 ] ( https://bugs.mysql.com/bug.php?id=93370 ) : ` MySqlParameterCollection.Add ` precondition check isn't consistent
148
148
* [ #93374 ] ( https://bugs.mysql.com/bug.php?id=93374 ) : ` MySqlDataReader.GetStream ` throws ` IndexOutOfRangeException `
149
+ * [ #93825 ] ( https://bugs.mysql.com/bug.php?id=93825 ) : ` MySqlException ` loses data when serialized
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Data . Common ;
3
+ #if ! NETSTANDARD1_3
4
+ using System . Runtime . Serialization ;
5
+ #endif
3
6
4
7
namespace MySql . Data . MySqlClient
5
8
{
9
+ #if ! NETSTANDARD1_3
10
+ [ Serializable ]
11
+ #endif
6
12
public sealed class MySqlException : DbException
7
13
{
8
14
public int Number { get ; }
9
15
public string SqlState { get ; }
10
16
17
+ #if ! NETSTANDARD1_3
18
+ private MySqlException ( SerializationInfo info , StreamingContext context )
19
+ : base ( info , context )
20
+ {
21
+ Number = info . GetInt32 ( "Number" ) ;
22
+ SqlState = info . GetString ( "SqlState" ) ;
23
+ }
24
+
25
+ public override void GetObjectData ( SerializationInfo info , StreamingContext context )
26
+ {
27
+ base . GetObjectData ( info , context ) ;
28
+ info . AddValue ( "Number" , Number ) ;
29
+ info . AddValue ( "SqlState" , SqlState ) ;
30
+ }
31
+ #endif
32
+
11
33
internal MySqlException ( string message )
12
34
: this ( message , null )
13
35
{
Original file line number Diff line number Diff line change 32
32
33
33
<ItemGroup Condition =" '$(Configuration)' == 'Baseline' " >
34
34
<PackageReference Include =" MySql.Data" Version =" 8.0.13" />
35
- <Compile Remove =" ByteBufferWriterTests.cs;CachedProcedureTests.cs;ConnectionTests.cs;FakeMySqlServer.cs;FakeMySqlServerConnection.cs;LoadBalancerTests.cs;NormalizeTests.cs;StatementPreparerTests.cs;TypeMapperTests.cs;UtilityTests.cs" />
35
+ <Compile Remove =" ByteBufferWriterTests.cs;CachedProcedureTests.cs;ConnectionTests.cs;FakeMySqlServer.cs;FakeMySqlServerConnection.cs;LoadBalancerTests.cs;MySqlExceptionTests.cs; NormalizeTests.cs;StatementPreparerTests.cs;TypeMapperTests.cs;UtilityTests.cs" />
36
36
</ItemGroup >
37
37
38
38
<ItemGroup Condition =" '$(TargetFramework)' == 'net462' " >
Original file line number Diff line number Diff line change
1
+ using System . IO ;
2
+ using System . Runtime . Serialization . Formatters . Binary ;
3
+ using MySql . Data . MySqlClient ;
4
+ using Xunit ;
5
+
6
+ namespace MySqlConnector . Tests
7
+ {
8
+ public class MySqlExceptionTests
9
+ {
10
+ [ Fact ]
11
+ public void IsSerializable ( )
12
+ {
13
+ var exception = new MySqlException ( 1 , "two" , "three" ) ;
14
+ MySqlException copy ;
15
+
16
+ using ( var stream = new MemoryStream ( ) )
17
+ {
18
+ var formatter = new BinaryFormatter ( ) ;
19
+ formatter . Serialize ( stream , exception ) ;
20
+ stream . Position = 0 ;
21
+ copy = ( MySqlException ) formatter . Deserialize ( stream ) ;
22
+ }
23
+
24
+ Assert . Equal ( exception . Number , copy . Number ) ;
25
+ Assert . Equal ( exception . SqlState , copy . SqlState ) ;
26
+ Assert . Equal ( exception . Message , copy . Message ) ;
27
+ }
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments