Skip to content
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
26 changes: 13 additions & 13 deletions .ci/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,52 @@ steps:
displayName: 'Publish MySqlConnector.Tests'
inputs:
command: 'publish'
arguments: '-c Release -f net9.0 --no-build tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj'
arguments: '-c Release -f net10.0 --no-build tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@1
inputs:
artifact: 'MySqlConnector.Tests-9.0-$(Agent.OS)'
targetPath: 'artifacts/publish/MySqlConnector.Tests/release_net9.0'
artifact: 'MySqlConnector.Tests-10.0-$(Agent.OS)'
targetPath: 'artifacts/publish/MySqlConnector.Tests/release_net10.0'
publishLocation: 'pipeline'

- task: DotNetCoreCLI@2
displayName: 'Publish Conformance.Tests'
inputs:
command: 'publish'
arguments: '-c Release -f net9.0 --no-build tests/Conformance.Tests/Conformance.Tests.csproj'
arguments: '-c Release -f net10.0 --no-build tests/Conformance.Tests/Conformance.Tests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@1
inputs:
artifact: 'Conformance.Tests-9.0-$(Agent.OS)'
targetPath: 'artifacts/publish/Conformance.Tests/release_net9.0'
artifact: 'Conformance.Tests-10.0-$(Agent.OS)'
targetPath: 'artifacts/publish/Conformance.Tests/release_net10.0'
publishLocation: 'pipeline'

- task: DotNetCoreCLI@2
displayName: 'Publish MySqlConnector.DependencyInjection.Tests'
inputs:
command: 'publish'
arguments: '-c Release -f net9.0 --no-build tests/MySqlConnector.DependencyInjection.Tests/MySqlConnector.DependencyInjection.Tests.csproj'
arguments: '-c Release -f net10.0 --no-build tests/MySqlConnector.DependencyInjection.Tests/MySqlConnector.DependencyInjection.Tests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@1
inputs:
artifact: 'MySqlConnector.DependencyInjection.Tests-9.0-$(Agent.OS)'
targetPath: 'artifacts/publish/MySqlConnector.DependencyInjection.Tests/release_net9.0'
artifact: 'MySqlConnector.DependencyInjection.Tests-10.0-$(Agent.OS)'
targetPath: 'artifacts/publish/MySqlConnector.DependencyInjection.Tests/release_net10.0'
publishLocation: 'pipeline'

- task: DotNetCoreCLI@2
displayName: 'Publish IntegrationTests (9.0)'
displayName: 'Publish IntegrationTests (10.0)'
inputs:
command: 'publish'
arguments: '-c Release -f net9.0 --no-build tests/IntegrationTests/IntegrationTests.csproj'
arguments: '-c Release -f net10.0 --no-build tests/IntegrationTests/IntegrationTests.csproj'
publishWebProjects: false
zipAfterPublish: false
- task: PublishPipelineArtifact@1
inputs:
artifact: 'IntegrationTests-net9.0-$(Agent.OS)'
targetPath: 'artifacts/publish/IntegrationTests/release_net9.0'
artifact: 'IntegrationTests-net10.0-$(Agent.OS)'
targetPath: 'artifacts/publish/IntegrationTests/release_net10.0'
publishLocation: 'pipeline'

