Read-only storage diagnostics toolkit for CSharpDB database and WAL files.
$ dotnet add package CSharpDB.Storage.DiagnosticsRead-only storage diagnostics and integrity checking toolkit for CSharpDB database files.
CSharpDB.Storage.Diagnostics provides read-only inspection and integrity verification for CSharpDB database files, WAL files, and indexes. Use it to validate database health, diagnose corruption, inspect page layouts, and verify index consistency. All operations are non-destructive and safe to run on production databases.
| Type | Description |
|---|---|
DatabaseInspector | Inspects database files: validates headers, walks B+trees, produces page-type histograms, and reports issues |
WalInspector | Validates WAL files: header checks, frame-by-frame validation (salt, checksums), commit marker detection |
IndexInspector | Verifies index integrity: root page validity, table/column existence, B+tree reachability |
DatabaseInspectReport | Report model with header info, page histogram, scanned pages, and issue list |
using CSharpDB.Storage.Diagnostics;
// Full database inspection
var report = await DatabaseInspector.InspectAsync("mydb.db");
Console.WriteLine($"Pages scanned: {report.PageCountScanned}");
Console.WriteLine($"Issues found: {report.Issues.Count}");
foreach (var issue in report.Issues)
{
Console.WriteLine($" [{issue.Severity}] {issue.Message}");
}
// Inspect a specific page
var page = await DatabaseInspector.InspectPageAsync("mydb.db", pageId: 3, includeHex: true);
// Validate WAL integrity
var walReport = await WalInspector.InspectAsync("mydb.db");
// Check for frame validation errors, salt mismatches, checksum failures
// Verify an index is consistent with its table
var indexReport = await IndexInspector.CheckAsync("mydb.db", "idx_users_email", sampleSize: 100);
dotnet add package CSharpDB.Storage.Diagnostics
CSharpDB.Core - shared type systemCSharpDB.Storage - storage engine types and page format definitions| Package | Description |
|---|---|
| CSharpDB.Storage | The storage engine this package inspects |
| CSharpDB.Service | Service layer that exposes diagnostics via API |
MIT - see LICENSE for details.