Skip to content

Commit eec4de2

Browse files
committed
Missed library
1 parent 050935d commit eec4de2

18 files changed

Lines changed: 119 additions & 38 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@ jobs:
6060
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v') }}
6161
run: dotnet nuget push **\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGETAPIKEY }}
6262

63-
test-containers:
64-
runs-on: ubuntu-latest
65-
needs: build
66-
67-
steps:
68-
- name: Checkout
69-
uses: actions/checkout@v4
70-
with:
71-
fetch-depth: 0
72-
73-
- name: Setup .NET 10.0
74-
uses: actions/setup-dotnet@v4
75-
with:
76-
dotnet-version: '10.0.x'
77-
78-
- name: Build
79-
run: dotnet build tests/Shiny.DocumentDb.Tests/Shiny.DocumentDb.Tests.csproj --configuration Release
63+
# test-containers:
64+
# runs-on: ubuntu-latest
65+
# needs: build
66+
#
67+
# steps:
68+
# - name: Checkout
69+
# uses: actions/checkout@v4
70+
# with:
71+
# fetch-depth: 0
72+
#
73+
# - name: Setup .NET 10.0
74+
# uses: actions/setup-dotnet@v4
75+
# with:
76+
# dotnet-version: '10.0.x'
77+
#
78+
# - name: Build
79+
# run: dotnet build tests/Shiny.DocumentDb.Tests/Shiny.DocumentDb.Tests.csproj --configuration Release
8080

8181
# - name: Test (MySQL)
8282
# run: dotnet test tests/Shiny.DocumentDb.Tests/Shiny.DocumentDb.Tests.csproj --configuration Release --no-build --filter "FullyQualifiedName~MySql" --logger "trx;LogFileName=test-results-mysql.trx"

Directory.build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project>
22
<PropertyGroup>
3+
<BaseTargetFramework>net10.0</BaseTargetFramework>
34
<LangVersion>latest</LangVersion>
45
<Nullable>enable</Nullable>
56
<ImplicitUsings>enable</ImplicitUsings>
@@ -33,4 +34,11 @@
3334
<None Include="$(MSBuildThisFileDirectory)nuget.txt" Pack="true" PackagePath="readme.txt"/>
3435
<None Include="$(MSBuildThisFileDirectory)readme.md" Pack="true" PackagePath="\"/>
3536
</ItemGroup>
37+
38+
<ItemGroup>
39+
<PackageReference Include="Nerdbank.GitVersioning">
40+
<PrivateAssets>all</PrivateAssets>
41+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
42+
</PackageReference>
43+
</ItemGroup>
3644
</Project>

Directory.packages.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50"/>
67
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.3"/>
78
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3"/>
8-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50"/>
9+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.2"/>
10+
<PackageVersion Include="MySqlConnector" Version="2.4.0"/>
11+
<PackageVersion Include="Npgsql" Version="9.0.3"/>
12+
<PackageVersion Include="SystemTextJsonPatch" Version="4.2.0"/>
13+
</ItemGroup>
14+
<ItemGroup>
915
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8"/>
1016
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172"/>
1117
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0"/>
12-
<PackageVersion Include="SystemTextJsonPatch" Version="4.2.0"/>
1318
<PackageVersion Include="xunit.v3" Version="3.2.2"/>
1419
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5"/>
15-
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.2"/>
16-
<PackageVersion Include="MySqlConnector" Version="2.4.0"/>
17-
<PackageVersion Include="Npgsql" Version="9.0.3"/>
1820
<PackageVersion Include="Testcontainers.MsSql" Version="4.4.0"/>
1921
<PackageVersion Include="Testcontainers.MySql" Version="4.4.0"/>
2022
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.4.0"/>

DocumentDb.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Project Path="src/Shiny.DocumentDb/Shiny.DocumentDb.csproj" />
1818
<Project Path="src/Shiny.DocumentDb.Sqlite/Shiny.DocumentDb.Sqlite.csproj" />
1919
<Project Path="src/Shiny.DocumentDb.SqlServer/Shiny.DocumentDb.SqlServer.csproj" />
20+
<Project Path="src/Shiny.DocumentDb.Extensions.DependencyInjection/Shiny.DocumentDb.Extensions.DependencyInjection.csproj" />
2021
<Project Path="src/Shiny.DocumentDb.MySql/Shiny.DocumentDb.MySql.csproj" />
2122
<Project Path="src/Shiny.DocumentDb.PostgreSql/Shiny.DocumentDb.PostgreSql.csproj" />
2223
<Project Path="samples/Sample/Sample.csproj" />

benchmarks/Shiny.DocumentDb.Benchmarks/Shiny.DocumentDb.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>$(BaseTargetFramework)</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
77
<EnableAotAnalyzer>false</EnableAotAnalyzer>

