Merge branch 'Tryibion-first-capital-letter-fix'

This commit is contained in:
Wojciech Figat
2023-01-13 12:21:33 +01:00
2 changed files with 13 additions and 4 deletions

View File

@@ -906,12 +906,21 @@ namespace FlaxEditor.Utilities
if (name.StartsWith("g_") || name.StartsWith("m_"))
startIndex = 2;
if (name.StartsWith("_"))
startIndex = 1;
// Filter text
var lastChar = '\0';
for (int i = startIndex; i < length; i++)
{
var c = name[i];
if (i == startIndex)
{
sb.Append(char.ToUpper(c));
continue;
}
// Space before word starting with uppercase letter
if (char.IsUpper(c) && i > 0)
{

View File

@@ -11,10 +11,10 @@ namespace FlaxEditor.Tests
[Test]
public void TestFormatting()
{
Assert.AreEqual("property", Utils.GetPropertyNameUI("property"));
Assert.AreEqual("property", Utils.GetPropertyNameUI("_property"));
Assert.AreEqual("property", Utils.GetPropertyNameUI("m_property"));
Assert.AreEqual("property", Utils.GetPropertyNameUI("g_property"));
Assert.AreEqual("Property", Utils.GetPropertyNameUI("property"));
Assert.AreEqual("Property", Utils.GetPropertyNameUI("_property"));
Assert.AreEqual("Property", Utils.GetPropertyNameUI("m_property"));
Assert.AreEqual("Property", Utils.GetPropertyNameUI("g_property"));
Assert.AreEqual("Property", Utils.GetPropertyNameUI("Property"));
Assert.AreEqual("Property 1", Utils.GetPropertyNameUI("Property1"));
Assert.AreEqual("Property Name", Utils.GetPropertyNameUI("PropertyName"));