Skip to content

Re-add missing public APIs in NpgsqlCommand and NpgsqlTransaction - #2608

Merged
roji merged 1 commit into
npgsql:release/4.1from
baronfel:reapply-public-API-changes
Sep 11, 2019
Merged

roji merged 1 commit into
npgsql:release/4.1from
baronfel:reapply-public-API-changes

Conversation

@baronfel

@baronfel baronfel commented Sep 5, 2019

Copy link
Copy Markdown

Fixes #2607 by adding the two APIs that were altered there. Prospectively opening this MR to get checks started.

Comment thread src/Npgsql/NpgsqlCommand.cs Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was because the overload was ambiguous between the no-parameter and default-parameter members of the same name.

@YohDeadfall

Copy link
Copy Markdown
Contributor

The dev branch is for version 5, so you need to retarget the PR to release/4.1.

@baronfel
baronfel force-pushed the reapply-public-API-changes branch from 6080cf1 to 62d007e Compare September 6, 2019 14:02
@baronfel
baronfel changed the base branch from dev to release/4.1 September 6, 2019 14:03
@baronfel

baronfel commented Sep 6, 2019

Copy link
Copy Markdown
Author

Done, thanks for the reminder.

@YohDeadfall YohDeadfall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but would you mind to run an utility tool to check public API compatibility at all? Can't remember what I have used previously, but the first thing that I found now is BitDiffer. Otherwise, I'll do it, but a bit later.

@baronfel

baronfel commented Sep 7, 2019

Copy link
Copy Markdown
Author

I used SynVer.Lib and the following F# script to diff the surface area of the two dlls:

#I "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview9-19423-09"
#r "netstandard"
#r "/Users/chethusk/.nuget/packages/synver.lib/0.0.8/lib/netstandard2.0/SynVer.Lib.dll"

open System.Reflection
open SynVer

let previewPath = "/Users/chethusk/.nuget/packages/npgsql/4.1.0-preview2/lib/netcoreapp3.0/Npgsql.dll"
let oldPath = "/Users/chethusk/.nuget/packages/npgsql/4.0.9/lib/netstandard2.0/Npgsql.dll"

let preview = Assembly.LoadFile previewPath |> SurfaceArea.ofAssembly
let old = Assembly.LoadFile oldPath |> SurfaceArea.ofAssembly

let diffs = SurfaceArea.diff old preview

System.IO.File.WriteAllLines("/Users/chethusk/oss/foobar/diff.txt", diffs)

The full report is attached, I haven't gone over it 100% yet.

diff.txt

@baronfel

baronfel commented Sep 7, 2019

Copy link
Copy Markdown
Author

From that report, the list of missing or changed members:

  • Npgsql.BackendMessages.FieldDescription: default constructor gone
  • Npgsql.INpgsqlDatabaseInfoFactory.Load: timeout parameter changed namespace
  • Npgsql.NpgsqlBinaryImporter.Complete: void return changed to uint64
  • Npgsql.NpgsqlCommand.ExecuteReader: already noticed/reverted
  • Npgsql.NpgsqlConnection.WaitAsync: unit -> Task overload removed
  • Npgsql.NpgsqlDataReader: changed to concrete class
  • Npgsql.NpgsqlDataReader.GetStreamAsync: no-cancellation-token overload removed
  • Npgsql.NpgsqlDataReader.GetTextReaderAsync: no-cancellation-token overload removed
  • Npgsql.NpgsqlLargeObjectStream.GetLengthAsync: no-cancellation-token overload removed
  • Npgsql.NpgsqlStatement.Rows: uint32 => uint64
  • Npgsql.NpgsqlTimeout: type removed
  • Npgsql.NpgsqlTransaction.IsCompleted: removed (already addressed)
  • Npgsql.PostgresException: default constructor gone
  • Npgsql.PostgresNotice: default constructor gone
  • Npgsql.TypeHandlers.ArrayHandler.CreateArrayHandler: parameter type change from PostgresType to PostgresArrayType
  • Npgsql.TypeHandlers.ArrayHandler.CreateRangeHandler: parameter type change from PostgresType to PostgresArrayType
  • Npgsql.TypeHandlers.ArrayHandler<'TELEMENT>: new parameter added to constructor
  • Npgsql.TypeHandlers.ByteaHandler: default constructor gone
  • Npgsql.TypeHandlers.IMappedCompositeTypeHandlerFactory: type removed
  • Npgsql.TypeHandlers.JsonbHandler: type removed
  • Npgsql.TypeHandlers.RangeHandler<'TELEMENT>: new parameter added for range postgres type
  • Npgsql.TypeHandlers.RangeHandler<'TELEMENT>.CreateArrayHandler: parameter changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlSafeReadException: constructor parameter name changed
  • Npgsql.TypeHandling.NpgsqlSimpleTypeHandlerWithPsv<'TDEFAULT,'TPSV>: constructor parameter type changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlTypeHandler.CreateArrayHandler: parameter type changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlTypeHandler.CreateRangeHandler: parameter type changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlTypeHandler<'TDEFAULT>.CreateArrayHandler: parameter type changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlTypeHandler<'TDEFAULT>.CreateRangeHandler: parameter type changed from PostgresType to PostgresArrayType
  • Npgsql.TypeHandling.NpgsqlTypeHandlerFactory: type removed
  • Npgsql.TypeMapping.NpgsqlTypeMapping.TypeHandlerFactory: property type changed from NpgsqlTypeHandlerFactory to INpgsqlTypeHandlerFactory
  • Npgsql.TypeHandling.NpgsqlTypeHandlerFactory<'TDEFAULT>: changed base class to object
  • Npgsql.TypeMapping.NpgsqlTypeMappingBuilder.TypeHandlerFactory: property type changed from NpgsqlTypeHandlerFactory to INpgsqlTypeHandlerFactory
  • NpgsqlTypes.NpgsqlTsVector: list-of-lexemes constructor removed