build.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"path": "DocumentDb.slnx",
44
"projects": [
55
"src\\Shiny.DocumentDb\\Shiny.DocumentDb.csproj",
6+
"src\\Shiny.DocumentDb.Extensions.DependencyInjection\\Shiny.DocumentDb.Extensions.DependencyInjection.csproj",
67
"src\\Shiny.DocumentDb.Sqlite\\Shiny.DocumentDb.Sqlite.csproj",
78
"src\\Shiny.DocumentDb.SqlServer\\Shiny.DocumentDb.SqlServer.csproj",
89
"src\\Shiny.DocumentDb.MySql\\Shiny.DocumentDb.MySql.csproj",

readme.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![NuGet](https://img.shields.io/nuget/v/Shiny.DocumentDb.MySql.svg?label=MySQL)](https://www.nuget.org/packages/Shiny.DocumentDb.MySql/)
66
[![NuGet](https://img.shields.io/nuget/v/Shiny.DocumentDb.SqlServer.svg?label=SQL+Server)](https://www.nuget.org/packages/Shiny.DocumentDb.SqlServer/)
77
[![NuGet](https://img.shields.io/nuget/v/Shiny.DocumentDb.PostgreSql.svg?label=PostgreSQL)](https://www.nuget.org/packages/Shiny.DocumentDb.PostgreSql/)
8+
[![NuGet](https://img.shields.io/nuget/v/Shiny.DocumentDb.Extensions.DependencyInjection.svg?label=DI+Extensions)](https://www.nuget.org/packages/Shiny.DocumentDb.Extensions.DependencyInjection/)
89

910
A lightweight, multi-provider document store for .NET that turns relational databases into a schema-free JSON document database with LINQ querying and full AOT/trimming support. Supports **SQLite**, **MySQL**, **SQL Server**, and **PostgreSQL**.
1011

@@ -250,7 +251,12 @@ dotnet add package Shiny.DocumentDb.SqlServer
250251
dotnet add package Shiny.DocumentDb.PostgreSql
251252
```
252253

253-
Each provider package includes dependency injection extensions — no separate DI package needed.
254+
Each provider package includes dependency injection extensions. A standalone DI package is also available for provider-agnostic registration:
255+
256+
```bash
257+
# Generic DI extensions (bring your own provider)
258+
dotnet add package Shiny.DocumentDb.Extensions.DependencyInjection
259+
```
254260

255261
## Setup
256262

@@ -332,6 +338,22 @@ services.AddSqliteDocumentStore(opts =>
332338
});
333339
```
334340

341+
#### Generic (provider-agnostic) registration
342+
343+
If you want to register the document store without depending on a specific provider package, use the standalone DI extensions package:
344+
345+
```csharp
346+
using Shiny.DocumentDb;
347+
348+
services.AddDocumentStore(opts =>
349+
{
350+
opts.DatabaseProvider = new SqliteDatabaseProvider("Data Source=mydata.db");
351+
opts.TypeNameResolution = TypeNameResolution.FullName;
352+
});
353+
```
354+
355+
This is useful when the provider is determined at runtime or when building libraries that accept any `IDatabaseProvider`.
356+
335357
All DI methods register `IDocumentStore` as a singleton.
336358

337359
## Table-Per-Type Mapping

samples/Sample/Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>$(BaseTargetFramework)</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<EnableAotAnalyzer>false</EnableAotAnalyzer>
77
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>

skills/shiny-documentdb/SKILL.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ triggers:
3232
- document diff
3333
- BatchInsert
3434
- batch insert
35+
- AddDocumentStore
36+
- Shiny.DocumentDb.Extensions.DependencyInjection
3537
---
3638

3739
# Shiny DocumentDb Skill
@@ -70,6 +72,7 @@ Invoke this skill when the user wants to:
7072
- `Shiny.DocumentDb.MySql` — MySQL provider + DI extensions
7173
- `Shiny.DocumentDb.SqlServer` — SQL Server provider + DI extensions
7274
- `Shiny.DocumentDb.PostgreSql` — PostgreSQL provider + DI extensions
75+
- `Shiny.DocumentDb.Extensions.DependencyInjection` — generic (provider-agnostic) DI extensions
7376
- **Provider dependencies**:
7477
- SQLite: `Microsoft.Data.Sqlite`
7578
- MySQL: `MySqlConnector`
@@ -116,7 +119,7 @@ var store = new DocumentStore(new DocumentStoreOptions
116119
117120
### Dependency Injection
118121

119-
Each provider package includes its own DI extension method — no separate DI package needed.
122+
Each provider package includes its own DI extension method:
120123

121124
```csharp
122125
// SQLite
@@ -147,7 +150,21 @@ services.AddSqliteDocumentStore(opts =>
147150
});
148151
```
149152

150-
Registers `IDocumentStore` as a singleton.
153+
#### Generic (provider-agnostic) registration
154+
155+
Use `Shiny.DocumentDb.Extensions.DependencyInjection` when you want to register without depending on a specific provider package:
156+
157+
```csharp
158+
using Shiny.DocumentDb;
159+
160+
services.AddDocumentStore(opts =>
161+
{
162+
opts.DatabaseProvider = new SqliteDatabaseProvider("Data Source=mydata.db");
163+
opts.TypeNameResolution = TypeNameResolution.FullName;
164+
});
165+
```
166+
167+
All DI methods register `IDocumentStore` as a singleton.
151168

152169
### DocumentStoreOptions
153170

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
namespace Shiny.DocumentDb;
4+
5+
public static class ServiceCollectionExtensions
6+
{
7+
public static IServiceCollection AddDocumentStore(this IServiceCollection services, Action<DocumentStoreOptions> configure)
8+
{
9+
var options = new DocumentStoreOptions
10+
{
11+
DatabaseProvider = null!
12+
};
13+
configure(options);
14+
15+
if (options.DatabaseProvider == null)
16+
throw new ArgumentException("DatabaseProvider is null must be set.", nameof(configure));
17+
18+
services.AddSingleton(options);
19+
services.AddSingleton<IDocumentStore, DocumentStore>();
20+
return services;
21+
}
22+
}

0 commit comments

Comments
 (0)