Skip to content

Commit 9f44192

Browse files
committed
Implement new .NET Core 3.0 ADO.NET APIs
Pin dotnet sdk to 3.0.0-preview6 and implement new ADO.NET APIs introduced in .NET Core 3.0: * https://github.com/dotnet/corefx/issues/35564 * https://github.com/dotnet/corefx/issues/35012 Note: we cross-target netcoreapp3.0 since the new APIs aren't yet available in netstandard2.1, but this is expected to happen soon. Fixes npgsql#2481
1 parent 68147c4 commit 9f44192

6 files changed

+28
-5
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ install:
1818
- powershell .build\setup_appveyor.ps1
1919
# The following can be used to install a custom version of .NET Core
2020
- ps: Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" -OutFile "install-dotnet.ps1"
21-
- ps: .\install-dotnet.ps1 -Version 3.0.100-preview4-011223 -InstallDir "dotnetcli"
21+
- ps: .\install-dotnet.ps1 -Version 3.0.100-preview6-012264 -InstallDir "dotnetcli"
2222
services:
2323
- postgresql101
2424
before_build:

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.0.100-preview4-011223"
3+
"version": "3.0.100-preview6-012264"
44
}
55
}

src/Npgsql/Npgsql.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>Npgsql is the open source .NET data provider for PostgreSQL.</Description>
55
<PackageTags>npgsql postgresql postgres ado ado.net database sql</PackageTags>
66
<VersionPrefix>4.1.0</VersionPrefix>
7-
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
</PropertyGroup>
1010
<ItemGroup>

src/Npgsql/NpgsqlCommand.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,11 @@ void DeriveParametersForQuery()
556556
/// Creates a server-side prepared statement on the PostgreSQL server.
557557
/// This will make repeated future executions of this command much faster.
558558
/// </summary>
559-
#pragma warning disable CA1801 // Review unused parameters
559+
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
560+
public override Task PrepareAsync(CancellationToken cancellationToken)
561+
#else
560562
public Task PrepareAsync(CancellationToken cancellationToken)
561-
#pragma warning restore CA1801 // Review unused parameters
563+
#endif
562564
{
563565
cancellationToken.ThrowIfCancellationRequested();
564566
using (NoSynchronizationContextScope.Enter())

src/Npgsql/NpgsqlFactory.cs

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public sealed class NpgsqlFactory : DbProviderFactory, IServiceProvider
5151
/// </summary>
5252
public override DbDataAdapter CreateDataAdapter() => new NpgsqlDataAdapter();
5353

54+
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
55+
/// <summary>
56+
/// Specifies whether the specific <see cref="DbProviderFactory"/> supports the <see cref="DbDataAdapter"/> class.
57+
/// </summary>
58+
public override bool CanCreateDataAdapter => true;
59+
60+
/// <summary>
61+
/// Specifies whether the specific <see cref="DbProviderFactory"/> supports the <see cref="DbCommandBuilder"/> class.
62+
/// </summary>
63+
public override bool CanCreateCommandBuilder => true;
64+
#endif
65+
5466
#region IServiceProvider Members
5567

5668
/// <summary>

src/Npgsql/NpgsqlTransaction.cs

+9
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ async Task Commit(bool async)
136136
/// Commits the database transaction.
137137
/// </summary>
138138
[PublicAPI]
139+
140+
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
141+
public override Task CommitAsync(CancellationToken cancellationToken = default)
142+
#else
139143
public Task CommitAsync(CancellationToken cancellationToken = default)
144+
#endif
140145
{
141146
if (cancellationToken.IsCancellationRequested)
142147
return Task.FromCanceled(cancellationToken);
@@ -165,7 +170,11 @@ async Task Rollback(bool async)
165170
/// Rolls back a transaction from a pending state.
166171
/// </summary>
167172
[PublicAPI]
173+
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
174+
public override Task RollbackAsync(CancellationToken cancellationToken = default)
175+
#else
168176
public Task RollbackAsync(CancellationToken cancellationToken = default)
177+
#endif
169178
{
170179
if (cancellationToken.IsCancellationRequested)
171180
return Task.FromCanceled(cancellationToken);

0 commit comments

Comments
 (0)