Convert package name to PascalCase for C# namespace
Fixes issue 312.
This commit is contained in:
parent
9440a2abe3
commit
8482b6c462
@ -113,7 +113,7 @@ std::string GetFileNamespace(const FileDescriptor* descriptor) {
|
|||||||
if (descriptor->options().has_csharp_namespace()) {
|
if (descriptor->options().has_csharp_namespace()) {
|
||||||
return descriptor->options().csharp_namespace();
|
return descriptor->options().csharp_namespace();
|
||||||
}
|
}
|
||||||
return descriptor->package();
|
return UnderscoresToCamelCase(descriptor->package(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetUmbrellaClassNameInternal(const std::string& proto_file) {
|
std::string GetUmbrellaClassNameInternal(const std::string& proto_file) {
|
||||||
@ -154,7 +154,8 @@ std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) {
|
|||||||
|
|
||||||
// TODO(jtattermusch): can we reuse a utility function?
|
// TODO(jtattermusch): can we reuse a utility function?
|
||||||
std::string UnderscoresToCamelCase(const std::string& input,
|
std::string UnderscoresToCamelCase(const std::string& input,
|
||||||
bool cap_next_letter) {
|
bool cap_next_letter,
|
||||||
|
bool preserve_period) {
|
||||||
string result;
|
string result;
|
||||||
// Note: I distrust ctype.h due to locales.
|
// Note: I distrust ctype.h due to locales.
|
||||||
for (int i = 0; i < input.size(); i++) {
|
for (int i = 0; i < input.size(); i++) {
|
||||||
@ -180,6 +181,9 @@ std::string UnderscoresToCamelCase(const std::string& input,
|
|||||||
cap_next_letter = true;
|
cap_next_letter = true;
|
||||||
} else {
|
} else {
|
||||||
cap_next_letter = true;
|
cap_next_letter = true;
|
||||||
|
if (input[i] == '.' && preserve_period) {
|
||||||
|
result += '.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add a trailing "_" if the name should be altered.
|
// Add a trailing "_" if the name should be altered.
|
||||||
|
@ -88,7 +88,11 @@ std::string GetPropertyName(const FieldDescriptor* descriptor);
|
|||||||
|
|
||||||
int GetFixedSize(FieldDescriptor::Type type);
|
int GetFixedSize(FieldDescriptor::Type type);
|
||||||
|
|
||||||
std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter);
|
std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter, bool preserve_period);
|
||||||
|
|
||||||
|
inline std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter) {
|
||||||
|
return UnderscoresToCamelCase(input, cap_next_letter, false);
|
||||||
|
}
|
||||||
|
|
||||||
std::string UnderscoresToPascalCase(const std::string& input);
|
std::string UnderscoresToPascalCase(const std::string& input);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user