- task: DotNetCoreCLI@2
Expand Down
2 changes: 1 addition & 1 deletion .ci/conformance-test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
condition: always()
inputs:
buildType: 'current'
artifactName: 'Conformance.Tests-9.0-$(Agent.OS)'
artifactName: 'Conformance.Tests-10.0-$(Agent.OS)'
targetPath: '$(Build.BinariesDirectory)/9.0'
- task: DotNetCoreCLI@2
displayName: 'Conformance Tests'
Expand Down
4 changes: 2 additions & 2 deletions .ci/integration-tests-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ steps:
image: ${{ parameters.image }}
unsupportedFeatures: ${{ parameters.unsupportedFeatures }}
connectionString: 'server=localhost;port=3300;user id=mysqltest;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600;${{ parameters.connectionStringExtra }}'
platform: 'net9.0'
platform: 'net10.0'
description: 'No SSL'
- template: 'integration-test-steps.yml'
parameters:
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: 'net9.0'
platform: 'net10.0'
description: 'SSL'
6 changes: 3 additions & 3 deletions .ci/mysqlconnector-tests-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'MySqlConnector.Tests-9.0-$(Agent.OS)'
artifactName: 'MySqlConnector.Tests-10.0-$(Agent.OS)'
targetPath: $(System.DefaultWorkingDirectory)
- task: DotNetCoreCLI@2
displayName: 'Run MySqlConnector.Tests'
Expand All @@ -18,7 +18,7 @@ steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'MySqlConnector.DependencyInjection.Tests-9.0-$(Agent.OS)'
artifactName: 'MySqlConnector.DependencyInjection.Tests-10.0-$(Agent.OS)'
targetPath: $(System.DefaultWorkingDirectory)
- task: DotNetCoreCLI@2
displayName: 'Run MySqlConnector.DependencyInjection.Tests'
Expand All @@ -30,4 +30,4 @@ steps:
inputs:
testResultsFormat: VSTest
testResultsFiles: '**/*.trx'
testRunTitle: 'MySqlConnector.Tests-9.0-$(Agent.OS)'
testRunTitle: 'MySqlConnector.Tests-10.0-$(Agent.OS)'
2 changes: 1 addition & 1 deletion .ci/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dotnet test -c Release -f net462
if ($LASTEXITCODE -ne 0){
exit $LASTEXITCODE;
}
dotnet test -c Release -f net9.0
dotnet test -c Release -f net10.0
if ($LASTEXITCODE -ne 0){
exit $LASTEXITCODE;
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tfm: [ 'net8.0', 'net9.0' ]
tfm: [ 'net8.0', 'net10.0' ]
services:
mysql:
image: mysql:9.4
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>preview</LangVersion>
<LangVersion>14.0</LangVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<NoWarn>$(NoWarn);1591;CA1708;CA1835;CA2215;CA5397;NU5105;SYSLIB0039</NoWarn>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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 8.0 -InstallDir "dotnetcli"
- ps: .\install-dotnet.ps1 -Channel 9.0 -InstallDir "dotnetcli"
- ps: .\install-dotnet.ps1 -Channel 10.0 -InstallDir "dotnetcli"
build_script:
- dotnet --info
before_test:
Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
DotNetCoreSdkVersion: '9.x'
DotNetCoreSdkVersion: '10.x'
NUGET_PACKAGES: '$(Pipeline.Workspace)/.nuget/packages'

jobs:
Expand Down Expand Up @@ -107,18 +107,18 @@ jobs:
displayName: 'Remove target frameworks'
inputs:
targetType: 'inline'
script: '((Get-Content .\tests\IntegrationTests\IntegrationTests.csproj -Raw) -replace(''<TargetFrameworks>.*</TargetFrameworks>'', ''<TargetFrameworks>net481;net9.0</TargetFrameworks>'')) | Set-Content .\tests\IntegrationTests\IntegrationTests.csproj'
script: '((Get-Content .\tests\IntegrationTests\IntegrationTests.csproj -Raw) -replace(''<TargetFrameworks>.*</TargetFrameworks>'', ''<TargetFrameworks>net481;net10.0</TargetFrameworks>'')) | Set-Content .\tests\IntegrationTests\IntegrationTests.csproj'
- task: DotNetCoreCLI@2
displayName: 'Restore packages'
inputs:
command: 'restore'
- task: DotNetCoreCLI@2
displayName: 'Integration tests (net481/net9.0)'
displayName: 'Integration tests (net481/net10.0)'
inputs:
command: 'test'
projects: 'tests/IntegrationTests/IntegrationTests.csproj'
arguments: '-c Release --no-restore -p:TestTfmsInParallel=false'
testRunTitle: ${{ format('{0}, $(Agent.OS), {1}, {2}', 'mysql:8.0', 'net481/net9.0', 'No SSL') }}
testRunTitle: ${{ format('{0}, $(Agent.OS), {1}, {2}', 'mysql:8.0', 'net481/net10.0', 'No SSL') }}
env:
DATA__UNSUPPORTEDFEATURES: 'Ed25519,QueryAttributes,ParsecAuthentication,Redirection,StreamingResults,Tls11,TlsFingerprintValidation,UnixDomainSocket,Vector'
DATA__CONNECTIONSTRING: 'server=localhost;port=3306;user id=mysqltest;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600;AllowPublicKeyRetrieval=True;UseCompression=True'
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.200",
"version": "10.0.100-rc.1",
"rollForward": "latestFeature"
}
}
10 changes: 0 additions & 10 deletions src/MySqlConnector/Authentication/AuthenticationPlugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ public static class AuthenticationPlugins
/// <param name="plugin">The authentication plugin.</param>
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);
}
Expand Down
5 changes: 0 additions & 5 deletions src/MySqlConnector/Core/ResultSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,7 @@ public bool HasRows

public int GetOrdinal(string name)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(name);
#else
if (name is null)
throw new ArgumentNullException(nameof(name));
#endif
if (!HasResultSet)
throw new InvalidOperationException("There is no current result set.");

Expand Down
27 changes: 2 additions & 25 deletions src/MySqlConnector/Core/Row.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ public void SetData(ReadOnlyMemory<byte> data)

public object GetValue(int ordinal)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfNegative(ordinal);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(ordinal, ResultSet.ColumnDefinitions!.Length);
#else
if (ordinal < 0 || ordinal >= ResultSet.ColumnDefinitions!.Length)
throw new ArgumentOutOfRangeException(nameof(ordinal), $"value must be between 0 and {ResultSet.ColumnDefinitions!.Length - 1}");
#endif

if (m_dataOffsetLengths[ordinal].Offset == -1)
return DBNull.Value;
Expand Down Expand Up @@ -235,8 +230,8 @@ public short GetInt16(int ordinal)

public int GetInt32(int ordinal)
{
if (ordinal < 0 || ordinal >= ResultSet.ColumnDefinitions!.Length)
throw new ArgumentOutOfRangeException(nameof(ordinal), $"value must be between 0 and {ResultSet.ColumnDefinitions!.Length - 1}");
ArgumentOutOfRangeException.ThrowIfNegative(ordinal);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(ordinal, ResultSet.ColumnDefinitions!.Length);
if (m_dataOffsetLengths[ordinal].Offset == -1)
throw new InvalidCastException("Can't convert NULL to Int32");

Expand Down Expand Up @@ -424,12 +419,7 @@ public MySqlDecimal GetMySqlDecimal(int ordinal)

public int GetValues(object[] values)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(values);
#else
if (values is null)
throw new ArgumentNullException(nameof(values));
#endif
int count = Math.Min(values.Length, ResultSet.ColumnDefinitions!.Length);
for (int i = 0; i < count; i++)
values[i] = GetValue(i);
Expand Down Expand Up @@ -463,24 +453,11 @@ private void CheckBinaryColumn(int ordinal)

private static void CheckBufferArguments<T>(long dataOffset, T[] buffer, int bufferOffset, int length)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfNegative(dataOffset);
ArgumentOutOfRangeException.ThrowIfGreaterThan(dataOffset, int.MaxValue);
ArgumentOutOfRangeException.ThrowIfNegative(length);
ArgumentOutOfRangeException.ThrowIfNegative(bufferOffset);
ArgumentOutOfRangeException.ThrowIfGreaterThan(bufferOffset, buffer.Length);
#else
if (dataOffset < 0)
throw new ArgumentOutOfRangeException(nameof(dataOffset), dataOffset, nameof(dataOffset) + " must be non-negative");
if (dataOffset > int.MaxValue)
throw new ArgumentOutOfRangeException(nameof(dataOffset), dataOffset, nameof(dataOffset) + " must be a 32-bit integer");
if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length), length, nameof(length) + " must be non-negative");
if (bufferOffset < 0)
throw new ArgumentOutOfRangeException(nameof(bufferOffset), bufferOffset, nameof(bufferOffset) + " must be non-negative");
if (bufferOffset > buffer.Length)
throw new ArgumentOutOfRangeException(nameof(bufferOffset), bufferOffset, nameof(bufferOffset) + " must be within the buffer");
#endif
if (checked(bufferOffset + length) > buffer.Length)
throw new ArgumentException(nameof(bufferOffset) + " + " + nameof(length) + " cannot exceed " + nameof(buffer) + "." + nameof(buffer.Length), nameof(length));
}
Expand Down
5 changes: 0 additions & 5 deletions src/MySqlConnector/Core/SchemaProvider.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ internal sealed partial class SchemaProvider
{
public async ValueTask<DataTable> GetSchemaAsync(IOBehavior ioBehavior, string collectionName, string?[]? restrictionValues, CancellationToken cancellationToken)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(collectionName);
#else
if (collectionName is null)
throw new ArgumentNullException(nameof(collectionName));
#endif

var dataTable = new DataTable();
if (string.Equals(collectionName, "MetaDataCollections", StringComparison.OrdinalIgnoreCase))
Expand Down
17 changes: 11 additions & 6 deletions src/MySqlConnector/Core/ServerSession.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Buffers;
using System.Buffers.Text;
using System.ComponentModel;
using System.Diagnostics;
Expand Down Expand Up @@ -686,6 +687,9 @@ private bool ValidateFingerprint(byte[]? validationHash, ReadOnlySpan<byte> chal

static bool TryConvertFromHexString(ReadOnlySpan<byte> hexChars, Span<byte> data)
{
#if NET10_0_OR_GREATER
return Convert.FromHexString(hexChars, data, out _, out _) == OperationStatus.Done;
#else
ReadOnlySpan<byte> hexDigits = "0123456789ABCDEFabcdef"u8;
for (var i = 0; i < hexChars.Length; i += 2)
{
Expand All @@ -700,6 +704,7 @@ static bool TryConvertFromHexString(ReadOnlySpan<byte> hexChars, Span<byte> data
data[i / 2] = (byte) ((high << 4) | low);
}
return true;
#endif
}
}

Expand Down Expand Up @@ -967,7 +972,7 @@ private async Task<PayloadData> SendClearPasswordAsync(string password, IOBehavi

private async Task<PayloadData> SendEncryptedPasswordAsync(
byte[] switchRequestData,
string rsaPublicKey,
byte[] rsaPublicKey,
string password,
IOBehavior ioBehavior,
CancellationToken cancellationToken)
Expand All @@ -988,7 +993,7 @@ private async Task<PayloadData> SendEncryptedPasswordAsync(
RSAParameters rsaParameters;
try
{
rsaParameters = Utility.GetRsaParameters(rsaPublicKey);
rsaParameters = Utility.GetRsaParameters(Encoding.ASCII.GetString(rsaPublicKey));
}
catch (Exception ex)
{
Expand All @@ -1015,13 +1020,13 @@ private async Task<PayloadData> SendEncryptedPasswordAsync(
return await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
}

private async Task<string> GetRsaPublicKeyAsync(string switchRequestName, ConnectionSettings cs, IOBehavior ioBehavior, CancellationToken cancellationToken)
private async Task<byte[]> GetRsaPublicKeyAsync(string switchRequestName, ConnectionSettings cs, IOBehavior ioBehavior, CancellationToken cancellationToken)
{
if (cs.ServerRsaPublicKeyFile.Length != 0)
{
try
{
return File.ReadAllText(cs.ServerRsaPublicKeyFile);
return File.ReadAllBytes(cs.ServerRsaPublicKeyFile);
}
catch (IOException ex)
{
Expand All @@ -1037,7 +1042,7 @@ private async Task<string> GetRsaPublicKeyAsync(string switchRequestName, Connec
await SendReplyAsync(new PayloadData([payloadContent]), ioBehavior, cancellationToken).ConfigureAwait(false);
var payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
var publicKeyPayload = AuthenticationMoreDataPayload.Create(payload.Span);
return Encoding.ASCII.GetString(publicKeyPayload.Data);
return publicKeyPayload.Data;
}

Log.CouldNotUseAuthenticationMethodForRsa(m_logger, Id, switchRequestName);
Expand Down Expand Up @@ -1905,7 +1910,7 @@ private bool ShouldGetRealServerDetails(ConnectionSettings cs)

// detect AWS RDS Proxy, if hostname like <name>.proxy-<random-chars>.<region>.rds.amazonaws.com
if (HostName.EndsWith(".rds.amazonaws.com", StringComparison.OrdinalIgnoreCase) &&
HostName.Contains(".proxy-", StringComparison.OrdinalIgnoreCase))
HostName.AsSpan().Contains(".proxy-".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
return true;
}
Expand Down
5 changes: 0 additions & 5 deletions src/MySqlConnector/Core/SqlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal abstract class SqlParser(StatementPreparer preparer)

public void Parse(string sql)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(sql);
#else
if (sql is null)
throw new ArgumentNullException(nameof(sql));
#endif
OnBeforeParse(sql);

int parameterStartIndex = -1;
Expand Down
Loading