Skip to content

Commit 83f7cbe

Browse files
committed
'Auto-commit changes made by Claude
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>'
1 parent af55f8e commit 83f7cbe

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ public class CSharpToCppTransformer : TextTransformer
230230
// string
231231
// std::string
232232
(new Regex(@"(?<before>\W)(?<!::)string(?<after>\W)"), "${before}std::string${after}", 0),
233+
// Constructor(std::string param) { field = param; }
234+
// Constructor(std::string param) : field(std::move(param)) { }
235+
(new Regex(@"(?<access>(private|protected|public): )?(?<constructor>[a-zA-Z0-9_]+\((?<params>[^)]*std::string [a-zA-Z0-9_]+[^)]*)\))\s*{\s*(?<field>[a-zA-Z0-9_]+) = (?<param>[a-zA-Z0-9_]+);\s*}"), "${access}${constructor} : ${field}(std::move(${param})) { }", 0),
233236
// System.ValueTuple
234237
// std::tuple
235238
(new Regex(@"(?<before>\W)(System\.)?ValueTuple(?!\s*=|\()(?<after>\W)"), "${before}std::tuple${after}", 0),

examples/test_constructor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
class TestClass
4+
{
5+
private string field;
6+
7+
public TestClass(string stringParam)
8+
{
9+
field = stringParam;
10+
}
11+
}

examples/test_transform.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Platform.RegularExpressions.Transformer.CSharpToCpp;
2+
3+
var transformer = new CSharpToCppTransformer();
4+
var input = @"class TestClass
5+
{
6+
private string field;
7+
8+
public TestClass(string stringParam)
9+
{
10+
field = stringParam;
11+
}
12+
}";
13+
14+
Console.WriteLine("Input:");
15+
Console.WriteLine(input);
16+
Console.WriteLine("\nOutput:");
17+
var result = transformer.Transform(input);
18+
Console.WriteLine(result);

0 commit comments

Comments
 (0)