Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ConductorSharp.Engine/Util/ExpressionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private static string GetMemberName(PropertyInfo propertyInfo)
memberName = propertyInfo.GetCustomAttribute<JsonPropertyAttribute>(true)?.PropertyName;

if (memberName == null)
memberName = SnakeCaseUtil.ToLowercasedPrefixSnakeCase(propertyInfo.Name);
memberName = SnakeCaseUtil.ToSnakeCase(propertyInfo.Name);

return memberName;
}
Expand Down
24 changes: 0 additions & 24 deletions src/ConductorSharp.Engine/Util/SnakeCaseUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ public static string ToCapitalizedPrefixSnakeCase(string str)
return string.Join("_", chunks);
}

public static string ToLowercasedPrefixSnakeCase(string str)
{
str = str.Replace("-", "");
var pattern = new Regex(@"[A-Z0-9_]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z][0-9]+|[A-Z]");
var prefixPattern = new Regex(@"[A-Z0-9]{2,}");

var matches = pattern.Matches(str);

var chunks = new List<string>();

for (var i = 0; i < matches.Count; i++)
{
if (i == 0 && prefixPattern.Match(matches[i].Value).Success)
{
chunks.Add(matches[i].Value.Replace("_", "").ToLower());
continue;
}
else
chunks.Add(matches[i].Value.ToLower());
}

return string.Join("_", chunks);
}

public static string ToSnakeCase(string str) =>
string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower();

Expand Down