diff --git a/src/Workspaces/Core/Portable/Storage/SQLite/NativeMethods.cs b/src/Workspaces/Core/Portable/Storage/SQLite/NativeMethods.cs index 5e95dd871dfa2..aff6924dc951e 100644 --- a/src/Workspaces/Core/Portable/Storage/SQLite/NativeMethods.cs +++ b/src/Workspaces/Core/Portable/Storage/SQLite/NativeMethods.cs @@ -24,6 +24,8 @@ public static SafeSqliteHandle sqlite3_open_v2(string filename, int flags, strin try { + // Always return a non-null handle to match default P/Invoke marshaling behavior. SafeHandle.IsInvalid + // will be true when the handle is not usable, but the handle instance can be disposed either way. return new SafeSqliteHandle(wrapper); } catch @@ -45,6 +47,8 @@ public static SafeSqliteStatementHandle sqlite3_prepare_v2(SafeSqliteHandle db, try { + // Always return a non-null handle to match default P/Invoke marshaling behavior. SafeHandle.IsInvalid + // will be true when the handle is not usable, but the handle instance can be disposed either way. return new SafeSqliteStatementHandle(db, wrapper); } catch @@ -66,6 +70,8 @@ public static SafeSqliteBlobHandle sqlite3_blob_open(SafeSqliteHandle db, string try { + // Always return a non-null handle to match default P/Invoke marshaling behavior. SafeHandle.IsInvalid + // will be true when the handle is not usable, but the handle instance can be disposed either way. return new SafeSqliteBlobHandle(db, wrapper); } catch