From d90d615f716c6d2f0ede2b2ce23705d4c502ea45 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 12 Apr 2016 09:32:08 +0100 Subject: Attempt to fix AppVeyor build by exporting GetEnumValueName --- src/google/protobuf/compiler/csharp/csharp_helpers.cc | 5 +++++ src/google/protobuf/compiler/csharp/csharp_helpers.h | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index efd01556..6c154c5a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -260,6 +260,11 @@ std::string TryRemovePrefix(const std::string& prefix, const std::string& value) return value.substr(value_index); } +// Format the enum value name in a pleasant way for C#: +// - Strip the enum name as a prefix if possible +// - Convert to PascalCase. +// For example, an enum called Color with a value of COLOR_BLUE should +// result in an enum value in C# called just Blue std::string GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name) { std::string stripped = TryRemovePrefix(enum_name, enum_value_name); std::string result = ShoutyToPascalCase(stripped); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 8830e957..1563ca7e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -36,6 +36,7 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__ #include +#include #include #include #include @@ -93,7 +94,9 @@ inline std::string UnderscoresToCamelCase(const std::string& input, bool cap_nex std::string UnderscoresToPascalCase(const std::string& input); -std::string GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name); +// Note that we wouldn't normally want to export this (we're not expecting +// it to be used outside libprotoc itself) but this exposes it for testing. +std::string LIBPROTOBUF_EXPORT GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name); // TODO(jtattermusch): perhaps we could move this to strutil std::string StringToBase64(const std::string& input); -- cgit v1.2.3