Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.8.0-beta - System.ArgumentException: method arguments are incompatible #1048

Closed
tranb3r opened this issue Jun 21, 2021 · 4 comments · Fixed by #1059
Closed

1.8.0-beta - System.ArgumentException: method arguments are incompatible #1048

tranb3r opened this issue Jun 21, 2021 · 4 comments · Fixed by #1059

Comments

@tranb3r
Copy link

tranb3r commented Jun 21, 2021

There is an exception when using the new version sqlite-net-pcl 1.8.0-beta with SqliteNetExtensions

[Error] Exception catched !!!System.ArgumentException: method arguments are incompatible
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x002e3] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System/Delegate.cs:281 
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System/Delegate.cs:296 
  at SQLite.FastColumnSetter.CreateNullableTypedSetterDelegate[ObjectType,ColumnMemberType] (SQLite.TableMapping+Column column, System.Func`3[T1,T2,TResult] getColumnValue) [0x00077] in <a9edccd8a27f41fdaae16acd8ec0ca8e>:0 
  at SQLite.FastColumnSetter.GetFastSetter[T] (SQLite.SQLiteConnection conn, SQLite.TableMapping+Column column) [0x000a0] in <a9edccd8a27f41fdaae16acd8ec0ca8e>:0 
  at SQLite.SQLiteCommand+<ExecuteDeferredQuery>d__12`1[T].MoveNext () [0x000d1] in <a9edccd8a27f41fdaae16acd8ec0ca8e>:0 
  at System.Collections.Generic.List`1[T].AddEnumerable (System.Collections.Generic.IEnumerable`1[T] enumerable) [0x00059] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:1108 
  at System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) [0x00062] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:87 
  at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:30 
  at SQLite.SQLiteCommand.ExecuteQuery[T] (SQLite.TableMapping map) [0x00007] in <a9edccd8a27f41fdaae16acd8ec0ca8e>:0 
  at SQLite.SQLiteConnection.Query (SQLite.TableMapping map, System.String query, System.Object[] args) [0x00008] in <a9edccd8a27f41fdaae16acd8ec0ca8e>:0 
  at SQLiteNetExtensions.Extensions.ReadOperations.GetManyToOneChildren[T] (SQLite.SQLiteConnection conn, System.Collections.Generic.IList`1[T] elements, System.Reflection.PropertyInfo relationshipProperty, System.Boolean recursive, System.Collections.Generic.Dictionary`2[TKey,TValue] objectCache) [0x00159] in D:\Dev\Zitch\sqlite-net-extensions\SQLiteNetExtensions\Extensions\ReadOperations.cs:358 
  at SQLiteNetExtensions.Extensions.ReadOperations.GetChildRecursive (SQLite.SQLiteConnection conn, System.Object element, System.Reflection.PropertyInfo relationshipProperty, System.Boolean recursive, System.Collections.Generic.Dictionary`2[TKey,TValue] objectCache) [0x00044] in D:\Dev\Zitch\sqlite-net-extensions\SQLiteNetExtensions\Extensions\ReadOperations.cs:190 
  at SQLiteNetExtensions.Extensions.ReadOperations.GetChildrenRecursive (SQLite.SQLiteConnection conn, System.Object element, System.Boolean onlyCascadeChildren, System.Boolean recursive, System.Collections.Generic.Dictionary`2[TKey,TValue] objectCache) [0x0003a] in D:\Dev\Zitch\sqlite-net-extensions\SQLiteNetExtensions\Extensions\ReadOperations.cs:169 
  at SQLiteNetExtensions.Extensions.ReadOperations.GetChildren[T] (SQLite.SQLiteConnection conn, T element, System.Boolean recursive) [0x00000] in D:\Dev\Zitch\sqlite-net-extensions\SQLiteNetExtensions\Extensions\ReadOperations.cs:110 
  at SQLiteNetExtensionsAsync.Extensions.ReadOperations+<>c__DisplayClass3_0`1[T].<GetChildrenAsync>b__0 () [0x00029] in D:\Dev\Zitch\sqlite-net-extensions\SQLiteNetExtensionsAsync\Extensions\ReadOperations.cs:123 
  at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2476 
  at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 

This issue has been introduced in 1.8.0-beta with PR #902 (Fast Column Setters)

I've created a simple repro project, with 2 applications:

  • TestSqliteNet.Android : xamarin forms android app
  • TestSqliteNet.Net : netcoreapp3.1 console app

With sqlite-net-pcl 1.8.0-beta, there is an exception on both environments:

  • android : System.ArgumentException: method arguments are incompatible
  • netcoreapp3.1 : System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type

No error with 1.7.335.

The code for the test is in TestClass.cs in the shared lib (TestSqliteNet).
It uses sqlite-net-pcl and SQLiteNetExtensions ; no need for sqlcipher nor async api.

TestSqliteNet.zip

@tranb3r
Copy link
Author

tranb3r commented Aug 26, 2021

@praeclarum
Could you please take a look at this regression before you release the final 1.8.0 ?
Thanks !

@inforithmics
Copy link
Contributor

inforithmics commented Aug 31, 2021

Minimal reproduction sample:

var db = new SQLiteConnection(dbPath);
db.CreateTable<ClassB>();
var b = new ClassB();
db.Insert(b);

var test = db.CreateCommand("select * from ClassB")
                .ExecuteDeferredQuery<object>(new TableMapping(typeof(ClassB))).ToList();

@praeclarum
Copy link
Owner

Thank you @tranb3r for this fix. This is an interesting one... the nullable design strikes again.

@tranb3r
Copy link
Author

tranb3r commented Sep 3, 2021

Thanks @inforithmics for the fix !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants