Skip to content

Commit

Permalink
Do not directly use SQLitePCLRaw.bundle_green
Browse files Browse the repository at this point in the history
This has been preventing other .NET 5+ (non-ASP.NET Core) users from easily
depending on this package. We now use SQLitePCLRaw.core in this library and
require downstream users to supply the correct platform dependency.

ASP.NET Core users do not need to do anything since the web stack automatically
calls `SQLitePCL.Batteries_V2.Init()` for them.
  • Loading branch information
mqudsi committed Jun 29, 2023
1 parent f42614b commit e8e5282
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions SqliteCache.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ namespace NeoSmart.Caching.Sqlite.Tests
[TestClass]
public class BasicTests : IDisposable
{
[AssemblyInitialize]
public static void SetSqliteProvider(TestContext _)
{
// SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());
SQLitePCL.Batteries_V2.Init();
}

public static readonly Encoding DefaultEncoding = new UTF8Encoding(false);
private readonly SqliteCacheOptions Configuration = new SqliteCacheOptions()
{
Expand Down
2 changes: 1 addition & 1 deletion SqliteCache.Tests/SqliteCache.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="*" />
</ItemGroup>

<ItemGroup>
Expand All @@ -23,7 +24,6 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.3" />
<PackageReference Include="SQlitePCLRaw.bundle_e_sqlite3" PrivateAssets="All" Version="2.1.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion SqliteCache/SqliteCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class SqliteCache : IDistributedCache, IDisposable

static SqliteCache()
{
SQLitePCL.Batteries.Init();
// SQLitePCL.Batteries.Init();
}

public SqliteCache(IOptions<SqliteCacheOptions> options, ILogger<SqliteCache>? logger = null)
Expand Down
17 changes: 13 additions & 4 deletions SqliteCache/SqliteCache.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<AssemblyName>NeoSmart.Caching.Sqlite</AssemblyName>
<RootNamespace>NeoSmart.Caching.Sqlite</RootNamespace>
<Version>6.1.0</Version>
<Version>7.0.0-preview1</Version>
<Nullable>enable</Nullable>
<Authors>Mahmoud Al-Qudsi, neosmart, mqudsi</Authors>
<Company>NeoSmart Technologies</Company>
Expand All @@ -18,6 +18,14 @@
<RepositoryType>git</RepositoryType>
<PackageTags>idistributedcache, cache, sqlite, sqlitecache, distributed, aspnetcore, asp, core, performance</PackageTags>
<PackageReleaseNotes>
Version 7.0:
- SqliteCache no longer depends on SQLitePCLRaw.bundle_green.

ASP.NET users do not have to change anything, but other .NET Core users will need to install either
SQLitePCLRaw.bundle_green and call `SQLitePCL.Batteries.Init()` before instantiating SqliteCache,
or else install the correct SQLitePCLRaw.provider.xxx version that matches the target platform and call
`SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_whatever())` before using SqliteCache.

Version 6.1:
- Add methods to clear the cache (SqliteCache.Clear() and SqliteCache.ClearAsync())
- SQLitePCLRaw upgraded to 2.1.4
Expand Down Expand Up @@ -64,7 +72,8 @@ Version 3.1:
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.4" />
<!--<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.4" />-->
<PackageReference Include="SQLitePCLRaw.core" Version="2.1.4" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit e8e5282

Please sign in to comment.