Skip to content

Commit 588538f

Browse files
committed
Version 0.0.34. const char* allows null as C# string does, it also immutable like C# string, it should be a better translation for now.
1 parent a52cebe commit 588538f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Platform.RegularExpressions.Transformer.CSharpToCpp.Tests/CSharpToCppTransformerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void Main(string[] args)
1818
const string expectedResult = @"class Program
1919
{
2020
public:
21-
static void Main(char* args[])
21+
static void Main(const char* args[])
2222
{
2323
printf(""Hello, world!\n"");
2424
}

Platform.RegularExpressions.Transformer.CSharpToCpp/CSharpToCppTransformer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public class CSharpToCppTransformer : Transformer
132132
// void PrintNode(TElement node, StringBuilder sb, int level) override
133133
(new Regex(@"override ([a-zA-Z0-9 \*\+]+)(\([^\)\r\n]+?\))"), "$1$2 override", null, 0),
134134
// string
135-
// std::string
136-
(new Regex(@"(\W)string(\W)"), "$1std::string$2", null, 0),
135+
// const char*
136+
(new Regex(@"(\W)string(\W)"), "$1const char*$2", null, 0),
137137
// sbyte
138138
// std::int8_t
139139
(new Regex(@"(\W)sbyte(\W)"), "$1std::int8_t$2", null, 0),
@@ -204,8 +204,8 @@ public class CSharpToCppTransformer : Transformer
204204
// Assert::AreEqual
205205
(new Regex(@"Assert\.Equal"), "Assert::AreEqual", null, 0),
206206
// $"Argument {argumentName} is null."
207-
// ((std::string)"Argument ").append(argumentName).append(" is null.")
208-
(new Regex(@"\$""(?<left>(\\""|[^""\r\n])*){(?<expression>[_a-zA-Z0-9]+)}(?<right>(\\""|[^""\r\n])*)"""), "((std::string)$\"${left}\").append(${expression}).append(\"${right}\")", null, 10),
207+
// ((std::string)"Argument ").append(argumentName).append(" is null.").data()
208+
(new Regex(@"\$""(?<left>(\\""|[^""\r\n])*){(?<expression>[_a-zA-Z0-9]+)}(?<right>(\\""|[^""\r\n])*)"""), "((std::string)$\"${left}\").append(${expression}).append(\"${right}\").data()", null, 10),
209209
// $"
210210
// "
211211
(new Regex(@"\$"""), "\"", null, 0),

Platform.RegularExpressions.Transformer.CSharpToCpp/Platform.RegularExpressions.Transformer.CSharpToCpp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<IncludeSymbols>true</IncludeSymbols>
2525
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2626
<LangVersion>latest</LangVersion>
27-
<PackageReleaseNotes>std::string is closer by semantic to C# System.String than char*.</PackageReleaseNotes>
27+
<PackageReleaseNotes>const char* allows null as C# string does, it also immutable like C# string, it should be a better translation for now.</PackageReleaseNotes>
2828
</PropertyGroup>
2929

3030
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">

0 commit comments

Comments
 (0)