M1 Dati e libreria: modello, archivi SQLite con scrittore unico, nomi dei file, scrittura sicura, miniature, impronte, _febe.jsonl, copie, eliminazione e ricostruzione

Modello del dominio e interfacce degli archivi in Febe.Core; implementazione SQLite in Febe.Data (WAL, chiavi esterne, migrazioni numerate in transazione, coda di scrittura su un solo thread); logica della libreria in Febe.Core/Library; 164 prove MSTest, compresa la ricostruzione del database da una libreria di prova e la scala a 200.000 elementi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-13 16:06:15 +00:00
1 parent c803bd98b5
commit 3aeaa17da7
69 files changed
+12472

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
using System.Globalization;
using System.Text;
namespace Febe.Core.Library;
/// <summary>
/// Normalization for the search of the library (spec §4.6: account name and caption): lowercase, without accents,
/// with runs of white space collapsed. «Perché» and «perche» match.
/// </summary>
public static class TextSearch
{
public static string Normalize(string? text)
{
if (string.IsNullOrEmpty(text))
{
return string.Empty;
}
var decomposed = text.Normalize(NormalizationForm.FormD);
var builder = new StringBuilder(decomposed.Length);
var lastWasSpace = false;
foreach (var ch in decomposed)
{
var category = CharUnicodeInfo.GetUnicodeCategory(ch);
if (category is UnicodeCategory.NonSpacingMark or UnicodeCategory.SpacingCombiningMark or UnicodeCategory.EnclosingMark)
{
continue;
}
if (char.IsWhiteSpace(ch))
{
if (!lastWasSpace && builder.Length > 0)
{
builder.Append(' ');
}
lastWasSpace = true;
continue;
}
lastWasSpace = false;
builder.Append(char.ToLowerInvariant(ch));
}
return builder.ToString().TrimEnd().Normalize(NormalizationForm.FormC);
}
/// <summary>Text indexed for an entry: caption and author.</summary>
public static string ForEntry(string? caption, string? author) =>
Normalize(string.Join(' ', new[] { caption, author }.Where(s => !string.IsNullOrWhiteSpace(s))));
/// <summary>A LIKE pattern «%term%» with %, _ and \ escaped (use with ESCAPE '\').</summary>
public static string LikePattern(string normalizedTerm)
{
ArgumentNullException.ThrowIfNull(normalizedTerm);
var escaped = normalizedTerm.Replace("\\", "\\\\", StringComparison.Ordinal)
.Replace("%", "\\%", StringComparison.Ordinal)
.Replace("_", "\\_", StringComparison.Ordinal);
return "%" + escaped + "%";
}
}