querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

Breaking Changes Due to Addition of Optional CancellationToken Parameters

Open nathanaw opened this issue 3 years ago • 0 comments

Expected Behavior

Binary backwards compatibility within a major version (Semver)

Current Behavior

The addition of optional parameters in releases after 2.2.0 make the packages incompatible.

Possible Solution

A two step change:

  1. Add overloads that do not include the new optional parameters to maintain binary backwards compatibility.
  2. Change the methods (which accept the optional cancellation token) so that the cancellation token parameter is not optional.

This should be backward compatible with both 2.2.x and 2.3.x.

Steps to Reproduce

  1. Create a library "foo" compiled against SqlKata version 2.2.0. Use GetAsync() method.
  2. Create an application "bar" that uses library "foo", and references SqlKata 2.3.x
  3. Run application and observe a missing method exception

(See attached below.)

Resulting exception:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'System.Threading.Tasks.Task`1<System.Collections.Generic.IEnumerable`1<System.Object>> SqlKata.Execution.QueryExtensions.GetAsync(SqlKata.Query, System.Data.IDbTransaction, System.Nullable`1<Int32>)'.
  Source=Foo
  StackTrace:
   at 
Foo.Test.<CallGetAsync>d__0.MoveNext() in C:\src\temp\sqlkata-lib\Foo\Test.cs:line 19
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Foo.Test.CallGetAsync()
   at Foo.Program.<Main>d__0.MoveNext() in C:\src\temp\sqlkata-app\Bar\Test.cs:line 15

Notes

The Fuget tooling provides a quick snapshot between the released packages, showing the API differences: https://www.fuget.org/packages/SqlKata.Execution/2.3.7/lib/netstandard2.0/diff/2.2.0/

Attached is a sample pair of projects showing the above repro:

sqlkata-breaking-change-sample.zip

nathanaw avatar Jun 30 '21 14:06 nathanaw