Skip to content

Commit deb284d

Browse files
committed
Add runtime config option for static linkage
1 parent 494e7e9 commit deb284d

27 files changed

+324
-0
lines changed

src/SQLitePCLRaw.provider.e_sqlcipher/Generated/provider_e_sqlcipher_funcptrs_notwin.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,18 @@ static class NativeMethods
15551555
{
15561556
private const string SQLITE_DLL = "e_sqlcipher";
15571557

1558+
#if NET
1559+
static NativeMethods()
1560+
{
1561+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1562+
{
1563+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1564+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1565+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1566+
}
1567+
}
1568+
#endif
1569+
15581570
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15591571
public static extern unsafe int sqlite3_close(IntPtr db);
15601572

src/SQLitePCLRaw.provider.e_sqlcipher/Generated/provider_e_sqlcipher_funcptrs_win.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,18 @@ static class NativeMethods
15581558
{
15591559
private const string SQLITE_DLL = "e_sqlcipher";
15601560

1561+
#if NET
1562+
static NativeMethods()
1563+
{
1564+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1565+
{
1566+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1567+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1568+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1569+
}
1570+
}
1571+
#endif
1572+
15611573
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15621574
public static extern unsafe int sqlite3_close(IntPtr db);
15631575

src/SQLitePCLRaw.provider.e_sqlcipher/Generated/provider_e_sqlcipher_prenet5_notwin.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,18 @@ static class NativeMethods
15481548
{
15491549
private const string SQLITE_DLL = "e_sqlcipher";
15501550

1551+
#if NET
1552+
static NativeMethods()
1553+
{
1554+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1555+
{
1556+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1557+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1558+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1559+
}
1560+
}
1561+
#endif
1562+
15511563
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15521564
public static extern unsafe int sqlite3_close(IntPtr db);
15531565

src/SQLitePCLRaw.provider.e_sqlcipher/Generated/provider_e_sqlcipher_prenet5_win.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,18 @@ static class NativeMethods
15511551
{
15521552
private const string SQLITE_DLL = "e_sqlcipher";
15531553

1554+
#if NET
1555+
static NativeMethods()
1556+
{
1557+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1558+
{
1559+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1560+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1561+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1562+
}
1563+
}
1564+
#endif
1565+
15541566
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15551567
public static extern unsafe int sqlite3_close(IntPtr db);
15561568

src/SQLitePCLRaw.provider.e_sqlite3/Generated/provider_e_sqlite3_funcptrs_notwin.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,18 @@ static class NativeMethods
15431543
{
15441544
private const string SQLITE_DLL = "e_sqlite3";
15451545

1546+
#if NET
1547+
static NativeMethods()
1548+
{
1549+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1550+
{
1551+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1552+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1553+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1554+
}
1555+
}
1556+
#endif
1557+
15461558
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15471559
public static extern unsafe int sqlite3_close(IntPtr db);
15481560

src/SQLitePCLRaw.provider.e_sqlite3/Generated/provider_e_sqlite3_funcptrs_win.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,18 @@ static class NativeMethods
15461546
{
15471547
private const string SQLITE_DLL = "e_sqlite3";
15481548

1549+
#if NET
1550+
static NativeMethods()
1551+
{
1552+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1553+
{
1554+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1555+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1556+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1557+
}
1558+
}
1559+
#endif
1560+
15491561
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15501562
public static extern unsafe int sqlite3_close(IntPtr db);
15511563

src/SQLitePCLRaw.provider.e_sqlite3/Generated/provider_e_sqlite3_prenet5_notwin.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,18 @@ static class NativeMethods
15361536
{
15371537
private const string SQLITE_DLL = "e_sqlite3";
15381538

1539+
#if NET
1540+
static NativeMethods()
1541+
{
1542+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1543+
{
1544+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1545+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1546+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1547+
}
1548+
}
1549+
#endif
1550+
15391551
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15401552
public static extern unsafe int sqlite3_close(IntPtr db);
15411553

src/SQLitePCLRaw.provider.e_sqlite3/Generated/provider_e_sqlite3_prenet5_win.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,18 @@ static class NativeMethods
15391539
{
15401540
private const string SQLITE_DLL = "e_sqlite3";
15411541

1542+
#if NET
1543+
static NativeMethods()
1544+
{
1545+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1546+
{
1547+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1548+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1549+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1550+
}
1551+
}
1552+
#endif
1553+
15421554
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15431555
public static extern unsafe int sqlite3_close(IntPtr db);
15441556

src/SQLitePCLRaw.provider.e_sqlite3mc/Generated/provider_e_sqlite3mc_funcptrs_notwin.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,18 @@ static class NativeMethods
15551555
{
15561556
private const string SQLITE_DLL = "e_sqlite3mc";
15571557

1558+
#if NET
1559+
static NativeMethods()
1560+
{
1561+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1562+
{
1563+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1564+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1565+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1566+
}
1567+
}
1568+
#endif
1569+
15581570
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15591571
public static extern unsafe int sqlite3_close(IntPtr db);
15601572

src/SQLitePCLRaw.provider.e_sqlite3mc/Generated/provider_e_sqlite3mc_funcptrs_win.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,18 @@ static class NativeMethods
15581558
{
15591559
private const string SQLITE_DLL = "e_sqlite3mc";
15601560

1561+
#if NET
1562+
static NativeMethods()
1563+
{
1564+
if (AppContext.TryGetSwitch("SQLitePCL.LinkageType.Static", out bool isStatic) && isStatic)
1565+
{
1566+
nint selfHandle = NativeLibrary.GetMainProgramHandle();
1567+
NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly,
1568+
(string libraryName, Assembly asm, DllImportSearchPath? dllImportSearchPath) => selfHandle;
1569+
}
1570+
}
1571+
#endif
1572+
15611573
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
15621574
public static extern unsafe int sqlite3_close(IntPtr db);
15631575

0 commit comments

Comments
 (0)