From 4bc213ea1ea376aa49355b0cfae7bbeffd37625c Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:26:59 +0300 Subject: [PATCH 1/4] Initial commit with task details for issue #62 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/issues/62 --- 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..87d36f1 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Data/issues/62 +Your prepared branch: issue-62-1aaf4256 +Your prepared working directory: /tmp/gh-issue-solver-1757762816036 + +Proceed. \ No newline at end of file From f96a8b38927d273134fe0689d271b226e7f80d77 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:33:50 +0300 Subject: [PATCH 2/4] Fix indexing operators to properly validate negative indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add check for negative indices in Point indexer (index < 0) - Refactor LinkAddress indexer to use != 0 check for better readability - Both indexers now properly throw IndexOutOfRangeException for all invalid indices - Fixes issue #62: Bug in all indexing operators 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/Platform.Data/LinkAddress.cs | 7 ++----- csharp/Platform.Data/Point.cs | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/csharp/Platform.Data/LinkAddress.cs b/csharp/Platform.Data/LinkAddress.cs index 91c9d81..1657116 100644 --- a/csharp/Platform.Data/LinkAddress.cs +++ b/csharp/Platform.Data/LinkAddress.cs @@ -42,14 +42,11 @@ public TLinkAddress this[int index] [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - if (index == 0) - { - return Index; - } - else + if (index != 0) { throw new IndexOutOfRangeException(); } + return Index; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set => throw new NotSupportedException(); diff --git a/csharp/Platform.Data/Point.cs b/csharp/Platform.Data/Point.cs index b1ed34b..7183b87 100644 --- a/csharp/Platform.Data/Point.cs +++ b/csharp/Platform.Data/Point.cs @@ -57,14 +57,11 @@ public TLinkAddress this[int index] [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - if (index < Size) - { - return Index; - } - else + if (index < 0 || index >= Size) { throw new IndexOutOfRangeException(); } + return Index; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set => throw new NotSupportedException(); From 84723c3441cedb1b17ca9062db2beb8975df9184 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:34:32 +0300 Subject: [PATCH 3/4] 'Auto-commit changes made by Claude MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude ' --- examples/experiments/IndexerTest.cs | 101 ++++++++++++++++++++++++ examples/experiments/IndexerTest.csproj | 11 +++ 2 files changed, 112 insertions(+) create mode 100644 examples/experiments/IndexerTest.cs create mode 100644 examples/experiments/IndexerTest.csproj diff --git a/examples/experiments/IndexerTest.cs b/examples/experiments/IndexerTest.cs new file mode 100644 index 0000000..4bcf2d3 --- /dev/null +++ b/examples/experiments/IndexerTest.cs @@ -0,0 +1,101 @@ +using System; +using Platform.Data; + +namespace Platform.Data.Tests +{ + public class IndexerTest + { + public static void Main() + { + Console.WriteLine("Testing Point indexer..."); + var point = new Point(42UL, 3); + + // Test valid indices + try + { + for (int i = 0; i < 3; i++) + { + Console.WriteLine($"point[{i}] = {point[i]}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"Unexpected error with valid indices: {ex.Message}"); + } + + // Test negative index (should throw) + try + { + var result = point[-1]; + Console.WriteLine($"ERROR: Negative index should have thrown exception, but got: {result}"); + } + catch (IndexOutOfRangeException) + { + Console.WriteLine("✓ Negative index correctly throws IndexOutOfRangeException"); + } + catch (Exception ex) + { + Console.WriteLine($"ERROR: Unexpected exception type: {ex.GetType().Name}: {ex.Message}"); + } + + // Test out-of-bounds index (should throw) + try + { + var result = point[3]; + Console.WriteLine($"ERROR: Out-of-bounds index should have thrown exception, but got: {result}"); + } + catch (IndexOutOfRangeException) + { + Console.WriteLine("✓ Out-of-bounds index correctly throws IndexOutOfRangeException"); + } + catch (Exception ex) + { + Console.WriteLine($"ERROR: Unexpected exception type: {ex.GetType().Name}: {ex.Message}"); + } + + Console.WriteLine(); + Console.WriteLine("Testing LinkAddress indexer..."); + var linkAddress = new LinkAddress(123UL); + + // Test valid index (0) + try + { + Console.WriteLine($"linkAddress[0] = {linkAddress[0]}"); + } + catch (Exception ex) + { + Console.WriteLine($"Unexpected error with valid index 0: {ex.Message}"); + } + + // Test negative index (should throw) + try + { + var result = linkAddress[-1]; + Console.WriteLine($"ERROR: Negative index should have thrown exception, but got: {result}"); + } + catch (IndexOutOfRangeException) + { + Console.WriteLine("✓ Negative index correctly throws IndexOutOfRangeException"); + } + catch (Exception ex) + { + Console.WriteLine($"ERROR: Unexpected exception type: {ex.GetType().Name}: {ex.Message}"); + } + + // Test positive index other than 0 (should throw) + try + { + var result = linkAddress[1]; + Console.WriteLine($"ERROR: Index 1 should have thrown exception, but got: {result}"); + } + catch (IndexOutOfRangeException) + { + Console.WriteLine("✓ Index 1 correctly throws IndexOutOfRangeException"); + } + catch (Exception ex) + { + Console.WriteLine($"ERROR: Unexpected exception type: {ex.GetType().Name}: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/examples/experiments/IndexerTest.csproj b/examples/experiments/IndexerTest.csproj new file mode 100644 index 0000000..6cd6395 --- /dev/null +++ b/examples/experiments/IndexerTest.csproj @@ -0,0 +1,11 @@ + + + Exe + net8 + enable + + + + + + \ No newline at end of file From 44141c60bbe43b19ecca4b9811c93040e97a65ed Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:34:33 +0300 Subject: [PATCH 4/4] 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 87d36f1..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Data/issues/62 -Your prepared branch: issue-62-1aaf4256 -Your prepared working directory: /tmp/gh-issue-solver-1757762816036 - -Proceed. \ No newline at end of file