Skip to content

Commit 8c1df14

Browse files
committed
Merge master into net7.
2 parents 1ac0d45 + 1920eb8 commit 8c1df14

31 files changed

+84
-1128
lines changed

.ci/integration-tests-steps.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
unsupportedFeatures: ''
33
image: ''
4+
connectionStringExtra: ''
45
DotNetCoreSdkVersion: ''
56

67
steps:
@@ -35,7 +36,7 @@ steps:
3536
parameters:
3637
image: ${{ parameters.image }}
3738
unsupportedFeatures: ${{ parameters.unsupportedFeatures }}
38-
connectionString: 'server=localhost;port=3300;user id=mysqltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600;certificate file=$(Build.Repository.LocalPath)/.ci/server/certs/ssl-client.pfx'
39+
connectionString: server=localhost;port=3300;user id=mysqltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600;certificate file=$(Build.Repository.LocalPath)/.ci/server/certs/ssl-client.pfx;${{ parameters.connectionStringExtra }}
3940
platform: 'net7.0'
4041
description: 'SSL'
4142
- template: 'sidebyside-test-steps.yml'
@@ -56,6 +57,6 @@ steps:
5657
parameters:
5758
image: ${{ parameters.image }}
5859
unsupportedFeatures: ${{ parameters.unsupportedFeatures }}
59-
connectionString: 'server=localhost;port=3300;user id=mysqltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600;certificate file=$(Build.Repository.LocalPath)/.ci/server/certs/ssl-client.pfx'
60+
connectionString: server=localhost;port=3300;user id=mysqltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600;certificate file=$(Build.Repository.LocalPath)/.ci/server/certs/ssl-client.pfx;${{ parameters.connectionStringExtra }}
6061
platform: 'net6.0'
6162
description: 'SSL'

.ci/sidebyside-test-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ steps:
2020
inputs:
2121
command: 'custom'
2222
custom: 'vstest'
23-
arguments: ${{ format('$(Build.BinariesDirectory)/{0}/SideBySide.dll /logger:trx', parameters.platform) }}
23+
arguments: ${{ format('$(Build.BinariesDirectory)/{0}/SideBySide.dll /logger:trx', parameters.platform) }}
2424
env:
2525
DATA__UNSUPPORTEDFEATURES: ${{ parameters.unsupportedFeatures }}
2626
DATA__CONNECTIONSTRING: ${{ parameters.connectionString }}

azure-pipelines.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,25 +223,32 @@ jobs:
223223
matrix:
224224
'MySQL 5.6':
225225
image: 'mysql:5.6'
226+
connectionStringExtra: ''
226227
unsupportedFeatures: 'CachingSha2Password,Ed25519,Json,LargePackets,QueryAttributes,ResetConnection,SessionTrack,Sha256Password,Tls11,Tls13,UuidToBin'
227228
'MySQL 5.7':
228229
image: 'mysql:5.7'
230+
connectionStringExtra: 'Tls Cipher Suites=TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256'
229231
unsupportedFeatures: 'CachingSha2Password,Ed25519,QueryAttributes,Tls11,Tls13,UuidToBin'
230232
'MySQL 8.0':
231233
image: 'mysql:8.0'
234+
connectionStringExtra: ''
232235
unsupportedFeatures: 'Ed25519,Tls11,ZeroDateTime'
233236
'MariaDB 10.4':
234237
image: 'mariadb:10.4'
238+
connectionStringExtra: ''
235239
unsupportedFeatures: 'CachingSha2Password,Json,RoundDateTime,QueryAttributes,Sha256Password,Tls11,UuidToBin'
236240
'MariaDB 10.5':
237241
image: 'mariadb:10.5'
242+
connectionStringExtra: ''
238243
unsupportedFeatures: 'CachingSha2Password,Json,RoundDateTime,QueryAttributes,Sha256Password,Tls11,UuidToBin'
239244
'MariaDB 10.6':
240245
image: 'mariadb:10.6'
246+
connectionStringExtra: ''
241247
unsupportedFeatures: 'CachingSha2Password,Json,RoundDateTime,QueryAttributes,Sha256Password,Tls11,UuidToBin'
242248
steps:
243249
- template: '.ci/integration-tests-steps.yml'
244250
parameters:
245251
image: $(image)
252+
connectionStringExtra: $(connectionStringExtra)
246253
unsupportedFeatures: $(unsupportedFeatures)
247254
DotNetCoreSdkVersion: $(DotNetCoreSdkVersion)