@roji

roji commented Sep 8, 2019

Copy link
Copy Markdown
Member

No problem for bringing back parameter-less ExecuteReader, but NpgsqlTransaction.IsCompleted is a bit complicated... this was done as part of #2416, where we started recycling the NpgsqlTransaction instance. The logic of removing/hiding IsCompleted was that since the transaction instance will be revived, IsCompleted will switch from true to false, leading to potential confusion/dangerous behavior. Therefore, it is up to the user to track whether a transaction is in progress or not (which is the way ADO.NET works - IsCompleted has always been an Npgsql extension).

I'll have to investigate this a bit. Currently it is not required to actually dispose an NpgsqlTransaction before starting a new transaction - the only thing that matters is whether the transaction has completed on the PostgreSQL side. I'm not sure that's the desirable behavior. Depending on that, it may still make sense to have a public IsCompleted, with a contract that once the instance has been disposed, all bets are off. Give me a couple days to look at this.

@roji

roji commented Sep 11, 2019

Copy link
Copy Markdown
Member

@baronfel I've reverted the transaction recycling change in #2617, which also brings back the missing IsCompleted. Can you please remove that part from this PR?

@baronfel
baronfel force-pushed the reapply-public-API-changes branch from 62d007e to 0a646da Compare September 11, 2019 14:23
@baronfel

Copy link
Copy Markdown
Author

Done, and I reworked the name of the commit to reflect the smaller scope

@roji
roji merged this pull request into npgsql:release/4.1 Sep 11, 2019
@roji

roji commented Sep 11, 2019

Copy link
Copy Markdown
Member

Thanks @baronfel!

@baronfel
baronfel deleted the reapply-public-API-changes branch September 18, 2019 20:38
@baronfel

Copy link
Copy Markdown
Author

Should I log an issue with the remaining changed members to be reverted in the release/4.1 branch? I know that the TypeHandling changes have been somewhat changed, I'm speaking specifically of

Npgsql.BackendMessages.FieldDescription: default constructor gone
Npgsql.INpgsqlDatabaseInfoFactory.Load: timeout parameter changed namespace
Npgsql.NpgsqlBinaryImporter.Complete: void return changed to uint64
Npgsql.NpgsqlCommand.ExecuteReader: already noticed/reverted
Npgsql.NpgsqlConnection.WaitAsync: unit -> Task overload removed
Npgsql.NpgsqlDataReader: changed to concrete class
Npgsql.NpgsqlDataReader.GetStreamAsync: no-cancellation-token overload removed
Npgsql.NpgsqlDataReader.GetTextReaderAsync: no-cancellation-token overload removed
Npgsql.NpgsqlLargeObjectStream.GetLengthAsync: no-cancellation-token overload removed
Npgsql.NpgsqlStatement.Rows: uint32 => uint64
Npgsql.NpgsqlTimeout: type removed
Npgsql.NpgsqlTransaction.IsCompleted: removed (already addressed)
Npgsql.PostgresException: default constructor gone
Npgsql.PostgresNotice: default constructor gone

@roji

roji commented Sep 19, 2019

Copy link
Copy Markdown
Member

@baronfel yes please! It makes sense to add back the no-cancellation-token overloads, but it looks like we may keep most of the other changes listed.

BTW which tool are you using to detect these changes?

@baronfel

baronfel commented Sep 19, 2019 •

Copy link
Copy Markdown
Author

I'm using SynVer (per #2608 (comment)) and a short script. There's also a standalone windows executable for it, and I'm working on a PR for the tool to allow for usage as a dotnet SDK global tool, so you could do synver <source dll> <target dll> to get the same output. Along with potential enhancements like a structured json output, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants