Skip to content

Commit

Permalink
Add net48 TFM. Fixes #1355
Browse files Browse the repository at this point in the history
This enables "TlsVesion=Tls13" to be used in the connection string.

It also supports X509Certificate2.CopyWithPrivateKey on .NET Framework 4.8.
  • Loading branch information
bgrainger committed Sep 3, 2023
1 parent fec9506 commit 3d10049
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
55 changes: 39 additions & 16 deletions src/MySqlConnector/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbColumn</Target>
<Left>lib/net461/MySqlConnector.dll</Left>
<Right>lib/netstandard2.0/MySqlConnector.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbColumn</Target>
<Left>lib/net462/MySqlConnector.dll</Left>
<Right>lib/net471/MySqlConnector.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbDataSource</Target>
<Left>lib/net6.0/MySqlConnector.dll</Left>
<Right>lib/net7.0/MySqlConnector.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:MySqlConnector.MySqlDataReader</Target>
<Left>lib/netstandard2.0/MySqlConnector.dll</Left>
<Right>lib/net462/MySqlConnector.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:MySqlConnector.MySqlBatchCommandCollection</Target>
<Left>lib/netstandard2.1/MySqlConnector.dll</Left>
<Right>lib/net6.0/MySqlConnector.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbColumn</Target>
<Left>lib/net461/MySqlConnector.dll</Left>
<Right>lib/net471/MySqlConnector.dll</Right>
<DiagnosticId>CP1002</DiagnosticId>
<Target>System.Data.Common, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Target>
<Left>lib/net5.0/MySqlConnector.dll</Left>
<Right>lib/netstandard2.1/MySqlConnector.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbColumn</Target>
<Left>lib/net461/MySqlConnector.dll</Left>
<Right>lib/netstandard2.0/MySqlConnector.dll</Right>
<DiagnosticId>CP1002</DiagnosticId>
<Target>System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Target>
<Left>lib/net5.0/MySqlConnector.dll</Left>
<Right>lib/netstandard2.1/MySqlConnector.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Data.Common.DbColumn</Target>
<Left>lib/net462/MySqlConnector.dll</Left>
<Right>lib/net471/MySqlConnector.dll</Right>
<DiagnosticId>CP1002</DiagnosticId>
<Target>System.Data.Common, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Target>
<Left>lib/netcoreapp3.1/MySqlConnector.dll</Left>
<Right>lib/netstandard2.1/MySqlConnector.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:MySqlConnector.MySqlDataReader</Target>
<Left>lib/netstandard2.0/MySqlConnector.dll</Left>
<Right>lib/net462/MySqlConnector.dll</Right>
<DiagnosticId>CP1002</DiagnosticId>
<Target>System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Target>
<Left>lib/netcoreapp3.1/MySqlConnector.dll</Left>
<Right>lib/netstandard2.1/MySqlConnector.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
Expand Down
2 changes: 1 addition & 1 deletion src/MySqlConnector/Core/ConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ConnectionSettings(MySqlConnectionStringBuilder csb)
TlsVersions |= SslProtocols.Tls11;
else if (minorVersion == '2')
TlsVersions |= SslProtocols.Tls12;
#if NETCOREAPP3_0_OR_GREATER
#if NETCOREAPP3_0_OR_GREATER || NET48_OR_GREATER
else if (minorVersion == '3')
TlsVersions |= SslProtocols.Tls13;
#endif
Expand Down
8 changes: 3 additions & 5 deletions src/MySqlConnector/MySqlConnector.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net471;netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net471;net48;netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>A truly async MySQL ADO.NET provider, supporting MySQL Server, MariaDB, Amazon Aurora, Azure Database for MySQL, Google Cloud SQL, and more.</Description>
<Copyright>Copyright 2016–2023 Bradley Grainger</Copyright>
<Authors>Bradley Grainger</Authors>
Expand All @@ -19,15 +19,13 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net471' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net471' OR '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Transactions" />
<Using Remove="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net471' OR '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net471' OR '$(TargetFramework)' == 'net48' OR '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="IndexRange" Version="1.0.2" PrivateAssets="All" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/MySqlConnector/Utilities/NullableAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Supports using nullable attributes on older frameworks.
// Copied from https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Diagnostics/CodeAnalysis/NullableAttributes.cs

#if NET462 || NET471 || NETSTANDARD2_0 || NETCOREAPP2_1
#if NET462 || NET471 || NET48 || NETSTANDARD2_0 || NETCOREAPP2_1
namespace System.Diagnostics.CodeAnalysis;

/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
Expand Down

0 comments on commit 3d10049

Please sign in to comment.