aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2016-07-27 10:46:00 +0100
committerJisi Liu <jisi.liu@gmail.com>2016-07-27 10:51:12 -0700
commit4e169bf0e57107d864c26960d5720d203e3768e8 (patch)
treeace095095816d9098cb265d56b64dd7ed08f216d /csharp/src/Google.Protobuf
parent86535a1ce7609bb5549d2b4f7e7aded0948e8d45 (diff)
downloadprotobuf-4e169bf0e57107d864c26960d5720d203e3768e8.tar.gz
protobuf-4e169bf0e57107d864c26960d5720d203e3768e8.tar.bz2
protobuf-4e169bf0e57107d864c26960d5720d203e3768e8.zip
Bring C#'s ToPascalCase method in line with C++.
(This still doesn't fix the conformance tests, but at least we're now consistent with the C++ code.)
Diffstat (limited to 'csharp/src/Google.Protobuf')
-rw-r--r--csharp/src/Google.Protobuf/JsonFormatter.cs12
1 files changed, 10 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index a894ffa1..d8a814d9 100644
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -274,7 +274,6 @@ namespace Google.Protobuf
}
// Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase
- // TODO: Use the new field in FieldDescriptor.
internal static string ToCamelCase(string input)
{
bool capitalizeNext = false;
@@ -305,6 +304,7 @@ namespace Google.Protobuf
(!wasCap || (i + 1 < input.Length && char.IsLower(input[i + 1]))))
{
firstWord = false;
+ result.Append(input[i]);
}
else
{
@@ -320,8 +320,16 @@ namespace Google.Protobuf
result.Append(char.ToUpperInvariant(input[i]));
continue;
}
+ else
+ {
+ result.Append(input[i]);
+ continue;
+ }
+ }
+ else
+ {
+ result.Append(char.ToLowerInvariant(input[i]));
}
- result.Append(input[i]);
}
return result.ToString();
}