From a9a9a167b4c1d69b9cde41e366cb7e5955b6e8c8 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 16:51:29 +0300 Subject: [PATCH 1/4] Initial commit with task details for issue #22 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/link-foundation/link-cli/issues/22 --- 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 0000000..1b2c125 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/link-foundation/link-cli/issues/22 +Your prepared branch: issue-22-889744b4 +Your prepared working directory: /tmp/gh-issue-solver-1757512287537 + +Proceed. \ No newline at end of file From da1b7ddc9e3322b53c4b9f1db498caa3e252c838 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 16:51:45 +0300 Subject: [PATCH 2/4] Remove CLAUDE.md - PR created successfully --- 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 1b2c125..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/link-foundation/link-cli/issues/22 -Your prepared branch: issue-22-889744b4 -Your prepared working directory: /tmp/gh-issue-solver-1757512287537 - -Proceed. \ No newline at end of file From 971695a412ccbc7eacbb85025f31ce2faa577313 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 17:06:11 +0300 Subject: [PATCH 3/4] Add implementation of universal PinnedTypes decorator for ILinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created IPinnedTypes interface that extends IEnumerable with deconstruction support - Updated PinnedTypes class to implement IPinnedTypes interface - Added Deconstruct method to PinnedTypes for tuple-like destructuring - Implemented PinnedTypesDecorator that implements both ILinks and IPinnedTypes - Added comprehensive unit tests for the PinnedTypesDecorator functionality - Decorator follows existing patterns in the codebase (LinksDecoratorBase inheritance) Resolves issue #22: PinnedTypesDecorator provides universal access to both ILinks operations and IPinnedTypes functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../PinnedTypesDecoratorTests.cs | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Foundation.Data.Doublets.Cli.Tests/PinnedTypesDecoratorTests.cs diff --git a/Foundation.Data.Doublets.Cli.Tests/PinnedTypesDecoratorTests.cs b/Foundation.Data.Doublets.Cli.Tests/PinnedTypesDecoratorTests.cs new file mode 100644 index 0000000..7ed269f --- /dev/null +++ b/Foundation.Data.Doublets.Cli.Tests/PinnedTypesDecoratorTests.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Platform.Data; +using Platform.Data.Doublets; +using Platform.Data.Doublets.Memory.United.Generic; +using Platform.Delegates; +using Xunit; + +namespace Foundation.Data.Doublets.Cli.Tests +{ + public class PinnedTypesDecoratorTests + { + [Fact] + public void Should_Implement_Both_ILinks_And_IPinnedTypes() + { + // Arrange + var tempDbFile = Path.GetTempFileName(); + try + { + using var links = new UnitedMemoryLinks(tempDbFile); + + // Act + var decorator = new PinnedTypesDecorator(links); + + // Assert - Should implement both interfaces + Assert.IsAssignableFrom>(decorator); + Assert.IsAssignableFrom>(decorator); + } + finally + { + File.Delete(tempDbFile); + } + } + + [Fact] + public void Should_Enumerate_PinnedTypes() + { + // Arrange + var tempDbFile = Path.GetTempFileName(); + try + { + using var links = new UnitedMemoryLinks(tempDbFile); + var decorator = new PinnedTypesDecorator(links); + var numberOfTypes = 3; + + // Act + var result = new List(); + foreach (var type in decorator.Take(numberOfTypes)) + { + result.Add(type); + } + + // Assert + Assert.Equal(numberOfTypes, result.Count); + Assert.Equal(new ulong[] { 1, 2, 3 }, result); + } + finally + { + File.Delete(tempDbFile); + } + } + + [Fact] + public void Should_Support_Deconstruction() + { + // Arrange + var tempDbFile = Path.GetTempFileName(); + try + { + using var links = new UnitedMemoryLinks(tempDbFile); + var decorator = new PinnedTypesDecorator(links); + var initialSource = 1UL; + + // Pre-create links to ensure they exist + links.GetOrCreate(initialSource, 1UL); + links.GetOrCreate(initialSource, 2UL); + links.GetOrCreate(initialSource, 3UL); + + // Act + var (type1, type2, type3) = decorator; + + // Assert + Assert.Equal(1UL, type1); + Assert.Equal(2UL, type2); + Assert.Equal(3UL, type3); + } + finally + { + File.Delete(tempDbFile); + } + } + + [Fact] + public void Should_Work_As_ILinks_Decorator() + { + // Arrange + var tempDbFile = Path.GetTempFileName(); + try + { + using var baseLinks = new UnitedMemoryLinks(tempDbFile); + var decorator = new PinnedTypesDecorator(baseLinks); + + // Act & Assert - Test that it still works as a decorator and properly implements both interfaces + Assert.NotNull(decorator); + Assert.IsAssignableFrom>(decorator); + Assert.IsAssignableFrom>(decorator); + } + finally + { + File.Delete(tempDbFile); + } + } + } +} \ No newline at end of file From 986d46390b83cbb6b6cd1fce383a64bba6f631f6 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 17:06:26 +0300 Subject: [PATCH 4/4] Update PinnedTypes class and add PinnedTypesDecorator implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enhanced PinnedTypes to implement IPinnedTypes interface - Added PinnedTypesDecorator that extends LinksDecoratorBase and implements IPinnedTypes - Decorator provides seamless integration of pinned types functionality with ILinks operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- Foundation.Data.Doublets.Cli/PinnedTypes.cs | 22 +++++++++- .../PinnedTypesDecorator.cs | 43 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Foundation.Data.Doublets.Cli/PinnedTypesDecorator.cs diff --git a/Foundation.Data.Doublets.Cli/PinnedTypes.cs b/Foundation.Data.Doublets.Cli/PinnedTypes.cs index 591de18..f9e34cb 100644 --- a/Foundation.Data.Doublets.Cli/PinnedTypes.cs +++ b/Foundation.Data.Doublets.Cli/PinnedTypes.cs @@ -6,7 +6,13 @@ namespace Foundation.Data.Doublets.Cli { - public class PinnedTypes : IEnumerable + public interface IPinnedTypes : IEnumerable + where TLinkAddress : struct, System.Numerics.IUnsignedNumber + { + void Deconstruct(out TLinkAddress type1, out TLinkAddress type2, out TLinkAddress type3); + } + + public class PinnedTypes : IPinnedTypes where TLinkAddress : struct, System.Numerics.IUnsignedNumber { private readonly ILinks _links; @@ -83,5 +89,19 @@ public void Dispose() // No resources to dispose } } + + public void Deconstruct(out TLinkAddress type1, out TLinkAddress type2, out TLinkAddress type3) + { + using var enumerator = GetEnumerator(); + + enumerator.MoveNext(); + type1 = enumerator.Current; + + enumerator.MoveNext(); + type2 = enumerator.Current; + + enumerator.MoveNext(); + type3 = enumerator.Current; + } } } \ No newline at end of file diff --git a/Foundation.Data.Doublets.Cli/PinnedTypesDecorator.cs b/Foundation.Data.Doublets.Cli/PinnedTypesDecorator.cs new file mode 100644 index 0000000..07a3b12 --- /dev/null +++ b/Foundation.Data.Doublets.Cli/PinnedTypesDecorator.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Numerics; +using Platform.Data; +using Platform.Data.Doublets; +using Platform.Data.Doublets.Decorators; +using Platform.Delegates; + +namespace Foundation.Data.Doublets.Cli +{ + public class PinnedTypesDecorator : LinksDecoratorBase, IPinnedTypes + where TLinkAddress : struct, + IUnsignedNumber, + IComparisonOperators, + IShiftOperators, + IBitwiseOperators, + IMinMaxValue + { + private readonly IPinnedTypes _pinnedTypes; + + public PinnedTypesDecorator(ILinks links) : base(links) + { + _pinnedTypes = new PinnedTypes(links); + } + + // Implement IPinnedTypes interface + public IEnumerator GetEnumerator() + { + return _pinnedTypes.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Deconstruct(out TLinkAddress type1, out TLinkAddress type2, out TLinkAddress type3) + { + _pinnedTypes.Deconstruct(out type1, out type2, out type3); + } + } +} \ No newline at end of file