Skip to content

Commit ce3d5d5

Browse files
committed
Generate valid C# when a function is named "get<number>"
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent 8fca42a commit ce3d5d5

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/Generator/Passes/GetterSetterToPropertyPass.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ private static RawComment CombineComments(Declaration getter, Declaration setter
224224
private static string GetPropertyName(string name)
225225
{
226226
var firstWord = GetFirstWord(name);
227-
if (Match(firstWord, new[] { "get" }) && name != firstWord)
227+
if (Match(firstWord, new[] { "get" }) && name != firstWord &&
228+
!char.IsNumber(name[3]))
228229
{
229230
if (char.IsLower(name[0]))
230231
{

tests/Common/Common.Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ public void TestProperties()
503503

504504
Assert.That(prop.nestedEnum(), Is.EqualTo(5));
505505
Assert.That(prop.nestedEnum(55), Is.EqualTo(55));
506+
507+
Assert.That(prop.Get32Bit, Is.EqualTo(10));
506508
}
507509
}
508510

tests/Common/Common.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ int TestProperties::nestedEnum(int i)
596596
return i;
597597
}
598598

599+
int TestProperties::get32Bit()
600+
{
601+
return 10;
602+
}
603+
599604
HasOverridenSetter::HasOverridenSetter()
600605
{
601606
}

tests/Common/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ struct DLL_API TestProperties
609609

610610
int nestedEnum();
611611
int nestedEnum(int i);
612+
613+
int get32Bit();
612614
private:
613615
int FieldValue;
614616
double _refToPrimitiveInSetter;

0 commit comments

Comments
 (0)