From db6019efd14711a81381f02f1ac651945a2a6ae4 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 12:01:36 -0600
Subject: [PATCH 01/16] Rewritten the Symbol Transformation
Humanizer is also removed from project.
---
.../SymbolTransformation/SymbolTransformer.cs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
index 6cbace31..69f1d3f3 100644
--- a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
+++ b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
@@ -21,7 +21,6 @@
using System.Linq;
using System.Reflection;
using AdvancedDLSupport.Reflection;
-using Humanizer;
using JetBrains.Annotations;
using static AdvancedDLSupport.SymbolTransformationMethod;
@@ -121,23 +120,26 @@ private string Transform
}
case Pascalize:
{
- return concatenated.Pascalize();
+ return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(concatenated).Replace("_", string.Empty);
}
case Camelize:
{
- return concatenated.Camelize();
+ var camelized = new StringBuilder(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(concatenated));
+ camelized[0] = char.ToLower(camelized[0]);
+ camelized.Replace("_", string.Empty);
+ return camelized.ToString();
}
case Underscore:
{
- return concatenated.Underscore();
+ return concatenated.ToLower().Replace(" ", "_");
}
case Dasherize:
{
- return concatenated.Dasherize();
+ return concatenated.Replace("_", "-");
}
case Kebaberize:
{
- return concatenated.Kebaberize();
+ return concatenated.Replace(" ", "‐");
}
default:
{
From 0ed145e6958246d0b8824b7b3213634c784fea4f Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 12:02:25 -0600
Subject: [PATCH 02/16] Removal of Humanizer Dependency
All Test ran and verified to succeed!
---
AdvancedDLSupport/AdvancedDLSupport.csproj | 1 -
1 file changed, 1 deletion(-)
diff --git a/AdvancedDLSupport/AdvancedDLSupport.csproj b/AdvancedDLSupport/AdvancedDLSupport.csproj
index a38356ad..cdf03612 100644
--- a/AdvancedDLSupport/AdvancedDLSupport.csproj
+++ b/AdvancedDLSupport/AdvancedDLSupport.csproj
@@ -36,7 +36,6 @@
-
From 68175cd267e75f832485e6bc1926eecdc643f1df Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 12:05:27 -0600
Subject: [PATCH 03/16] Oops, wrong changes
Fixed the wrong changes with the correct changes.
---
.../SymbolTransformation/SymbolTransformer.cs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
index 69f1d3f3..ac210c19 100644
--- a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
+++ b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
@@ -131,7 +131,15 @@ private string Transform
}
case Underscore:
{
- return concatenated.ToLower().Replace(" ", "_");
+ var underscore = new StringBuilder(concatenated);
+ for (var i = 1; i < underscore.Length; ++i)
+ {
+ if (char.IsUpper(underscore[i]) && char.IsLower(underscore[i - 1]))
+ {
+ underscore.Insert(i, '_');
+ }
+ }
+ return underscore.Replace(" ", "_").ToString().ToLower();
}
case Dasherize:
{
From abb25d53cd1fda4e1f998a2ff2a61f37cb964ec2 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:43:28 -0600
Subject: [PATCH 04/16] Fixed up the implementation for tests
Removal of Humanizer Dependency code
---
.../SymbolTransformation/SymbolTransformer.cs | 67 ++++++++++++++++---
1 file changed, 56 insertions(+), 11 deletions(-)
diff --git a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
index ac210c19..8caadd5c 100644
--- a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
+++ b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
@@ -120,35 +120,80 @@ private string Transform
}
case Pascalize:
{
- return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(concatenated).Replace("_", string.Empty);
+ var pascalized = new StringBuilder(concatenated);
+ if (pascalized.Length > 1)
+ {
+ for (var i = 1; i < pascalized.Length; ++i)
+ {
+ var previousCharacter = pascalized[i - 1];
+ if (previousCharacter == '_' ||
+ previousCharacter == ' ' )
+ {
+ pascalized[i] = char.ToUpper(pascalized[i]);
+ }
+ }
+ }
+
+ pascalized[0] = char.ToUpper(pascalized[0]);
+ return pascalized.ToString();
}
case Camelize:
{
- var camelized = new StringBuilder(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(concatenated));
+ var camelized = new StringBuilder(concatenated);
+ if (camelized.Length > 1)
+ {
+ for (var i = 1; i < camelized.Length; ++i)
+ {
+ var previousCharacter = camelized[i - 1];
+ if (previousCharacter == '_' ||
+ previousCharacter == ' ' )
+ {
+ camelized[i] = char.ToUpper(camelized[i]);
+ }
+ }
+ }
+
camelized[0] = char.ToLower(camelized[0]);
- camelized.Replace("_", string.Empty);
return camelized.ToString();
}
case Underscore:
{
var underscore = new StringBuilder(concatenated);
- for (var i = 1; i < underscore.Length; ++i)
+ if (underscore.Length > 1)
{
- if (char.IsUpper(underscore[i]) && char.IsLower(underscore[i - 1]))
+ for (var i = 1; i < underscore.Length; ++i)
{
- underscore.Insert(i, '_');
+ var previousCharacter = underscore[i - 1];
+ char? nextCharacter = null;
+ if (underscore.Length > i + 1)
+ {
+ nextCharacter = underscore[i + 1];
+ }
+
+ // ReSharper disable once SA1028
+ if (nextCharacter.HasValue &&
+ char.IsUpper(previousCharacter) &&
+ char.IsUpper(underscore[i]) &&
+ char.IsLower(nextCharacter.Value))
+ {
+ underscore.Insert(i, "_");
+ }
+ else if (char.IsLower(previousCharacter) && char.IsUpper(underscore[i]))
+ {
+ underscore.Insert(i, "_");
+ }
}
}
- return underscore.Replace(" ", "_").ToString().ToLower();
+
+ underscore.Replace("-", "_");
+
+ return underscore.ToString().ToLower();
}
+ case Kebaberize:
case Dasherize:
{
return concatenated.Replace("_", "-");
}
- case Kebaberize:
- {
- return concatenated.Replace(" ", "‐");
- }
default:
{
throw new ArgumentOutOfRangeException(nameof(method), method, null);
From 2a1bda67b155db0ad87afa83ba6a75530224f00d Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:44:03 -0600
Subject: [PATCH 05/16] Update CMakeLists.txt
---
AdvancedDLSupport.Tests/c/CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/AdvancedDLSupport.Tests/c/CMakeLists.txt b/AdvancedDLSupport.Tests/c/CMakeLists.txt
index 78346d6c..60d95e35 100644
--- a/AdvancedDLSupport.Tests/c/CMakeLists.txt
+++ b/AdvancedDLSupport.Tests/c/CMakeLists.txt
@@ -39,6 +39,9 @@ list(
IndirectCallTests
NameManglingTests
SymbolTransformationTests
+ SymbolTransformationTests2
+ SymbolTransformationTests3
+ SymbolTransformationTests4
GenericDelegateTests
BooleanMarshallingTests
SpanMarshallingTests
From 159f4f805394d1d09476cd84ba8e7b3ea0e16a54 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:45:14 -0600
Subject: [PATCH 06/16] Create SymbolTransformationTests2.c
---
AdvancedDLSupport.Tests/c/src/SymbolTransformationTests2.c | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/c/src/SymbolTransformationTests2.c
diff --git a/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests2.c b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests2.c
new file mode 100644
index 00000000..73b24383
--- /dev/null
+++ b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests2.c
@@ -0,0 +1,7 @@
+#include
+#include "comp.h"
+
+__declspec(dllexport) int32_t AbCeD_CDEfDdaDfjc_ZDDdDdf_TestCode(int32_t a, int32_t b)
+{
+ return a * b;
+}
From 6ea870217466f4a195ad1f2d1e62252c1881232f Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:45:30 -0600
Subject: [PATCH 07/16] Create SymbolTransformationTests3.c
---
AdvancedDLSupport.Tests/c/src/SymbolTransformationTests3.c | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/c/src/SymbolTransformationTests3.c
diff --git a/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests3.c b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests3.c
new file mode 100644
index 00000000..bdcec307
--- /dev/null
+++ b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests3.c
@@ -0,0 +1,7 @@
+#include
+#include "comp.h"
+
+__declspec(dllexport) int32_t abCeD_CDEfDdaDfjc_ZDDdDdf_TestCode(int32_t a, int32_t b)
+{
+ return a * b;
+}
From a7c67e55ac926110173156d6a3f1c6974221a48c Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:45:46 -0600
Subject: [PATCH 08/16] Create SymbolTransformationTests4.c
---
AdvancedDLSupport.Tests/c/src/SymbolTransformationTests4.c | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/c/src/SymbolTransformationTests4.c
diff --git a/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests4.c b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests4.c
new file mode 100644
index 00000000..0acfb960
--- /dev/null
+++ b/AdvancedDLSupport.Tests/c/src/SymbolTransformationTests4.c
@@ -0,0 +1,7 @@
+#include
+#include "comp.h"
+
+__declspec(dllexport) int32_t ab_ce_d_cd_ef_dda_dfjc_zd_dd_ddf_test_code(int32_t a, int32_t b)
+{
+ return a * b;
+}
From b6538a41f7f881f02ef93e50641c1b18cbbd4993 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:46:21 -0600
Subject: [PATCH 09/16] Create ISymbolTransformationTests2.cs
---
.../Interfaces/ISymbolTransformationTests2.cs | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests2.cs
diff --git a/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests2.cs b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests2.cs
new file mode 100644
index 00000000..b138f018
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests2.cs
@@ -0,0 +1,31 @@
+//
+// ISymbolTransformationTests2.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using static AdvancedDLSupport.SymbolTransformationMethod;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Data
+{
+ [NativeSymbols(Prefix = "abCeD_cDEfDdaDfjc_zDDdDdf_", SymbolTransformationMethod = Pascalize)]
+ public interface ISymbolTransformationTests2
+ {
+ int TestCode(int a, int b);
+ }
+}
From d89f6cc014f5cd9275960276d348579b9bcab95e Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:46:37 -0600
Subject: [PATCH 10/16] Create ISymbolTransformationTests3.cs
---
.../Interfaces/ISymbolTransformationTests3.cs | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests3.cs
diff --git a/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests3.cs b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests3.cs
new file mode 100644
index 00000000..2a8082a4
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests3.cs
@@ -0,0 +1,31 @@
+//
+// ISymbolTransformationTests3.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using static AdvancedDLSupport.SymbolTransformationMethod;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Data
+{
+ [NativeSymbols(Prefix = "abCeD_cDEfDdaDfjc_zDDdDdf_", SymbolTransformationMethod = Camelize)]
+ public interface ISymbolTransformationTests3
+ {
+ int TestCode(int a, int b);
+ }
+}
From c9ad2f1e3ae84754c2c37ee9ab8fc3594dd4a0dc Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:46:48 -0600
Subject: [PATCH 11/16] Create ISymbolTransformationTests4.cs
---
.../Interfaces/ISymbolTransformationTests4.cs | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests4.cs
diff --git a/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests4.cs b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests4.cs
new file mode 100644
index 00000000..2c2efbd9
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Data/Interfaces/ISymbolTransformationTests4.cs
@@ -0,0 +1,31 @@
+//
+// ISymbolTransformationTests4.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using static AdvancedDLSupport.SymbolTransformationMethod;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Data
+{
+ [NativeSymbols(Prefix = "abCeD_CDEfDdaDfjc_ZDDdDdf", SymbolTransformationMethod = Underscore)]
+ public interface ISymbolTransformationTests4
+ {
+ int TestCode(int a, int b);
+ }
+}
From a6c1a6025e4e78e9111906c5cda4dd7e1228fd18 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:47:23 -0600
Subject: [PATCH 12/16] Create SymbolTransformationTests2.cs
---
.../Integration/SymbolTransformationTests2.cs | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests2.cs
diff --git a/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests2.cs b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests2.cs
new file mode 100644
index 00000000..18eded9b
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests2.cs
@@ -0,0 +1,46 @@
+//
+// SymbolTransformationTests2.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using AdvancedDLSupport.Tests.Data;
+using AdvancedDLSupport.Tests.TestBases;
+using Xunit;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Integration
+{
+ public class SymbolTransformationTests2 : LibraryTestBase
+ {
+ private const string LibraryName = "SymbolTransformationTests2";
+
+ public SymbolTransformationTests2()
+ : base(LibraryName)
+ {
+ }
+
+ [Fact]
+ public void CanPascalizeString()
+ {
+ var expected = 5 * 5;
+ var actual = Library.TestCode(5, 5);
+
+ Assert.Equal(expected, actual);
+ }
+ }
+}
From 00539522d99472bdffa9eb50288953b586dd1f75 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:47:40 -0600
Subject: [PATCH 13/16] Create SymbolTransformationTests3.cs
---
.../Integration/SymbolTransformationTests3.cs | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests3.cs
diff --git a/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests3.cs b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests3.cs
new file mode 100644
index 00000000..88e334df
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests3.cs
@@ -0,0 +1,46 @@
+//
+// SymbolTransformationTests3.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using AdvancedDLSupport.Tests.Data;
+using AdvancedDLSupport.Tests.TestBases;
+using Xunit;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Integration
+{
+ public class SymbolTransformationTests3 : LibraryTestBase
+ {
+ private const string LibraryName = "SymbolTransformationTests3";
+
+ public SymbolTransformationTests3()
+ : base(LibraryName)
+ {
+ }
+
+ [Fact]
+ public void CanCamelizeString()
+ {
+ var expected = 5 * 5;
+ var actual = Library.TestCode(5, 5);
+
+ Assert.Equal(expected, actual);
+ }
+ }
+}
From 913cc1d9d30e3586d6efcd20b93fb62611fb0081 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:47:55 -0600
Subject: [PATCH 14/16] Create SymbolTransformationTests4.cs
---
.../Integration/SymbolTransformationTests4.cs | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests4.cs
diff --git a/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests4.cs b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests4.cs
new file mode 100644
index 00000000..f7239a0d
--- /dev/null
+++ b/AdvancedDLSupport.Tests/Tests/Integration/SymbolTransformationTests4.cs
@@ -0,0 +1,46 @@
+//
+// SymbolTransformationTests4.cs
+//
+// Copyright (c) 2018 Firwood Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+
+using AdvancedDLSupport.Tests.Data;
+using AdvancedDLSupport.Tests.TestBases;
+using Xunit;
+
+#pragma warning disable SA1600, CS1591
+
+namespace AdvancedDLSupport.Tests.Integration
+{
+ public class SymbolTransformationTests4 : LibraryTestBase
+ {
+ private const string LibraryName = "SymbolTransformationTests4";
+
+ public SymbolTransformationTests4()
+ : base(LibraryName)
+ {
+ }
+
+ [Fact]
+ public void CanUnderscoreString()
+ {
+ var expected = 5 * 5;
+ var actual = Library.TestCode(5, 5);
+
+ Assert.Equal(expected, actual);
+ }
+ }
+}
From 7be46d0e6229e798473c9084d501535e7a1218b0 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Mon, 14 Oct 2019 13:50:03 -0600
Subject: [PATCH 15/16] Update SymbolTransformer.cs
---
AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
index 8caadd5c..450679ae 100644
--- a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
+++ b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
@@ -1,4 +1,4 @@
-//
+//
// SymbolTransformer.cs
//
// Copyright (c) 2018 Firwood Software
@@ -20,6 +20,7 @@
using System;
using System.Linq;
using System.Reflection;
+using System.Text;
using AdvancedDLSupport.Reflection;
using JetBrains.Annotations;
using static AdvancedDLSupport.SymbolTransformationMethod;
From b5351f6060b0b064d377626110f3fdbbbde1b462 Mon Sep 17 00:00:00 2001
From: QuickFixGuy <56558882+QuickFixGuy@users.noreply.github.com>
Date: Tue, 15 Oct 2019 00:28:57 -0600
Subject: [PATCH 16/16] Removed unneeded check for string length
---
.../SymbolTransformation/SymbolTransformer.cs | 65 ++++++++-----------
1 file changed, 28 insertions(+), 37 deletions(-)
diff --git a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
index 450679ae..0eb1b203 100644
--- a/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
+++ b/AdvancedDLSupport/SymbolTransformation/SymbolTransformer.cs
@@ -122,16 +122,13 @@ private string Transform
case Pascalize:
{
var pascalized = new StringBuilder(concatenated);
- if (pascalized.Length > 1)
+ for (var i = 1; i < pascalized.Length; ++i)
{
- for (var i = 1; i < pascalized.Length; ++i)
+ var previousCharacter = pascalized[i - 1];
+ if (previousCharacter == '_' ||
+ previousCharacter == ' ')
{
- var previousCharacter = pascalized[i - 1];
- if (previousCharacter == '_' ||
- previousCharacter == ' ' )
- {
- pascalized[i] = char.ToUpper(pascalized[i]);
- }
+ pascalized[i] = char.ToUpper(pascalized[i]);
}
}
@@ -141,16 +138,13 @@ private string Transform
case Camelize:
{
var camelized = new StringBuilder(concatenated);
- if (camelized.Length > 1)
+ for (var i = 1; i < camelized.Length; ++i)
{
- for (var i = 1; i < camelized.Length; ++i)
+ var previousCharacter = camelized[i - 1];
+ if (previousCharacter == '_' ||
+ previousCharacter == ' ')
{
- var previousCharacter = camelized[i - 1];
- if (previousCharacter == '_' ||
- previousCharacter == ' ' )
- {
- camelized[i] = char.ToUpper(camelized[i]);
- }
+ camelized[i] = char.ToUpper(camelized[i]);
}
}
@@ -160,29 +154,26 @@ private string Transform
case Underscore:
{
var underscore = new StringBuilder(concatenated);
- if (underscore.Length > 1)
+ for (var i = 1; i < underscore.Length; ++i)
{
- for (var i = 1; i < underscore.Length; ++i)
+ var previousCharacter = underscore[i - 1];
+ char? nextCharacter = null;
+ if (underscore.Length > i + 1)
{
- var previousCharacter = underscore[i - 1];
- char? nextCharacter = null;
- if (underscore.Length > i + 1)
- {
- nextCharacter = underscore[i + 1];
- }
-
- // ReSharper disable once SA1028
- if (nextCharacter.HasValue &&
- char.IsUpper(previousCharacter) &&
- char.IsUpper(underscore[i]) &&
- char.IsLower(nextCharacter.Value))
- {
- underscore.Insert(i, "_");
- }
- else if (char.IsLower(previousCharacter) && char.IsUpper(underscore[i]))
- {
- underscore.Insert(i, "_");
- }
+ nextCharacter = underscore[i + 1];
+ }
+
+ // ReSharper disable once SA1028
+ if (nextCharacter.HasValue &&
+ char.IsUpper(previousCharacter) &&
+ char.IsUpper(underscore[i]) &&
+ char.IsLower(nextCharacter.Value))
+ {
+ underscore.Insert(i, "_");
+ }
+ else if (char.IsLower(previousCharacter) && char.IsUpper(underscore[i]))
+ {
+ underscore.Insert(i, "_");
}
}