diff --git a/.ci/build-steps.yml b/.ci/build-steps.yml
index 95cfc5553..c95f7acf3 100644
--- a/.ci/build-steps.yml
+++ b/.ci/build-steps.yml
@@ -6,9 +6,10 @@ steps:
contents: 'config.json'
targetFolder: 'tests/IntegrationTests'
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: 'Restore packages'
@@ -26,37 +27,37 @@ steps:
displayName: 'Publish MySqlConnector.Tests'
inputs:
command: 'publish'
- arguments: '-c Release -f net7.0 --no-build tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj'
+ arguments: '-c Release -f net8.0 --no-build tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@0
inputs:
- artifactName: 'MySqlConnector.Tests-7.0-$(Agent.OS)'
- targetPath: 'tests/MySqlConnector.Tests/bin/Release/net7.0/publish'
+ artifactName: 'MySqlConnector.Tests-8.0-$(Agent.OS)'
+ targetPath: 'artifacts/publish/MySqlConnector.Tests/release_net8.0'
- task: DotNetCoreCLI@2
displayName: 'Publish Conformance.Tests'
inputs:
command: 'publish'
- arguments: '-c Release -f net7.0 --no-build tests/Conformance.Tests/Conformance.Tests.csproj'
+ arguments: '-c Release -f net8.0 --no-build tests/Conformance.Tests/Conformance.Tests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@0
inputs:
- artifactName: 'Conformance.Tests-7.0-$(Agent.OS)'
- targetPath: 'tests/Conformance.Tests/bin/Release/net7.0/publish'
+ artifactName: 'Conformance.Tests-8.0-$(Agent.OS)'
+ targetPath: 'artifacts/publish/Conformance.Tests/release_net8.0'
- task: DotNetCoreCLI@2
displayName: 'Publish IntegrationTests (7.0)'
inputs:
command: 'publish'
- arguments: '-c Release -f net7.0 --no-build tests/IntegrationTests/IntegrationTests.csproj'
+ arguments: '-c Release -f net8.0 --no-build tests/IntegrationTests/IntegrationTests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@0
inputs:
- artifactName: 'IntegrationTests-net7.0-$(Agent.OS)'
- targetPath: 'tests/IntegrationTests/bin/Release/net7.0/publish'
+ artifactName: 'IntegrationTests-net8.0-$(Agent.OS)'
+ targetPath: 'artifacts/publish/IntegrationTests/release_net8.0'
- task: DotNetCoreCLI@2
displayName: 'Publish IntegrationTests (6.0)'
@@ -68,4 +69,4 @@ steps:
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'IntegrationTests-net6.0-$(Agent.OS)'
- targetPath: 'tests/IntegrationTests/bin/Release/net6.0/publish'
+ targetPath: 'artifacts/publish/IntegrationTests/release_net6.0'
diff --git a/.ci/config/config.compression+ssl.json b/.ci/config/config.compression+ssl.json
index 206c84969..8a11c95bf 100644
--- a/.ci/config/config.compression+ssl.json
+++ b/.ci/config/config.compression+ssl.json
@@ -1,12 +1,12 @@
{
"Data": {
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;use compression=true;DefaultCommandTimeout=3600",
- "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
+ "SocketPath": "./../../../../.ci/run/mysql/mysqld.sock",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,Tls13,UuidToBin",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
- "CertificatesPath": "../../../../../.ci/server/certs"
+ "MySqlBulkLoaderLocalCsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
+ "CertificatesPath": "../../../../.ci/server/certs"
}
}
diff --git a/.ci/config/config.compression.json b/.ci/config/config.compression.json
index afd6f6bee..ca3199da0 100644
--- a/.ci/config/config.compression.json
+++ b/.ci/config/config.compression.json
@@ -1,11 +1,11 @@
{
"Data": {
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;UseCompression=true;DefaultCommandTimeout=3600",
- "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
+ "SocketPath": "./../../../../.ci/run/mysql/mysqld.sock",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,QueryAttributes,Tls12,Tls13,UnixDomainSocket,UuidToBin",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
+ "MySqlBulkLoaderLocalCsvFile": "../../../../tests/TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../../tests/TestData/LoadData_UTF8_BOM_Unix.TSV"
}
}
diff --git a/.ci/config/config.json b/.ci/config/config.json
index b0332563d..fa5908d80 100644
--- a/.ci/config/config.json
+++ b/.ci/config/config.json
@@ -1,11 +1,11 @@
{
"Data": {
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600",
- "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
+ "SocketPath": "./../../../../.ci/run/mysql/mysqld.sock",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,QueryAttributes,Tls12,Tls13,UnixDomainSocket,UuidToBin",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
+ "MySqlBulkLoaderLocalCsvFile": "../../../../tests/TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../../tests/TestData/LoadData_UTF8_BOM_Unix.TSV"
}
}
diff --git a/.ci/config/config.ssl.json b/.ci/config/config.ssl.json
index d2132e290..ef4a5afb0 100644
--- a/.ci/config/config.ssl.json
+++ b/.ci/config/config.ssl.json
@@ -1,12 +1,12 @@
{
"Data": {
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;certificate file=../../../../../.ci/server/certs/ssl-client.pfx;DefaultCommandTimeout=3600",
- "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
+ "SocketPath": "./../../../../.ci/run/mysql/mysqld.sock",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,Tls13,UuidToBin",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
- "CertificatesPath": "../../../../../.ci/server/certs"
+ "MySqlBulkLoaderLocalCsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
+ "CertificatesPath": "../../../../.ci/server/certs"
}
}
diff --git a/.ci/config/config.uds+ssl.json b/.ci/config/config.uds+ssl.json
index 26d67f019..eb754da59 100644
--- a/.ci/config/config.uds+ssl.json
+++ b/.ci/config/config.uds+ssl.json
@@ -1,11 +1,11 @@
{
"Data": {
- "ConnectionString": "server=./../../../../../.ci/mysqld/mysqld.sock;user id=ssltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600",
+ "ConnectionString": "server=./../../../../.ci/mysqld/mysqld.sock;user id=ssltest;password=test;database=mysqltest;ssl mode=required;DefaultCommandTimeout=3600",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "None",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
- "CertificatesPath": "../../../../../.ci/server/certs"
+ "MySqlBulkLoaderLocalCsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.TSV",
+ "CertificatesPath": "../../../../.ci/server/certs"
}
}
diff --git a/.ci/config/config.uds.json b/.ci/config/config.uds.json
index d3e90c036..6b209d734 100644
--- a/.ci/config/config.uds.json
+++ b/.ci/config/config.uds.json
@@ -1,10 +1,10 @@
{
"Data": {
- "ConnectionString": "server=./../../../../../.ci/run/mysql/mysqld.sock;user id=mysqltest;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600",
+ "ConnectionString": "server=./../../../../.ci/run/mysql/mysqld.sock;user id=mysqltest;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600",
"PasswordlessUser": "no_password",
"SecondaryDatabase": "testdb2",
"UnsupportedFeatures": "None",
- "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
- "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
+ "MySqlBulkLoaderLocalCsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
+ "MySqlBulkLoaderLocalTsvFile": "../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
}
}
diff --git a/.ci/conformance-test-steps.yml b/.ci/conformance-test-steps.yml
index 28d38cbc0..02d700623 100644
--- a/.ci/conformance-test-steps.yml
+++ b/.ci/conformance-test-steps.yml
@@ -10,14 +10,14 @@ steps:
- task: DownloadPipelineArtifact@0
condition: always()
inputs:
- artifactName: 'Conformance.Tests-7.0-$(Agent.OS)'
- targetPath: '$(Build.BinariesDirectory)/7.0'
+ artifactName: 'Conformance.Tests-8.0-$(Agent.OS)'
+ targetPath: '$(Build.BinariesDirectory)/8.0'
- task: DotNetCoreCLI@2
displayName: 'Conformance Tests'
inputs:
command: 'custom'
custom: 'vstest'
- arguments: '$(Build.BinariesDirectory)/7.0/Conformance.Tests.dll /logger:trx'
+ arguments: '$(Build.BinariesDirectory)/8.0/Conformance.Tests.dll /logger:trx'
env:
CONNECTION_STRING: ${{ parameters.connectionString }}
- task: PublishTestResults@2
diff --git a/.ci/integration-tests-steps.yml b/.ci/integration-tests-steps.yml
index 4e89b919c..d56e29c11 100644
--- a/.ci/integration-tests-steps.yml
+++ b/.ci/integration-tests-steps.yml
@@ -8,19 +8,15 @@ steps:
- bash: ${{ format('.ci/docker-run.sh {0} 3300 {1}', parameters.image, parameters.unsupportedFeatures) }}
displayName: 'Start Docker container'
- task: UseDotNet@2
- displayName: 'Install .NET Core 3.1'
- inputs:
- version: 3.1.x
- packageType: runtime
-- task: UseDotNet@2
- displayName: 'Install .NET Core 6.0'
+ displayName: 'Install .NET 6.0'
inputs:
version: 6.0.x
packageType: runtime
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- template: 'conformance-test-steps.yml'
parameters:
image: ${{ parameters.image }}
@@ -30,7 +26,7 @@ steps:
image: ${{ parameters.image }}
unsupportedFeatures: ${{ parameters.unsupportedFeatures }}
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 }}
- platform: 'net7.0'
+ platform: 'net8.0'
description: 'SSL'
- template: 'integration-test-steps.yml'
parameters:
@@ -52,4 +48,4 @@ steps:
unsupportedFeatures: ${{ parameters.unsupportedFeatures }}
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 }}
platform: 'net6.0'
- description: 'SSL'
\ No newline at end of file
+ description: 'SSL'
diff --git a/.ci/mysqlconnector-tests-steps.yml b/.ci/mysqlconnector-tests-steps.yml
index 6e25b9f90..ca4b1ce8f 100644
--- a/.ci/mysqlconnector-tests-steps.yml
+++ b/.ci/mysqlconnector-tests-steps.yml
@@ -1,11 +1,12 @@
steps:
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- task: DownloadPipelineArtifact@0
inputs:
- artifactName: 'MySqlConnector.Tests-7.0-$(Agent.OS)'
+ artifactName: 'MySqlConnector.Tests-8.0-$(Agent.OS)'
targetPath: $(System.DefaultWorkingDirectory)
- task: DotNetCoreCLI@2
displayName: 'Run MySqlConnector.Tests'
@@ -17,4 +18,4 @@ steps:
inputs:
testResultsFormat: VSTest
testResultsFiles: '**/*.trx'
- testRunTitle: 'MySqlConnector.Tests-7.0-$(Agent.OS)'
\ No newline at end of file
+ testRunTitle: 'MySqlConnector.Tests-8.0-$(Agent.OS)'
diff --git a/.editorconfig b/.editorconfig
index 6d1ccd5a7..1765a3ee5 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -79,7 +79,6 @@ dotnet_diagnostic.CA1508.severity = silent # Avoid dead conditional code.
dotnet_diagnostic.CA1510.severity = none # Use ArgumentNullException.ThrowIfNull.
dotnet_diagnostic.CA1513.severity = none # Use ObjectDisposedException.ThrowIf.
dotnet_diagnostic.CA1849.severity = none # Call async methods when in an async method.
-dotnet_diagnostic.CA1859.severity = silent # Use concrete return types for performance.
dotnet_diagnostic.CA2000.severity = none # Use recommended Dispose pattern.
dotnet_diagnostic.CA2100.severity = none # Review SQL queries for security vulnerabilities.
dotnet_diagnostic.CA2213.severity = silent # Disposable fields should be disposed.
@@ -111,6 +110,7 @@ dotnet_diagnostic.SA1500.severity = none # Braces for multi-line statements shou
dotnet_diagnostic.SA1503.severity = none # Braces should not be omitted.
dotnet_diagnostic.SA1513.severity = none # Closing brace should be followed by blank line.
dotnet_diagnostic.SA1516.severity = none # Elements should be separated by blank line.
+dotnet_diagnostic.SA1519.severity = none # Braces should not be omitted from multi-line child statement
dotnet_diagnostic.SA1600.severity = none # Elements should be documented.
dotnet_diagnostic.SA1601.severity = none # Partial elements should be documented.
dotnet_diagnostic.SA1602.severity = none # Enumeration items should be documented.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c60d67252..0d9342836 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,10 +15,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- - name: Set up .NET 7.0
+ - name: Set up .NET 8.0
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.x
+ dotnet-version: 8.x
- name: Restore
run: dotnet restore
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 4a4d082d3..d9c51efda 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -26,10 +26,10 @@ jobs:
- name: Check out
uses: actions/checkout@v4
- - name: Set up .NET 7.0
+ - name: Set up .NET 8.0
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.x
+ dotnet-version: 8.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
diff --git a/.gitignore b/.gitignore
index b58dd54e1..e72e818f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
# ignore output folders
BenchmarkDotNet.Artifacts/
+artifacts/
bin/
build/
obj/
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 000000000..c475ff91a
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,22 @@
+
+
+
+ true
+ preview
+ true
+ $(NoWarn);1591;CA1708;CA1835;CA2215;CA5397;NU5105;SYSLIB0039
+ $(MSBuildThisFileDirectory)artifacts
+ true
+ low
+
+
+
+ true
+
+
+
+ true
+ true
+
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 000000000..a874fb181
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,34 @@
+
+
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/NuGet.config b/NuGet.config
index 6873eb959..4d736c19e 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -1,6 +1,7 @@
+
diff --git a/appveyor.yml b/appveyor.yml
index 001c7edfe..1f30f422b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,6 +11,7 @@ install:
- ps: Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "install-dotnet.ps1"
- ps: .\install-dotnet.ps1 -Channel 6.0 -InstallDir "dotnetcli"
- ps: .\install-dotnet.ps1 -Channel 7.0 -InstallDir "dotnetcli"
+ - ps: .\install-dotnet.ps1 -Channel 8.0 -InstallDir "dotnetcli"
build_script:
- dotnet --info
before_test:
@@ -21,19 +22,13 @@ test_script:
- ps: .\.ci\test.ps1
after_test:
- cmd: |-
- dotnet pack src\MySqlConnector\MySqlConnector.csproj -c Release
- dotnet pack src\MySqlConnector.Authentication.Ed25519\MySqlConnector.Authentication.Ed25519.csproj -c Release
- dotnet pack src\MySqlConnector.DependencyInjection\MySqlConnector.DependencyInjection.csproj -c Release
- dotnet pack src\MySqlConnector.Logging.log4net\MySqlConnector.Logging.log4net.csproj -c Release
- dotnet pack src\MySqlConnector.Logging.Microsoft.Extensions.Logging\MySqlConnector.Logging.Microsoft.Extensions.Logging.csproj -c Release
- dotnet pack src\MySqlConnector.Logging.NLog\MySqlConnector.Logging.NLog.csproj -c Release
- dotnet pack src\MySqlConnector.Logging.Serilog\MySqlConnector.Logging.Serilog.csproj -c Release
+ dotnet pack -c Release
notifications:
- provider: Slack
incoming_webhook:
secure: SRJ5fYQE4tvelyqeX3Lkv0gXta3O2pl4/+wNaqmqmcFkmYBe+U31T5YCGhipBOVhHBIZLevihOJZ78sFVJrmAFV5bHgtX/VPIKEXN+7ytis=
artifacts:
-- path: src\*\bin\Release\*.nupkg
+- path: artifacts\package\release\*.nupkg
deploy:
- provider: NuGet
api_key:
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 91efcf8e0..43cda8c76 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -1,5 +1,5 @@
variables:
- DotNetCoreSdkVersion: '7.x'
+ DotNetCoreSdkVersion: '8.x'
NUGET_PACKAGES: '$(Pipeline.Workspace)/.nuget/packages'
jobs:
@@ -26,7 +26,7 @@ jobs:
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'IntegrationTests-net472-$(Agent.OS)'
- targetPath: 'tests/IntegrationTests/bin/Release/net472/publish'
+ targetPath: 'artifacts/publish/IntegrationTests/release_net472'
- job: windows_mysql_data
displayName: 'MySql.Data Tests'
@@ -41,13 +41,14 @@ jobs:
contents: 'config.json'
targetFolder: 'tests/IntegrationTests'
- task: UseDotNet@2
- displayName: 'Install .NET Core 7.0'
+ displayName: 'Install .NET 7.0'
inputs:
version: '7.0.x'
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: 'MySql.Data unit tests'
inputs:
@@ -108,9 +109,10 @@ jobs:
steps:
- template: '.ci/install-mysql-windows.yml'
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- task: CopyFiles@2
displayName: 'Copy config.json'
inputs:
@@ -121,18 +123,18 @@ jobs:
displayName: 'Remove target frameworks'
inputs:
targetType: 'inline'
- script: '((Get-Content .\tests\IntegrationTests\IntegrationTests.csproj -Raw) -replace(''.*'', ''net472;net7.0'')) | Set-Content .\tests\IntegrationTests\IntegrationTests.csproj'
+ script: '((Get-Content .\tests\IntegrationTests\IntegrationTests.csproj -Raw) -replace(''.*'', ''net472;net8.0'')) | Set-Content .\tests\IntegrationTests\IntegrationTests.csproj'
- task: DotNetCoreCLI@2
displayName: 'Restore packages'
inputs:
command: 'restore'
- task: DotNetCoreCLI@2
- displayName: 'Integration tests (net472/net7.0)'
+ displayName: 'Integration tests (net472/net8.0)'
inputs:
command: 'test'
projects: 'tests/IntegrationTests/IntegrationTests.csproj'
arguments: '-c Release --no-restore'
- testRunTitle: ${{ format('{0}, $(Agent.OS), {1}, {2}', 'mysql:8.0', 'net472/net7.0', 'No SSL') }}
+ testRunTitle: ${{ format('{0}, $(Agent.OS), {1}, {2}', 'mysql:8.0', 'net472/net8.0', 'No SSL') }}
env:
DATA__UNSUPPORTEDFEATURES: 'Ed25519,QueryAttributes,StreamingResults,Tls11,UnixDomainSocket'
DATA__CONNECTIONSTRING: 'server=localhost;port=3306;user id=mysqltest;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600;AllowPublicKeyRetrieval=True;UseCompression=True'
@@ -144,14 +146,15 @@ jobs:
steps:
- template: '.ci/install-mysql-windows.yml'
- task: UseDotNet@2
- displayName: 'Install .NET Core 6.0'
+ displayName: 'Install .NET 6.0'
inputs:
version: 6.0.x
packageType: runtime
- task: UseDotNet@2
- displayName: 'Install .NET Core'
+ displayName: 'Install .NET'
inputs:
version: $(DotNetCoreSdkVersion)
+ includePreviewVersions: true
- script: copy .ci\config\config.json tests\IntegrationTests\config.json
displayName: 'Copy config.json'
- task: PowerShell@2
diff --git a/global.json b/global.json
index 3e3cfd9ca..7a8f3d994 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,6 @@
{
"sdk": {
- "version": "7.0.402"
+ "version": "8.0",
+ "allowPrerelease": true
}
}
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index e73c5bfa3..0968ec93d 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,10 +1,10 @@
+
true
true
..\..\MySqlConnector.snk
- true
https://mysqlconnector.net/overview/version-history/
https://mysqlconnector.net/
MIT
@@ -17,8 +17,6 @@
2.0.0
true
true
- 11.0
- true
latest-all
false
true
@@ -26,33 +24,18 @@
true
true
true
- $(NoWarn);1591;CA1708;CA1835;CA2215;CA5397;NU5105;SYSLIB0039
beta.0
-
- true
-
-
-
- true
- true
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/src/MySqlConnector.Authentication.Ed25519/CompatibilitySuppressions.xml b/src/MySqlConnector.Authentication.Ed25519/CompatibilitySuppressions.xml
index a95918371..738dbc799 100644
--- a/src/MySqlConnector.Authentication.Ed25519/CompatibilitySuppressions.xml
+++ b/src/MySqlConnector.Authentication.Ed25519/CompatibilitySuppressions.xml
@@ -1,4 +1,5 @@
+
PKV006
diff --git a/src/MySqlConnector.DependencyInjection/MySqlConnector.DependencyInjection.csproj b/src/MySqlConnector.DependencyInjection/MySqlConnector.DependencyInjection.csproj
index 5e1488102..d1e793b74 100644
--- a/src/MySqlConnector.DependencyInjection/MySqlConnector.DependencyInjection.csproj
+++ b/src/MySqlConnector.DependencyInjection/MySqlConnector.DependencyInjection.csproj
@@ -14,7 +14,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
diff --git a/src/MySqlConnector.Logging.Microsoft.Extensions.Logging/MySqlConnector.Logging.Microsoft.Extensions.Logging.csproj b/src/MySqlConnector.Logging.Microsoft.Extensions.Logging/MySqlConnector.Logging.Microsoft.Extensions.Logging.csproj
index 5233621fb..92ba235e8 100644
--- a/src/MySqlConnector.Logging.Microsoft.Extensions.Logging/MySqlConnector.Logging.Microsoft.Extensions.Logging.csproj
+++ b/src/MySqlConnector.Logging.Microsoft.Extensions.Logging/MySqlConnector.Logging.Microsoft.Extensions.Logging.csproj
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
diff --git a/src/MySqlConnector.Logging.NLog/CompatibilitySuppressions.xml b/src/MySqlConnector.Logging.NLog/CompatibilitySuppressions.xml
index a95918371..738dbc799 100644
--- a/src/MySqlConnector.Logging.NLog/CompatibilitySuppressions.xml
+++ b/src/MySqlConnector.Logging.NLog/CompatibilitySuppressions.xml
@@ -1,4 +1,5 @@
+
PKV006
diff --git a/src/MySqlConnector.Logging.NLog/MySqlConnector.Logging.NLog.csproj b/src/MySqlConnector.Logging.NLog/MySqlConnector.Logging.NLog.csproj
index 343e2fc58..b0cb9e194 100644
--- a/src/MySqlConnector.Logging.NLog/MySqlConnector.Logging.NLog.csproj
+++ b/src/MySqlConnector.Logging.NLog/MySqlConnector.Logging.NLog.csproj
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
diff --git a/src/MySqlConnector.Logging.Serilog/CompatibilitySuppressions.xml b/src/MySqlConnector.Logging.Serilog/CompatibilitySuppressions.xml
index a95918371..738dbc799 100644
--- a/src/MySqlConnector.Logging.Serilog/CompatibilitySuppressions.xml
+++ b/src/MySqlConnector.Logging.Serilog/CompatibilitySuppressions.xml
@@ -1,4 +1,5 @@
+
PKV006
diff --git a/src/MySqlConnector.Logging.Serilog/MySqlConnector.Logging.Serilog.csproj b/src/MySqlConnector.Logging.Serilog/MySqlConnector.Logging.Serilog.csproj
index b3344f37d..316d42263 100644
--- a/src/MySqlConnector.Logging.Serilog/MySqlConnector.Logging.Serilog.csproj
+++ b/src/MySqlConnector.Logging.Serilog/MySqlConnector.Logging.Serilog.csproj
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
diff --git a/src/MySqlConnector.Logging.log4net/CompatibilitySuppressions.xml b/src/MySqlConnector.Logging.log4net/CompatibilitySuppressions.xml
index a95918371..738dbc799 100644
--- a/src/MySqlConnector.Logging.log4net/CompatibilitySuppressions.xml
+++ b/src/MySqlConnector.Logging.log4net/CompatibilitySuppressions.xml
@@ -1,4 +1,5 @@
+
PKV006
diff --git a/src/MySqlConnector.Logging.log4net/MySqlConnector.Logging.log4net.csproj b/src/MySqlConnector.Logging.log4net/MySqlConnector.Logging.log4net.csproj
index 3e25ac19c..6e655a9e4 100644
--- a/src/MySqlConnector.Logging.log4net/MySqlConnector.Logging.log4net.csproj
+++ b/src/MySqlConnector.Logging.log4net/MySqlConnector.Logging.log4net.csproj
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
diff --git a/src/MySqlConnector/Authentication/AuthenticationPlugins.cs b/src/MySqlConnector/Authentication/AuthenticationPlugins.cs
index 0b1c1246c..025362e0f 100644
--- a/src/MySqlConnector/Authentication/AuthenticationPlugins.cs
+++ b/src/MySqlConnector/Authentication/AuthenticationPlugins.cs
@@ -13,11 +13,18 @@ public static class AuthenticationPlugins
/// The authentication plugin.
public static void Register(IAuthenticationPlugin plugin)
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(plugin);
+#else
if (plugin is null)
throw new ArgumentNullException(nameof(plugin));
+#endif
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(plugin.Name);
+#else
if (string.IsNullOrEmpty(plugin.Name))
throw new ArgumentException("Invalid plugin name.", nameof(plugin));
-
+#endif
lock (s_lock)
s_plugins.Add(plugin.Name, plugin);
}
@@ -29,5 +36,5 @@ internal static bool TryGetPlugin(string name, [NotNullWhen(true)] out IAuthenti
}
private static readonly object s_lock = new();
- private static readonly Dictionary s_plugins = new();
+ private static readonly Dictionary s_plugins = [];
}
diff --git a/src/MySqlConnector/ColumnReaders/GuidBinary16ColumnReader.cs b/src/MySqlConnector/ColumnReaders/GuidBinary16ColumnReader.cs
index 8cc2dd94f..0f4df3ff6 100644
--- a/src/MySqlConnector/ColumnReaders/GuidBinary16ColumnReader.cs
+++ b/src/MySqlConnector/ColumnReaders/GuidBinary16ColumnReader.cs
@@ -15,7 +15,9 @@ public override object ReadValue(ReadOnlySpan data, ColumnDefinitionPayloa
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Guid ReadGuid(ReadOnlySpan data) =>
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+#if NET8_0_OR_GREATER
+ new(data, bigEndian: true);
+#elif NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
new(stackalloc byte[16] { data[3], data[2], data[1], data[0], data[5], data[4], data[7], data[6], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15] });
#else
new(new[] { data[3], data[2], data[1], data[0], data[5], data[4], data[7], data[6], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15] });
diff --git a/src/MySqlConnector/ColumnReaders/GuidLittleEndianBinary16ColumnReader.cs b/src/MySqlConnector/ColumnReaders/GuidLittleEndianBinary16ColumnReader.cs
index 0bd7c2996..99e9fd96f 100644
--- a/src/MySqlConnector/ColumnReaders/GuidLittleEndianBinary16ColumnReader.cs
+++ b/src/MySqlConnector/ColumnReaders/GuidLittleEndianBinary16ColumnReader.cs
@@ -12,9 +12,11 @@ public override object ReadValue(ReadOnlySpan data, ColumnDefinitionPayloa
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Guid ReadGuid(ReadOnlySpan data) =>
-#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
- new Guid(data);
+#if NET8_0_OR_GREATER
+ new(data, bigEndian: false);
+#elif NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+ new(data);
#else
- new Guid(data.ToArray());
+ new(data.ToArray());
#endif
}
diff --git a/src/MySqlConnector/CompatibilitySuppressions.xml b/src/MySqlConnector/CompatibilitySuppressions.xml
index 35851e7b5..07cb181f8 100644
--- a/src/MySqlConnector/CompatibilitySuppressions.xml
+++ b/src/MySqlConnector/CompatibilitySuppressions.xml
@@ -20,6 +20,132 @@
lib/net6.0/MySqlConnector.dll
lib/net7.0/MySqlConnector.dll
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Collections.Generic.IEnumerable{System.Data.DataRow},System.Int32,System.Threading.CancellationToken)
+ lib/net461/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Threading.CancellationToken)
+ lib/net461/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Data.IDataReader,System.Threading.CancellationToken)
+ lib/net461/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.get_ProvideClientCertificatesCallback
+ lib/net461/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.ResetConnectionAsync(System.Threading.CancellationToken)
+ lib/net461/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Collections.Generic.IEnumerable{System.Data.DataRow},System.Int32,System.Threading.CancellationToken)
+ lib/net471/MySqlConnector.dll
+ lib/net471/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Threading.CancellationToken)
+ lib/net471/MySqlConnector.dll
+ lib/net471/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlBulkCopy.WriteToServerAsync(System.Data.IDataReader,System.Threading.CancellationToken)
+ lib/net471/MySqlConnector.dll
+ lib/net471/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.get_ProvideClientCertificatesCallback
+ lib/net471/MySqlConnector.dll
+ lib/net471/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.ResetConnectionAsync(System.Threading.CancellationToken)
+ lib/net471/MySqlConnector.dll
+ lib/net471/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.get_ProvideClientCertificatesCallback
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.ResetConnectionAsync(System.Threading.CancellationToken)
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.0/MySqlConnector.dll
+ true
+
+
+ CP0002
+ M:MySqlConnector.MySqlCommand.DisposeAsync
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.1/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnection.DisposeAsync
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.1/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlDataReader.DisposeAsync
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.1/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlTransaction.DisposeAsync
+ lib/netstandard2.0/MySqlConnector.dll
+ lib/netstandard2.1/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlBatchCommandCollection.GetEnumerator
+ lib/netstandard2.1/MySqlConnector.dll
+ lib/net6.0/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnectorFactory.CreateBatch
+ lib/netstandard2.1/MySqlConnector.dll
+ lib/net6.0/MySqlConnector.dll
+
+
+ CP0002
+ M:MySqlConnector.MySqlConnectorFactory.CreateBatchCommand
+ lib/netstandard2.1/MySqlConnector.dll
+ lib/net6.0/MySqlConnector.dll
+
CP0008
T:MySqlConnector.MySqlDataReader
diff --git a/src/MySqlConnector/Core/BatchedCommandPayloadCreator.cs b/src/MySqlConnector/Core/BatchedCommandPayloadCreator.cs
index 3b28ebe35..c17c53335 100644
--- a/src/MySqlConnector/Core/BatchedCommandPayloadCreator.cs
+++ b/src/MySqlConnector/Core/BatchedCommandPayloadCreator.cs
@@ -13,7 +13,7 @@ public bool WriteQueryCommand(ref CommandListPosition commandListPosition, IDict
writer.Write((byte) CommandKind.Multi);
bool? firstResult = default;
bool wroteCommand;
- ReadOnlySpan padding = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ ReadOnlySpan padding = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
do
{
// save room for command length
diff --git a/src/MySqlConnector/Core/CachedProcedure.cs b/src/MySqlConnector/Core/CachedProcedure.cs
index 26a45264c..c0f788649 100644
--- a/src/MySqlConnector/Core/CachedProcedure.cs
+++ b/src/MySqlConnector/Core/CachedProcedure.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
@@ -146,7 +147,7 @@ internal static List ParseParameters(string parametersSql)
parametersSql = s_multipleSpaces.Replace(parametersSql, " ");
if (string.IsNullOrWhiteSpace(parametersSql))
- return new List();
+ return [];
// strip precision specifier containing comma
parametersSql = s_numericTypes.Replace(parametersSql, @"$1");
@@ -233,6 +234,7 @@ private static CachedParameter CreateCachedParameter(int ordinal, string? direct
private string FullyQualified => $"`{m_schema}`.`{m_component}`";
+ [SuppressMessage("Performance", "CA1859:Use concrete types when possible for improved performance", Justification = "Avoid mutable static field")]
private static readonly IReadOnlyDictionary s_typeMapping = new Dictionary(StringComparer.OrdinalIgnoreCase)
{
{ "BOOL", "TINYINT" },
diff --git a/src/MySqlConnector/Core/ColumnTypeMetadata.cs b/src/MySqlConnector/Core/ColumnTypeMetadata.cs
index 48e4a4b1b..eadb27de4 100644
--- a/src/MySqlConnector/Core/ColumnTypeMetadata.cs
+++ b/src/MySqlConnector/Core/ColumnTypeMetadata.cs
@@ -1,31 +1,18 @@
namespace MySqlConnector.Core;
-internal sealed class ColumnTypeMetadata
+internal sealed class ColumnTypeMetadata(string dataTypeName, DbTypeMapping dbTypeMapping, MySqlDbType mySqlDbType, bool isUnsigned = false, bool binary = false, int length = 0, string? simpleDataTypeName = null, string? createFormat = null, long columnSize = 0)
{
public static string CreateLookupKey(string columnTypeName, bool isUnsigned, int length) => $"{columnTypeName}|{(isUnsigned ? "u" : "s")}|{length}";
- public ColumnTypeMetadata(string dataTypeName, DbTypeMapping dbTypeMapping, MySqlDbType mySqlDbType, bool isUnsigned = false, bool binary = false, int length = 0, string? simpleDataTypeName = null, string? createFormat = null, long columnSize = 0)
- {
- DataTypeName = dataTypeName;
- SimpleDataTypeName = simpleDataTypeName ?? dataTypeName;
- CreateFormat = createFormat ?? (dataTypeName + (isUnsigned ? " UNSIGNED" : ""));
- DbTypeMapping = dbTypeMapping;
- MySqlDbType = mySqlDbType;
- ColumnSize = columnSize;
- IsUnsigned = isUnsigned;
- Binary = binary;
- Length = length;
- }
-
- public string DataTypeName { get; }
- public string SimpleDataTypeName { get; }
- public string CreateFormat { get; }
- public DbTypeMapping DbTypeMapping { get; }
- public MySqlDbType MySqlDbType { get; }
- public bool Binary { get; }
- public long ColumnSize { get; }
- public bool IsUnsigned { get; }
- public int Length { get; }
+ public string DataTypeName { get; } = dataTypeName;
+ public string SimpleDataTypeName { get; } = simpleDataTypeName ?? dataTypeName;
+ public string CreateFormat { get; } = createFormat ?? (dataTypeName + (isUnsigned ? " UNSIGNED" : ""));
+ public DbTypeMapping DbTypeMapping { get; } = dbTypeMapping;
+ public MySqlDbType MySqlDbType { get; } = mySqlDbType;
+ public bool Binary { get; } = binary;
+ public long ColumnSize { get; } = columnSize;
+ public bool IsUnsigned { get; } = isUnsigned;
+ public int Length { get; } = length;
public string CreateLookupKey() => CreateLookupKey(DataTypeName, IsUnsigned, Length);
}
diff --git a/src/MySqlConnector/Core/CommandExecutor.cs b/src/MySqlConnector/Core/CommandExecutor.cs
index 74b2b4e6a..a2581334a 100644
--- a/src/MySqlConnector/Core/CommandExecutor.cs
+++ b/src/MySqlConnector/Core/CommandExecutor.cs
@@ -26,7 +26,7 @@ public static async ValueTask ExecuteReaderAsync(CommandListPos
var command2 = commandListPosition.CommandAt(commandIndex);
if (command2.CommandType == CommandType.StoredProcedure)
{
- cachedProcedures ??= new();
+ cachedProcedures ??= [];
var commandText = command2.CommandText!;
if (!cachedProcedures.ContainsKey(commandText))
{
diff --git a/src/MySqlConnector/Core/ConnectionPool.cs b/src/MySqlConnector/Core/ConnectionPool.cs
index 8544caeee..ad4f917f9 100644
--- a/src/MySqlConnector/Core/ConnectionPool.cs
+++ b/src/MySqlConnector/Core/ConnectionPool.cs
@@ -555,18 +555,18 @@ public static async Task ClearPoolsAsync(IOBehavior ioBehavior, CancellationToke
{
foreach (var pool in GetAllPools())
await pool.ClearAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
- }
- private static IReadOnlyList GetAllPools()
- {
- var pools = new List(s_pools.Count);
- var uniquePools = new HashSet();
- foreach (var pool in s_pools.Values)
+ static List GetAllPools()
{
- if (pool is not null && uniquePools.Add(pool))
- pools.Add(pool);
+ var pools = new List(s_pools.Count);
+ var uniquePools = new HashSet();
+ foreach (var pool in s_pools.Values)
+ {
+ if (pool is not null && uniquePools.Add(pool))
+ pools.Add(pool);
+ }
+ return pools;
}
- return pools;
}
private ConnectionPool(MySqlConnectorLoggingConfiguration loggingConfiguration, ConnectionSettings cs, string? name)
@@ -580,10 +580,10 @@ private ConnectionPool(MySqlConnectorLoggingConfiguration loggingConfiguration,
m_cleanSemaphore = new(1);
m_sessionSemaphore = new(cs.MaximumPoolSize);
m_sessions = new();
- m_leasedSessions = new();
+ m_leasedSessions = [];
if (cs.ConnectionProtocol == MySqlConnectionProtocol.Sockets && cs.LoadBalance == MySqlLoadBalance.LeastConnections)
{
- m_hostSessions = new();
+ m_hostSessions = [];
foreach (var hostName in cs.HostNames!)
m_hostSessions[hostName] = 0;
}
@@ -741,29 +741,19 @@ private void AdjustHostConnectionCount(ServerSession session, int delta)
}
}
- private sealed class LeastConnectionsLoadBalancer : ILoadBalancer
+ private sealed class LeastConnectionsLoadBalancer(Dictionary hostSessions) : ILoadBalancer
{
- public LeastConnectionsLoadBalancer(Dictionary hostSessions) => m_hostSessions = hostSessions;
-
public IReadOnlyList LoadBalance(IReadOnlyList hosts)
{
- lock (m_hostSessions)
- return m_hostSessions.OrderBy(static x => x.Value).Select(static x => x.Key).ToList();
+ lock (hostSessions)
+ return hostSessions.OrderBy(static x => x.Value).Select(static x => x.Key).ToList();
}
-
- private readonly Dictionary m_hostSessions;
}
- private sealed class ConnectionStringPool
+ private sealed class ConnectionStringPool(string connectionString, ConnectionPool? pool)
{
- public ConnectionStringPool(string connectionString, ConnectionPool? pool)
- {
- ConnectionString = connectionString;
- Pool = pool;
- }
-
- public string ConnectionString { get; }
- public ConnectionPool? Pool { get; }
+ public string ConnectionString { get; } = connectionString;
+ public ConnectionPool? Pool { get; } = pool;
}
static ConnectionPool()
diff --git a/src/MySqlConnector/Core/ConnectionSettings.cs b/src/MySqlConnector/Core/ConnectionSettings.cs
index 99c66d702..b4e9c87be 100644
--- a/src/MySqlConnector/Core/ConnectionSettings.cs
+++ b/src/MySqlConnector/Core/ConnectionSettings.cs
@@ -11,7 +11,7 @@ public ConnectionSettings(MySqlConnectionStringBuilder csb)
ConnectionStringBuilder = csb;
ConnectionString = csb.ConnectionString;
- if (csb.ConnectionProtocol == MySqlConnectionProtocol.UnixSocket || (!Utility.IsWindows() && (csb.Server.StartsWith("/", StringComparison.Ordinal) || csb.Server.StartsWith("./", StringComparison.Ordinal))))
+ if (csb.ConnectionProtocol == MySqlConnectionProtocol.UnixSocket || (!Utility.IsWindows() && (csb.Server.StartsWith('/') || csb.Server.StartsWith("./", StringComparison.Ordinal))))
{
if (csb.LoadBalance != MySqlLoadBalance.RoundRobin)
throw new NotSupportedException("LoadBalance not supported when ConnectionProtocol=UnixSocket");
@@ -26,7 +26,7 @@ public ConnectionSettings(MySqlConnectionStringBuilder csb)
if (csb.LoadBalance != MySqlLoadBalance.RoundRobin)
throw new NotSupportedException("LoadBalance not supported when ConnectionProtocol=NamedPipe");
ConnectionProtocol = MySqlConnectionProtocol.NamedPipe;
- HostNames = (csb.Server == "." || string.Equals(csb.Server, "localhost", StringComparison.OrdinalIgnoreCase)) ? s_localhostPipeServer : new[] { csb.Server };
+ HostNames = (csb.Server == "." || string.Equals(csb.Server, "localhost", StringComparison.OrdinalIgnoreCase)) ? s_localhostPipeServer : [ csb.Server ];
PipeName = csb.PipeName;
}
else if (csb.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
@@ -272,7 +272,7 @@ private ConnectionSettings(ConnectionSettings other, string host, int port, stri
ConnectionString = other.ConnectionString;
ConnectionProtocol = MySqlConnectionProtocol.Sockets;
- HostNames = new[] { host };
+ HostNames = [ host ];
LoadBalance = other.LoadBalance;
Port = port;
PipeName = other.PipeName;
diff --git a/src/MySqlConnector/Core/DbTypeMapping.cs b/src/MySqlConnector/Core/DbTypeMapping.cs
index 6fe3b096d..f72611ee7 100644
--- a/src/MySqlConnector/Core/DbTypeMapping.cs
+++ b/src/MySqlConnector/Core/DbTypeMapping.cs
@@ -2,24 +2,15 @@
namespace MySqlConnector.Core;
-internal sealed class DbTypeMapping
+internal sealed class DbTypeMapping(Type clrType, DbType[] dbTypes, Func