Skip to content

Commit 582af43

Browse files
authored
[C#] fix: handle case when valueRef is with enum type prefix (#1092)
1 parent d0ae48a commit 582af43

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpGenerator.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,20 +2069,33 @@ private CharSequence generateEnumProperty(
20692069
if (fieldToken.isConstantEncoding())
20702070
{
20712071
final String constValue = fieldToken.encoding().constValue().toString();
2072+
2073+
// If constValue already contains the type prefix (e.g., "filterType.TrailingDelta"),
2074+
// extract just the enum value name
2075+
final String enumValue;
2076+
if (constValue.contains("."))
2077+
{
2078+
enumValue = constValue.substring(constValue.lastIndexOf('.') + 1);
2079+
}
2080+
else
2081+
{
2082+
enumValue = constValue;
2083+
}
20722084

20732085
return String.format("\n" +
20742086
"%1$s" +
20752087
indent + INDENT + "public %2$s %3$s\n" +
20762088
indent + INDENT + "{\n" +
20772089
indent + INDENT + INDENT + "get\n" +
20782090
indent + INDENT + INDENT + "{\n" +
2079-
indent + INDENT + INDENT + INDENT + "return %4$s;\n" +
2091+
indent + INDENT + INDENT + INDENT + "return %4$s.%5$s;\n" +
20802092
indent + INDENT + INDENT + "}\n" +
20812093
indent + INDENT + "}\n\n",
20822094
generateDocumentation(indent + INDENT, fieldToken),
20832095
enumName,
20842096
toUpperFirstChar(propertyName),
2085-
constValue);
2097+
enumName,
2098+
enumValue);
20862099
}
20872100
else
20882101
{

0 commit comments

Comments
 (0)