From bc810a512a44dcbd0186b9357665af25c099d261 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 16:32:57 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #56 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/RegularExpressions.Transformer.CSharpToCpp/issues/56 --- 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..9792ce5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/RegularExpressions.Transformer.CSharpToCpp/issues/56 +Your prepared branch: issue-56-0f206a16 +Your prepared working directory: /tmp/gh-issue-solver-1757770374356 + +Proceed. \ No newline at end of file From cbcb6df368bbf78c87cf14e071a5ee396461ed6f Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 16:37:56 +0300 Subject: [PATCH 2/3] Fix readonly to const transformation for string types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated regex pattern on line 127 to include 'const' in the replacement string - This ensures that both 'readonly' and 'const' C# keywords are converted to 'const' in C++ - Added test cases in experiments/ folder to verify the transformation works correctly - All existing tests continue to pass Resolves issue #56 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../CSharpToCppTransformer.cs | 2 +- experiments/Program.cs | 34 +++++++++++++++++++ experiments/TestTransformations.csproj | 9 +++++ experiments/readonly_test.cs | 15 ++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 experiments/Program.cs create mode 100644 experiments/TestTransformations.csproj create mode 100644 experiments/readonly_test.cs diff --git a/csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs b/csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs index 2f5dceb..9445b86 100644 --- a/csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs +++ b/csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs @@ -124,7 +124,7 @@ public class CSharpToCppTransformer : TextTransformer (new Regex(@"(?(private|protected|public): )?static readonly (?[a-zA-Z0-9]+(<[a-zA-Z0-9]+>)?) (?[a-zA-Z0-9_]+) = new \k\((?[^\n]+)\);"), "${access}inline static ${type} ${name} = ${type}(${arguments});", 0), // public: static readonly string ExceptionContentsSeparator = "---"; // public: inline static std::string ExceptionContentsSeparator = "---"; - (new Regex(@"(?(private|protected|public): )?(const|static readonly) string (?[a-zA-Z0-9_]+) = ""(?(\\""|[^""\r\n])+)"";"), "${access}inline static std::string ${name} = \"${string}\";", 0), + (new Regex(@"(?(private|protected|public): )?(const|static readonly) string (?[a-zA-Z0-9_]+) = ""(?(\\""|[^""\r\n])+)"";"), "${access}inline static const std::string ${name} = \"${string}\";", 0), // private: const int MaxPath = 92; // private: inline static const int MaxPath = 92; (new Regex(@"(?(private|protected|public): )?(const|static readonly) (?[a-zA-Z0-9]+) (?[_a-zA-Z0-9]+) = (?[^;\r\n]+);"), "${access}inline static const ${type} ${name} = ${value};", 0), diff --git a/experiments/Program.cs b/experiments/Program.cs new file mode 100644 index 0000000..edc0ef5 --- /dev/null +++ b/experiments/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using Platform.RegularExpressions.Transformer.CSharpToCpp; + +class Program +{ + static void Main() + { + string inputCode = @"// Test cases for readonly transformations +public class TestClass +{ + // Test string readonly + public static readonly string ExceptionContentsSeparator = ""---""; + private static readonly string PrivateMessage = ""error""; + + // Test other types readonly + public static readonly int MaxPath = 92; + private static readonly bool IsEnabled = true; + + // Test const (should already work) + private const int ConstValue = 42; + public const string ConstString = ""test""; +}"; + + Console.WriteLine("Original code:"); + Console.WriteLine(inputCode); + Console.WriteLine("\n" + new string('=', 50) + "\n"); + + var transformer = new CSharpToCppTransformer(); + string transformed = transformer.Transform(inputCode); + Console.WriteLine("Transformed code:"); + Console.WriteLine(transformed); + } +} \ No newline at end of file diff --git a/experiments/TestTransformations.csproj b/experiments/TestTransformations.csproj new file mode 100644 index 0000000..8738f19 --- /dev/null +++ b/experiments/TestTransformations.csproj @@ -0,0 +1,9 @@ + + + Exe + net8 + + + + + \ No newline at end of file diff --git a/experiments/readonly_test.cs b/experiments/readonly_test.cs new file mode 100644 index 0000000..466d331 --- /dev/null +++ b/experiments/readonly_test.cs @@ -0,0 +1,15 @@ +// Test cases for readonly transformations +public class TestClass +{ + // Test string readonly + public static readonly string ExceptionContentsSeparator = "---"; + private static readonly string PrivateMessage = "error"; + + // Test other types readonly + public static readonly int MaxPath = 92; + private static readonly bool IsEnabled = true; + + // Test const (should already work) + private const int ConstValue = 42; + public const string ConstString = "test"; +} \ No newline at end of file From f0976b2c81fc2e2cbc5113f7e22b7647965cde03 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 16:38:24 +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 9792ce5..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/RegularExpressions.Transformer.CSharpToCpp/issues/56 -Your prepared branch: issue-56-0f206a16 -Your prepared working directory: /tmp/gh-issue-solver-1757770374356 - -Proceed. \ No newline at end of file