docs/content/home.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,33 @@ Install MySqlConnector from [NuGet](https://www.nuget.org/packages/MySqlConnecto
3333
Connecting to your database is simple. For example, in C#:
3434

3535
```csharp
36-
using (var connection = new MySqlConnection("Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase"))
37-
{
38-
connection.Open();
39-
40-
using (var command = new MySqlCommand("SELECT field FROM table;", connection))
41-
using (var reader = command.ExecuteReader())
42-
while (reader.Read())
43-
Console.WriteLine(reader.GetString(0));
44-
}
36+
using var connection = new MySqlConnection("Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase");
37+
connection.Open();
38+
39+
using var command = new MySqlCommand("SELECT field FROM table;", connection);
40+
using var reader = command.ExecuteReader();
41+
while (reader.Read())
42+
Console.WriteLine(reader.GetString(0));
4543
```
4644

4745
For more information, see [how to install](./overview/installing/) and a [basic example](./tutorials/basic-api/) of using the API.
4846
[Many ORMs](/overview/use-with-orms/) are supported.
4947

48+
49+
### Asynchronous I/O
50+
51+
MySqlConnector also fully supports asynchronous I/O. The C# example above can be rewritten as:
52+
53+
```csharp
54+
await using var connection = new MySqlConnection("Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase");
55+
await connection.OpenAsync();
56+
57+
using var command = new MySqlCommand("SELECT field FROM table;", connection);
58+
await using var reader = await command.ExecuteReaderAsync();
59+
while (await reader.ReadAsync())
60+
Console.WriteLine(reader.GetString(0));
61+
```
62+
5063
## Performance
5164

5265
MySqlConnector outperforms Connector/NET (MySql.Data) on benchmarks:

docs/content/tutorials/net-core-mvc.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,5 +379,3 @@ GET https://localhost:5001/api/blog
379379
// Output:
380380
[]
381381
```
382-
383-
If you would like to see all of this code and more on GitHub, check out [MySqlConnector.Performance](https://github.com/mysql-net/MySqlConnector/tree/master/tests/MySqlConnector.Performance).

src/MySqlConnector/Core/TextRow.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,24 @@ protected override object GetValueCore(ReadOnlySpan<byte> data, ColumnDefinition
9696
return ParseInt32(data);
9797

9898
case ColumnType.Float:
99-
return !Utf8Parser.TryParse(data, out float floatValue, out var floatBytesConsumed) || floatBytesConsumed != data.Length ? throw new FormatException() : floatValue;
99+
if (Utf8Parser.TryParse(data, out float floatValue, out var floatBytesConsumed) && floatBytesConsumed == data.Length)
100+
return floatValue;
101+
ReadOnlySpan<byte> floatInfinity = new byte[] { 0x2D, 0x69, 0x6E, 0x66 }; // "-inf"
102+
if (data.SequenceEqual(floatInfinity))
103+
return float.NegativeInfinity;
104+
if (data.SequenceEqual(floatInfinity.Slice(1)))
105+
return float.PositiveInfinity;
106+
throw new FormatException("Couldn't parse '{0}' as float".FormatInvariant(Encoding.UTF8.GetString(data)));
100107

101108
case ColumnType.Double:
102-
return !Utf8Parser.TryParse(data, out double doubleValue, out var doubleBytesConsumed) || doubleBytesConsumed != data.Length ? throw new FormatException() : doubleValue;
109+
if (Utf8Parser.TryParse(data, out double doubleValue, out var doubleBytesConsumed) && doubleBytesConsumed == data.Length)
110+
return doubleValue;
111+
ReadOnlySpan<byte> doubleInfinity = new byte[] { 0x2D, 0x69, 0x6E, 0x66 }; // "-inf"
112+
if (data.SequenceEqual(doubleInfinity))
113+
return double.NegativeInfinity;
114+
if (data.SequenceEqual(doubleInfinity.Slice(1)))
115+
return double.PositiveInfinity;
116+
throw new FormatException("Couldn't parse '{0}' as double".FormatInvariant(Encoding.UTF8.GetString(data)));
103117

104118
case ColumnType.Decimal:
105119
case ColumnType.NewDecimal:

tests/MySqlConnector.Performance/.editorconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/MySqlConnector.Performance/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/MySqlConnector.Performance/AppConfig.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/MySqlConnector.Performance/AppDb.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)