Skip to content

Commit

Permalink
Implement new .NET Core 3.0 ADO.NET APIs
Browse files Browse the repository at this point in the history
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 #2481
  • Loading branch information
roji committed Jul 7, 2019
1 parent 6bb9ef0 commit 8d3daed
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install:
- powershell .build\setup_appveyor.ps1
# The following can be used to install a custom version of .NET Core
- ps: Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" -OutFile "install-dotnet.ps1"
- ps: .\install-dotnet.ps1 -Version 3.0.100-preview4-011223 -InstallDir "dotnetcli"
- ps: .\install-dotnet.ps1 -Version 3.0.100-preview6-012264 -InstallDir "dotnetcli"
services:
- postgresql101
before_build:
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100-preview4-011223"
"version": "3.0.100-preview6-012264"
}
}
2 changes: 1 addition & 1 deletion src/Npgsql/Npgsql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>Npgsql is the open source .NET data provider for PostgreSQL.</Description>
<PackageTags>npgsql postgresql postgres ado ado.net database sql</PackageTags>
<VersionPrefix>4.1.0</VersionPrefix>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/Npgsql/NpgsqlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,11 @@ void DeriveParametersForQuery()
/// Creates a server-side prepared statement on the PostgreSQL server.
/// This will make repeated future executions of this command much faster.
/// </summary>
#pragma warning disable CA1801 // Review unused parameters
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
public override Task PrepareAsync(CancellationToken cancellationToken)
#else
public Task PrepareAsync(CancellationToken cancellationToken)
#pragma warning restore CA1801 // Review unused parameters
#endif
{
cancellationToken.ThrowIfCancellationRequested();
using (NoSynchronizationContextScope.Enter())
Expand Down
12 changes: 12 additions & 0 deletions src/Npgsql/NpgsqlFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public sealed class NpgsqlFactory : DbProviderFactory, IServiceProvider
/// </summary>
public override DbDataAdapter CreateDataAdapter() => new NpgsqlDataAdapter();

#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
/// <summary>
/// Specifies whether the specific <see cref="DbProviderFactory"/> supports the <see cref="DbDataAdapter"/> class.
/// </summary>
public override bool CanCreateDataAdapter => true;

/// <summary>
/// Specifies whether the specific <see cref="DbProviderFactory"/> supports the <see cref="DbCommandBuilder"/> class.
/// </summary>
public override bool CanCreateCommandBuilder => true;
#endif

#region IServiceProvider Members

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Npgsql/NpgsqlTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ async Task Commit(bool async)
/// Commits the database transaction.
/// </summary>
[PublicAPI]

#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
public override Task CommitAsync(CancellationToken cancellationToken = default)
#else
public Task CommitAsync(CancellationToken cancellationToken = default)
#endif
{
if (cancellationToken.IsCancellationRequested)
return Task.FromCanceled(cancellationToken);
Expand Down Expand Up @@ -165,7 +170,11 @@ async Task Rollback(bool async)
/// Rolls back a transaction from a pending state.
/// </summary>
[PublicAPI]
#if !NET461 && !NETSTANDARD2_0 && !NETSTANDARD2_1
public override Task RollbackAsync(CancellationToken cancellationToken = default)
#else
public Task RollbackAsync(CancellationToken cancellationToken = default)
#endif
{
if (cancellationToken.IsCancellationRequested)
return Task.FromCanceled(cancellationToken);
Expand Down

0 comments on commit 8d3daed

Please sign in to comment.