From ee502a4cb8e24ee465003b753ab1dabf61b612f2 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:05:25 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #7 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Setters/issues/7 --- 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..025df78 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Setters/issues/7 +Your prepared branch: issue-7-21c2ebc3 +Your prepared working directory: /tmp/gh-issue-solver-1757819122277 + +Proceed. \ No newline at end of file From 99ab48417cefb21ec6c55a342ea726aaf8f1c301 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:12:15 +0300 Subject: [PATCH 2/3] Add WithConstant factory methods for single constant Setter creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements solution for issue #7 by adding static factory methods that allow creating Setter instances with a single constant value used for both true and false cases. Changes: - Added Setter.WithConstant(constantValue) method - Added Setter.WithConstant(constantValue, defaultValue) method - Added comprehensive tests for both factory methods - Added experiment demo showing real-world usage This addresses the use case where "in real life usage only one constant is actually used" and allows for simplified syntax like: var setter = Setter.WithConstant(links.Constants.Break); 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/Platform.Setters.Tests/SetterTests.cs | 26 ++++++++++++ .../Setter[TResult, TDecision].cs | 34 +++++++++++++++ experiments/SingleConstantSetterDemo.cs | 41 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 experiments/SingleConstantSetterDemo.cs diff --git a/csharp/Platform.Setters.Tests/SetterTests.cs b/csharp/Platform.Setters.Tests/SetterTests.cs index af0dc4c..0a142c7 100644 --- a/csharp/Platform.Setters.Tests/SetterTests.cs +++ b/csharp/Platform.Setters.Tests/SetterTests.cs @@ -45,5 +45,31 @@ public void MethodsWithIntegerReturnTypeTest() Assert.Equal(0, setter.SetFirstAndReturnFalse(new int[] { 4 })); Assert.Equal(4, setter.Result); } + + [Fact] + public void WithConstantFactoryMethodTest() + { + Setter setter = Setter.WithConstant(42); + Assert.Equal(42, setter.TrueValue); + Assert.Equal(42, setter.FalseValue); + Assert.Equal(default, setter.Result); + Assert.Equal(42, setter.SetAndReturnTrue(1)); + Assert.Equal(1, setter.Result); + Assert.Equal(42, setter.SetAndReturnFalse(2)); + Assert.Equal(2, setter.Result); + } + + [Fact] + public void WithConstantAndDefaultValueFactoryMethodTest() + { + Setter setter = Setter.WithConstant(42, 99); + Assert.Equal(42, setter.TrueValue); + Assert.Equal(42, setter.FalseValue); + Assert.Equal(99, setter.Result); + Assert.Equal(42, setter.SetAndReturnTrue(1)); + Assert.Equal(1, setter.Result); + Assert.Equal(42, setter.SetAndReturnFalse(2)); + Assert.Equal(2, setter.Result); + } } } diff --git a/csharp/Platform.Setters/Setter[TResult, TDecision].cs b/csharp/Platform.Setters/Setter[TResult, TDecision].cs index c766674..61bb435 100644 --- a/csharp/Platform.Setters/Setter[TResult, TDecision].cs +++ b/csharp/Platform.Setters/Setter[TResult, TDecision].cs @@ -87,6 +87,40 @@ public Setter(TResult defaultValue) : base(defaultValue) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Setter() { } + /// + /// Creates a new instance of the class using passed-in as both true and false values. + /// Создает новый экземпляр класса , используя переданное значение в качестве значения для истины и лжи. + /// + /// + /// A constant value that will be used for both true and false cases. + /// Константное значение, которое будет использоваться для случаев истины и лжи. + /// + /// + /// A new instance of the class with the same constant for both true and false values. + /// Новый экземпляр класса с одинаковой константой для значений истины и лжи. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Setter WithConstant(TDecision constantValue) => new(constantValue, constantValue); + + /// + /// Creates a new instance of the class using passed-in as both true and false values with the as a result. + /// Создает новый экземпляр класса , используя переданное значение в качестве значения для истины и лжи с в качестве результата. + /// + /// + /// A constant value that will be used for both true and false cases. + /// Константное значение, которое будет использоваться для случаев истины и лжи. + /// + /// + /// A default result value. + /// Результирующее значение по умолчанию. + /// + /// + /// A new instance of the class with the same constant for both true and false values and the specified default result value. + /// Новый экземпляр класса с одинаковой константой для значений истины и лжи и указанным значением результата по умолчанию. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Setter WithConstant(TDecision constantValue, TResult defaultValue) => new(constantValue, constantValue, defaultValue); + /// /// Sets the to the and returns the value indicating true. /// Устанавливает в и возвращает значение обозначающее истину. diff --git a/experiments/SingleConstantSetterDemo.cs b/experiments/SingleConstantSetterDemo.cs new file mode 100644 index 0000000..6040fa5 --- /dev/null +++ b/experiments/SingleConstantSetterDemo.cs @@ -0,0 +1,41 @@ +using System; +using Platform.Setters; + +namespace Platform.Setters.Experiments +{ + /// + /// Demo showing the usage of Setter with single constant as requested in issue #7. + /// This addresses the case where "in real life usage only one constant is actually used". + /// + class SingleConstantSetterDemo + { + static void Main() + { + // Example usage as requested in the issue: + // "var setter = new Setter(links.Constants.Break);" + + // Before: Required specifying both true/false values + Console.WriteLine("=== Before (traditional approach) ==="); + var traditionalSetter = new Setter(1, 0); // trueValue=1, falseValue=0 + Console.WriteLine($"TrueValue: {traditionalSetter.TrueValue}, FalseValue: {traditionalSetter.FalseValue}"); + + // After: Can use single constant for both true/false cases + Console.WriteLine("\n=== After (single constant approach) ==="); + uint constantBreak = 42; // Simulating links.Constants.Break + var singleConstantSetter = Setter.WithConstant(constantBreak); + Console.WriteLine($"TrueValue: {singleConstantSetter.TrueValue}, FalseValue: {singleConstantSetter.FalseValue}"); + + // Both methods return the same constant value + Console.WriteLine("\n=== Testing functionality ==="); + Console.WriteLine($"SetAndReturnTrue result: {singleConstantSetter.SetAndReturnTrue(100)}"); // Should return 42 + Console.WriteLine($"SetAndReturnFalse result: {singleConstantSetter.SetAndReturnFalse(200)}"); // Should return 42 + Console.WriteLine($"Final result value: {singleConstantSetter.Result}"); // Should be 200 + + // Can also specify default value + Console.WriteLine("\n=== With default value ==="); + var setterWithDefault = Setter.WithConstant(constantBreak, 999); + Console.WriteLine($"TrueValue: {setterWithDefault.TrueValue}, FalseValue: {setterWithDefault.FalseValue}"); + Console.WriteLine($"Initial result: {setterWithDefault.Result}"); // Should be 999 + } + } +} \ No newline at end of file From 1537cc2cb131ec423732d4bb88981d42a08eb9a8 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:14:05 +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 025df78..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Setters/issues/7 -Your prepared branch: issue-7-21c2ebc3 -Your prepared working directory: /tmp/gh-issue-solver-1757819122277 - -Proceed. \ No newline at end of file