Skip to content

Commit b56a6f2

Browse files
author
MPCoreDeveloper
committed
check in latest enhancements functional engine for 1.6.0 not fully tested with 1762 tests
1 parent db5fdc2 commit b56a6f2

File tree

19 files changed

+768
-62
lines changed

19 files changed

+768
-62
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,33 @@ All other benchmarks (25 total) remain stable. Full results: [`docs/BENCHMARK_RE
8585

8686
#### 🎯 Latest Release (v1.5.0 → v1.6.0)
8787

88-
- **🐛 Critical Bug Fixes**
89-
- Database reopen edge case fixed (graceful empty JSON handling)
90-
- Immediate metadata flush ensures durability
91-
- Enhanced error messages with JSON preview
92-
- Parameterized compiled query execution no longer risks hanging in the SQL lexer pipeline
93-
94-
- **📦 New Features**
88+
### New in v1.6.0 compared to v1.5.0
89+
90+
- **Functional package family introduced**
91+
- `SharpCoreDB.Functional` adds a functional façade over `Database` / `IDatabase`
92+
- `SharpCoreDB.Functional.Dapper` adds modular Dapper adapters with `Option<T>`, `Fin<Unit>`, and `Seq<T>`-based APIs
93+
- `SharpCoreDB.Functional.EntityFrameworkCore` adds modular EF Core adapters with the same functional programming model
94+
- All functional packages are designed as optional modules and keep production dependencies flowing through transitive NuGet references
95+
96+
- **Advanced graph analytics and GraphRAG package delivered**
97+
- New `SharpCoreDB.Graph.Advanced` package
98+
- Community detection, centrality metrics, subgraph analysis, graph-aware ranking, and profiling helpers
99+
100+
- **Event Sourcing / Projections / CQRS package maturity improvements**
101+
- Optional package guidance now clearly documents durable snapshots, projection checkpointing, persistent outbox workflows, retry handling, dead-letter support, and hosted background workers
102+
- These capabilities are now presented as first-class companion modules in the documentation and package ecosystem
103+
104+
- **Core engine and packaging improvements**
95105
- Synchronized `1.6.0` package versioning across the SharpCoreDB ecosystem
96-
- Refreshed package documentation for core, server, Event Sourcing, Projections, and CQRS
97-
- Persistent outbox, retry/dead-letter handling, hosted outbox worker, durable snapshots, and projection metrics documented as first-class optional capabilities
98-
- Brotli compression for JSON metadata (60-80% size reduction)
99-
- Backward compatible format detection
100-
- Zero breaking changes
106+
- Refreshed package documentation for the core engine and companion packages
107+
- Brotli compression for metadata with backward-compatible format detection
108+
- Immediate metadata flush and reopen-path fixes for improved durability and startup reliability
109+
- SQL lexer / parser fixes for parameterized compiled-query execution paths
110+
111+
- **Quality and validation**
112+
- New functional module tests added for core, Dapper, and EF Core adapters
113+
- Zero breaking changes intended from `1.5.0` to `1.6.0`
114+
- Workspace and targeted adapter test suites validate the new modules successfully
101115

102116
- **📊 Quality Metrics**
103117
- **1,490+ tests** (was 850+ in v1.3.5)
@@ -194,14 +208,10 @@ dotnet add package SharpCoreDB.Graph.Advanced --version 1.6.0
194208
dotnet add package SharpCoreDB.EntityFrameworkCore --version 1.6.0
195209
dotnet add package SharpCoreDB.Extensions --version 1.6.0
196210

197-
# Event Sourcing (optional package)
198-
dotnet add package SharpCoreDB.EventSourcing --version 1.6.0
199-
200-
# Projection engine primitives (optional package)
201-
dotnet add package SharpCoreDB.Projections --version 1.6.0
202-
203-
# CQRS primitives (optional package)
204-
dotnet add package SharpCoreDB.CQRS --version 1.6.0
211+
# Functional programming adapters (optional packages)
212+
dotnet add package SharpCoreDB.Functional --version 1.6.0
213+
dotnet add package SharpCoreDB.Functional.Dapper --version 1.6.0
214+
dotnet add package SharpCoreDB.Functional.EntityFrameworkCore --version 1.6.0
205215
```
206216

207217
---

src/SharpCoreDB.Functional.Dapper/FunctionalDapperDb.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace SharpCoreDB.Functional.Dapper;
22

3-
using LanguageExt;
4-
using LanguageExt.Common;
53
using SharpCoreDB.Extensions;
64
using SharpCoreDB.Interfaces;
7-
using static LanguageExt.Prelude;
5+
using static SharpCoreDB.Functional.Prelude;
86

97
/// <summary>
108
/// Functional adapter over SharpCoreDB Dapper extension operations with Option/Fin return types.

src/SharpCoreDB.Functional.Dapper/SharpCoreDB.Functional.Dapper.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<Authors>MPCoreDeveloper</Authors>
1212
<Company>SharpCoreDB</Company>
1313
<Product>SharpCoreDB.Functional.Dapper</Product>
14-
<Description>Dapper adapter for SharpCoreDB.Functional with LanguageExt Option/Fin APIs and fluent functional composition for .NET 10 and C# 14.</Description>
14+
<Description>Dapper adapter for SharpCoreDB.Functional with zero-dependency Option/Fin APIs and fluent functional composition for .NET 10 and C# 14.</Description>
1515
<Copyright>Copyright (c) 2026 MPCoreDeveloper</Copyright>
1616
<PackageReleaseNotes>v1.6.0: Initial modular Dapper adapter for the functional SharpCoreDB stack.</PackageReleaseNotes>
17-
<PackageTags>sharpcoredb;functional;dapper;languageext;option;fin;net10;csharp14</PackageTags>
17+
<PackageTags>sharpcoredb;functional;dapper;option;fin;net10;csharp14</PackageTags>
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1919
<PackageProjectUrl>https://github.com/MPCoreDeveloper/SharpCoreDB</PackageProjectUrl>
2020
<RepositoryUrl>https://github.com/MPCoreDeveloper/SharpCoreDB</RepositoryUrl>

src/SharpCoreDB.Functional.EntityFrameworkCore/FunctionalEfDb.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace SharpCoreDB.Functional.EntityFrameworkCore;
22

33
using System.Linq.Expressions;
4-
using LanguageExt;
5-
using LanguageExt.Common;
64
using Microsoft.EntityFrameworkCore;
7-
using static LanguageExt.Prelude;
5+
using static SharpCoreDB.Functional.Prelude;
86

97
/// <summary>
108
/// Functional adapter over EF Core operations with Option/Fin return types.

src/SharpCoreDB.Functional.EntityFrameworkCore/SharpCoreDB.Functional.EntityFrameworkCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<Authors>MPCoreDeveloper</Authors>
1212
<Company>SharpCoreDB</Company>
1313
<Product>SharpCoreDB.Functional.EntityFrameworkCore</Product>
14-
<Description>Entity Framework Core adapter for SharpCoreDB.Functional with LanguageExt Option/Fin APIs and fluent functional composition for .NET 10 and C# 14.</Description>
14+
<Description>Entity Framework Core adapter for SharpCoreDB.Functional with zero-dependency Option/Fin APIs and fluent functional composition for .NET 10 and C# 14.</Description>
1515
<Copyright>Copyright (c) 2026 MPCoreDeveloper</Copyright>
1616
<PackageReleaseNotes>v1.6.0: Initial modular EF Core adapter for the functional SharpCoreDB stack.</PackageReleaseNotes>
17-
<PackageTags>sharpcoredb;functional;entityframeworkcore;efcore;languageext;option;fin;net10;csharp14</PackageTags>
17+
<PackageTags>sharpcoredb;functional;entityframeworkcore;efcore;option;fin;net10;csharp14</PackageTags>
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1919
<PackageProjectUrl>https://github.com/MPCoreDeveloper/SharpCoreDB</PackageProjectUrl>
2020
<RepositoryUrl>https://github.com/MPCoreDeveloper/SharpCoreDB</RepositoryUrl>

src/SharpCoreDB.Functional/ErrorHandling.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
namespace SharpCoreDB.Functional;
22

3-
using LanguageExt;
4-
using LanguageExt.Common;
5-
using static LanguageExt.Prelude;
3+
using static SharpCoreDB.Functional.Prelude;
64

75
/// <summary>
86
/// Helpers for converting runtime errors into <see cref="Fin{A}"/> values.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace SharpCoreDB.Functional;
4+
5+
/// <summary>
6+
/// Represents an error with a human-readable message and an optional inner exception.
7+
/// </summary>
8+
public sealed class Error : IEquatable<Error>
9+
{
10+
/// <summary>
11+
/// Gets the error message.
12+
/// </summary>
13+
public string Message { get; }
14+
15+
/// <summary>
16+
/// Gets the optional inner exception that caused this error.
17+
/// </summary>
18+
public Exception? Exception { get; }
19+
20+
private Error(string message, Exception? exception = null)
21+
{
22+
Message = message;
23+
Exception = exception;
24+
}
25+
26+
/// <summary>
27+
/// Creates a new <see cref="Error"/> from a message string.
28+
/// </summary>
29+
/// <param name="message">The error message.</param>
30+
/// <returns>A new <see cref="Error"/> instance.</returns>
31+
public static Error New(string message) => new(message);
32+
33+
/// <summary>
34+
/// Creates a new <see cref="Error"/> from an exception, using its message.
35+
/// </summary>
36+
/// <param name="exception">The exception that caused the error.</param>
37+
/// <returns>A new <see cref="Error"/> instance.</returns>
38+
public static Error New(Exception exception)
39+
{
40+
ArgumentNullException.ThrowIfNull(exception);
41+
return new(exception.Message, exception);
42+
}
43+
44+
/// <summary>
45+
/// Creates a new <see cref="Error"/> from a message and an exception.
46+
/// </summary>
47+
/// <param name="message">The error message.</param>
48+
/// <param name="exception">The exception that caused the error.</param>
49+
/// <returns>A new <see cref="Error"/> instance.</returns>
50+
public static Error New(string message, Exception exception) => new(message, exception);
51+
52+
/// <inheritdoc />
53+
public bool Equals(Error? other) =>
54+
other is not null && Message == other.Message;
55+
56+
/// <inheritdoc />
57+
public override bool Equals(object? obj) => Equals(obj as Error);
58+
59+
/// <inheritdoc />
60+
public override int GetHashCode() => Message.GetHashCode(StringComparison.Ordinal);
61+
62+
/// <inheritdoc />
63+
public override string ToString() =>
64+
Exception is not null
65+
? $"{Message} ({Exception.GetType().Name})"
66+
: Message;
67+
68+
/// <summary>
69+
/// Implicit conversion from <see cref="string"/> to <see cref="Error"/>.
70+
/// </summary>
71+
[return: NotNull]
72+
public static implicit operator Error(string message) => New(message);
73+
74+
/// <summary>
75+
/// Implicit conversion from <see cref="System.Exception"/> to <see cref="Error"/>.
76+
/// </summary>
77+
[return: NotNull]
78+
public static implicit operator Error(Exception exception) => New(exception);
79+
}
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace SharpCoreDB.Functional;
4+
5+
/// <summary>
6+
/// Represents the result of an operation — either a success value or an <see cref="Error"/>.
7+
/// </summary>
8+
/// <typeparam name="T">The type of the success value.</typeparam>
9+
public readonly struct Fin<T> : IEquatable<Fin<T>>
10+
{
11+
private readonly T? _value;
12+
private readonly Error? _error;
13+
private readonly bool _isSucc;
14+
15+
private Fin(T value)
16+
{
17+
_value = value;
18+
_error = null;
19+
_isSucc = true;
20+
}
21+
22+
private Fin(Error error)
23+
{
24+
_value = default;
25+
_error = error;
26+
_isSucc = false;
27+
}
28+
29+
/// <summary>
30+
/// Creates a success result wrapping <paramref name="value"/>.
31+
/// </summary>
32+
/// <param name="value">The success value.</param>
33+
/// <returns>A successful <see cref="Fin{T}"/>.</returns>
34+
public static Fin<T> Succ(T value) => new(value);
35+
36+
/// <summary>
37+
/// Creates a failure result wrapping <paramref name="error"/>.
38+
/// </summary>
39+
/// <param name="error">The error.</param>
40+
/// <returns>A failed <see cref="Fin{T}"/>.</returns>
41+
public static Fin<T> Fail(Error error)
42+
{
43+
ArgumentNullException.ThrowIfNull(error);
44+
return new(error);
45+
}
46+
47+
/// <summary>
48+
/// Gets whether this result is a success.
49+
/// </summary>
50+
[MemberNotNullWhen(true, nameof(_value))]
51+
public bool IsSucc => _isSucc;
52+
53+
/// <summary>
54+
/// Gets whether this result is a failure.
55+
/// </summary>
56+
[MemberNotNullWhen(true, nameof(_error))]
57+
public bool IsFail => !_isSucc;
58+
59+
/// <summary>
60+
/// Pattern-matches on this result, returning a value from the appropriate branch.
61+
/// </summary>
62+
/// <typeparam name="TResult">The return type.</typeparam>
63+
/// <param name="Succ">Function invoked on success.</param>
64+
/// <param name="Fail">Function invoked on failure.</param>
65+
/// <returns>The result of the matched branch.</returns>
66+
public TResult Match<TResult>(Func<T, TResult> Succ, Func<Error, TResult> Fail) =>
67+
_isSucc ? Succ(_value!) : Fail(_error!);
68+
69+
/// <summary>
70+
/// Async pattern-match on this result.
71+
/// </summary>
72+
/// <typeparam name="TResult">The return type.</typeparam>
73+
/// <param name="Succ">Async function invoked on success.</param>
74+
/// <param name="Fail">Async function invoked on failure.</param>
75+
/// <returns>The result of the matched branch.</returns>
76+
public Task<TResult> Match<TResult>(Func<T, Task<TResult>> Succ, Func<Error, Task<TResult>> Fail) =>
77+
_isSucc ? Succ(_value!) : Fail(_error!);
78+
79+
/// <summary>
80+
/// Pattern-matches on this result, executing the appropriate action.
81+
/// </summary>
82+
/// <param name="Succ">Action invoked on success.</param>
83+
/// <param name="Fail">Action invoked on failure.</param>
84+
public void Match(Action<T> Succ, Action<Error> Fail)
85+
{
86+
if (_isSucc)
87+
Succ(_value!);
88+
else
89+
Fail(_error!);
90+
}
91+
92+
/// <summary>
93+
/// Transforms the success value using <paramref name="map"/>.
94+
/// Failures pass through unchanged.
95+
/// </summary>
96+
/// <typeparam name="TResult">The mapped type.</typeparam>
97+
/// <param name="map">The mapping function.</param>
98+
/// <returns>A new result with the mapped success value, or the original failure.</returns>
99+
public Fin<TResult> Map<TResult>(Func<T, TResult> map) =>
100+
_isSucc ? Fin<TResult>.Succ(map(_value!)) : Fin<TResult>.Fail(_error!);
101+
102+
/// <summary>
103+
/// Executes <paramref name="action"/> if this result is a success.
104+
/// </summary>
105+
/// <param name="action">The action to execute on the success value.</param>
106+
public void IfSucc(Action<T> action)
107+
{
108+
if (_isSucc)
109+
action(_value!);
110+
}
111+
112+
/// <summary>
113+
/// Executes <paramref name="action"/> if this result is a failure.
114+
/// </summary>
115+
/// <param name="action">The action to execute on the error.</param>
116+
public void IfFail(Action<Error> action)
117+
{
118+
if (!_isSucc)
119+
action(_error!);
120+
}
121+
122+
/// <summary>
123+
/// Flat-maps the success value using <paramref name="bind"/>.
124+
/// Failures pass through unchanged.
125+
/// </summary>
126+
/// <typeparam name="TResult">The bound type.</typeparam>
127+
/// <param name="bind">The binding function.</param>
128+
/// <returns>The result of the bind, or the original failure.</returns>
129+
public Fin<TResult> Bind<TResult>(Func<T, Fin<TResult>> bind) =>
130+
_isSucc ? bind(_value!) : Fin<TResult>.Fail(_error!);
131+
132+
/// <summary>
133+
/// Returns the success value or invokes <paramref name="handler"/> on the error.
134+
/// Prefer <see cref="Match{TResult}(Func{T, TResult}, Func{Error, TResult})"/> over this method.
135+
/// </summary>
136+
/// <param name="handler">Handler invoked when this result is a failure.</param>
137+
/// <returns>The success value or the handler result.</returns>
138+
public T IfFail(Func<Error, T> handler) =>
139+
_isSucc ? _value! : handler(_error!);
140+
141+
/// <summary>
142+
/// Implicit conversion from a value to a success result.
143+
/// </summary>
144+
public static implicit operator Fin<T>(T value) => Succ(value);
145+
146+
/// <summary>
147+
/// Implicit conversion from an <see cref="Error"/> to a failure result.
148+
/// </summary>
149+
public static implicit operator Fin<T>(Error error) => Fail(error);
150+
151+
/// <inheritdoc />
152+
public bool Equals(Fin<T> other) =>
153+
_isSucc == other._isSucc &&
154+
(_isSucc
155+
? EqualityComparer<T>.Default.Equals(_value, other._value)
156+
: EqualityComparer<Error>.Default.Equals(_error, other._error));
157+
158+
/// <inheritdoc />
159+
public override bool Equals(object? obj) => obj is Fin<T> other && Equals(other);
160+
161+
/// <inheritdoc />
162+
public override int GetHashCode() =>
163+
_isSucc
164+
? HashCode.Combine(true, _value)
165+
: HashCode.Combine(false, _error);
166+
167+
/// <summary>Equality operator.</summary>
168+
public static bool operator ==(Fin<T> left, Fin<T> right) => left.Equals(right);
169+
170+
/// <summary>Inequality operator.</summary>
171+
public static bool operator !=(Fin<T> left, Fin<T> right) => !left.Equals(right);
172+
173+
/// <inheritdoc />
174+
public override string ToString() =>
175+
_isSucc ? $"Succ({_value})" : $"Fail({_error})";
176+
}

0 commit comments

Comments
 (0)