From 418518fcf1ad894128ac651ef858428bcdd49a67 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 05:12:34 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #150 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Data.Doublets/issues/150 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..e0b2ef603 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/150 +Your prepared branch: issue-150-8aba0d16 +Your prepared working directory: /tmp/gh-issue-solver-1757815892924 + +Proceed. \ No newline at end of file From 49ca44da58a8dd5508ecd88b01f34967a073bf35 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 05:19:58 +0300 Subject: [PATCH 2/3] Add PrintContents extension method for ILinks interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implemented PrintContents extension method with configurable Action output handler - Handles empty database case with appropriate message - Formats each link with proper alignment and zero-padding - Uses format: [linkIndex]: source -> target - Based on reference implementation from MasterServer.cs - Addresses issue #150 requirement for common interface instead of Console.WriteLine 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../ILinksExtensions.cs | 49 ++++++++++++++++++ experiments/TestPrintContents.cs | 49 ++++++++++++++++++ experiments/TestPrintContents.csproj | 13 +++++ experiments/test.db | Bin 0 -> 256 bytes 4 files changed, 111 insertions(+) create mode 100644 experiments/TestPrintContents.cs create mode 100644 experiments/TestPrintContents.csproj create mode 100644 experiments/test.db diff --git a/csharp/Platform.Data.Doublets/ILinksExtensions.cs b/csharp/Platform.Data.Doublets/ILinksExtensions.cs index a94c8f579..d696061ab 100644 --- a/csharp/Platform.Data.Doublets/ILinksExtensions.cs +++ b/csharp/Platform.Data.Doublets/ILinksExtensions.cs @@ -1599,5 +1599,54 @@ public static void ClearGarbage(this ILinks links, T } #endregion + + /// + /// + /// Prints the contents of the links database using the specified message handler. + /// + /// + /// + /// + /// The type of link address. + /// + /// + /// + /// The links. + /// + /// + /// + /// The message handler for outputting formatted messages. + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void PrintContents(this ILinks links, Action messageHandler) where TLinkAddress : IUnsignedNumber, IComparisonOperators + { + var count = links.Count(); + if (count == TLinkAddress.Zero) + { + messageHandler("Database is empty."); + } + else + { + messageHandler("Contents:"); + var linksTotalLength = count.ToString().Length; + var printFormatBase = new string('0', linksTotalLength); + var printFormat = $"\t[{{0:{printFormatBase}}}]: {{1:{printFormatBase}}} -> {{2:{printFormatBase}}}"; + + // Iterate through all existing links + var allLinks = links.All(); + for (var i = 0; i < allLinks.Count; i++) + { + var link = allLinks[i]; + if (link != null) + { + var linkIndex = links.GetIndex(link); + var source = links.GetSource(link); + var target = links.GetTarget(link); + messageHandler(string.Format(printFormat, linkIndex, source, target)); + } + } + } + } } } diff --git a/experiments/TestPrintContents.cs b/experiments/TestPrintContents.cs new file mode 100644 index 000000000..60d64bc65 --- /dev/null +++ b/experiments/TestPrintContents.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using Platform.Data.Doublets; +using Platform.Data.Doublets.Memory.United.Generic; + +namespace Platform.Data.Doublets.Experiments +{ + class TestPrintContents + { + static void Main() + { + Console.WriteLine("Testing PrintContents extension method..."); + + // Create a simple in-memory links storage + using var links = new UnitedMemoryLinks("test.db"); + + var messages = new List(); + void CaptureMessage(string message) => messages.Add(message); + + // Test with empty database + Console.WriteLine("1. Testing with empty database:"); + links.PrintContents(CaptureMessage); + foreach (var message in messages) + { + Console.WriteLine($"Output: {message}"); + } + Console.WriteLine(); + + // Clear messages and add some links + messages.Clear(); + + // Create some test links + var link1 = links.Create(); + var link2 = links.Create(); + var link3 = links.CreateAndUpdate(link1, link2); + + Console.WriteLine("2. Testing with some links:"); + Console.WriteLine($"Created links: {link1}, {link2}, {link3}"); + + links.PrintContents(CaptureMessage); + foreach (var message in messages) + { + Console.WriteLine($"Output: {message}"); + } + + Console.WriteLine("\nTest completed successfully!"); + } + } +} \ No newline at end of file diff --git a/experiments/TestPrintContents.csproj b/experiments/TestPrintContents.csproj new file mode 100644 index 000000000..9720a93b9 --- /dev/null +++ b/experiments/TestPrintContents.csproj @@ -0,0 +1,13 @@ + + + Exe + net8 + true + latest + enable + + + + + + \ No newline at end of file diff --git a/experiments/test.db b/experiments/test.db new file mode 100644 index 0000000000000000000000000000000000000000..40f7749f4684eb9259355a93883ad87fa30078ea GIT binary patch literal 256 mcmZQ(fPnx1`JpUSiW$m<(WtTm&trr-feD9GVDjkFFmV6{nF1UD literal 0 HcmV?d00001 From af7372ad4502eb576e393effb7562e4f986259a9 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 05:21:01 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index e0b2ef603..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/150 -Your prepared branch: issue-150-8aba0d16 -Your prepared working directory: /tmp/gh-issue-solver-1757815892924 - -Proceed. \ No newline at end of file