|
|
|
@ -43,24 +43,24 @@ |
|
|
|
|
#include <google/protobuf/compiler/csharp/csharp_helpers.h> |
|
|
|
|
#include <google/protobuf/compiler/csharp/csharp_message.h> |
|
|
|
|
#include <google/protobuf/compiler/csharp/csharp_names.h> |
|
|
|
|
#include <google/protobuf/compiler/csharp/csharp_umbrella_class.h> |
|
|
|
|
#include <google/protobuf/compiler/csharp/csharp_reflection_class.h> |
|
|
|
|
|
|
|
|
|
namespace google { |
|
|
|
|
namespace protobuf { |
|
|
|
|
namespace compiler { |
|
|
|
|
namespace csharp { |
|
|
|
|
|
|
|
|
|
UmbrellaClassGenerator::UmbrellaClassGenerator(const FileDescriptor* file) |
|
|
|
|
ReflectionClassGenerator::ReflectionClassGenerator(const FileDescriptor* file) |
|
|
|
|
: SourceGeneratorBase(file), |
|
|
|
|
file_(file) { |
|
|
|
|
namespace_ = GetFileNamespace(file); |
|
|
|
|
umbrellaClassname_ = GetUmbrellaClassUnqualifiedName(file); |
|
|
|
|
reflectionClassname_ = GetReflectionClassUnqualifiedName(file); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UmbrellaClassGenerator::~UmbrellaClassGenerator() { |
|
|
|
|
ReflectionClassGenerator::~ReflectionClassGenerator() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UmbrellaClassGenerator::Generate(io::Printer* printer) { |
|
|
|
|
void ReflectionClassGenerator::Generate(io::Printer* printer) { |
|
|
|
|
WriteIntroduction(printer); |
|
|
|
|
|
|
|
|
|
WriteDescriptor(printer); |
|
|
|
@ -100,7 +100,7 @@ void UmbrellaClassGenerator::Generate(io::Printer* printer) { |
|
|
|
|
printer->Print("#endregion Designer generated code\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { |
|
|
|
|
void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) { |
|
|
|
|
printer->Print( |
|
|
|
|
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n" |
|
|
|
|
"// source: $file_name$\n" |
|
|
|
@ -125,14 +125,14 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { |
|
|
|
|
"file_name", file_->name()); |
|
|
|
|
WriteGeneratedCodeAttributes(printer); |
|
|
|
|
printer->Print( |
|
|
|
|
"$access_level$ static partial class $umbrella_class_name$ {\n" |
|
|
|
|
"$access_level$ static partial class $reflection_class_name$ {\n" |
|
|
|
|
"\n", |
|
|
|
|
"access_level", class_access_level(), |
|
|
|
|
"umbrella_class_name", umbrellaClassname_); |
|
|
|
|
"reflection_class_name", reflectionClassname_); |
|
|
|
|
printer->Indent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { |
|
|
|
|
void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) { |
|
|
|
|
printer->Print( |
|
|
|
|
"#region Descriptor\n" |
|
|
|
|
"/// <summary>File descriptor for $file_name$</summary>\n" |
|
|
|
@ -141,9 +141,9 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { |
|
|
|
|
"}\n" |
|
|
|
|
"private static pbr::FileDescriptor descriptor;\n" |
|
|
|
|
"\n" |
|
|
|
|
"static $umbrella_class_name$() {\n", |
|
|
|
|
"static $reflection_class_name$() {\n", |
|
|
|
|
"file_name", file_->name(), |
|
|
|
|
"umbrella_class_name", umbrellaClassname_); |
|
|
|
|
"reflection_class_name", reflectionClassname_); |
|
|
|
|
printer->Indent(); |
|
|
|
|
printer->Print( |
|
|
|
|
"byte[] descriptorData = global::System.Convert.FromBase64String(\n"); |
|
|
|
@ -176,9 +176,9 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { |
|
|
|
|
printer->Print("pbr::FileDescriptor.DescriptorProtoFileDescriptor, "); |
|
|
|
|
} else { |
|
|
|
|
printer->Print( |
|
|
|
|
"$full_umbrella_class_name$.Descriptor, ", |
|
|
|
|
"full_umbrella_class_name", |
|
|
|
|
GetUmbrellaClassName(file_->dependency(i))); |
|
|
|
|
"$full_reflection_class_name$.Descriptor, ", |
|
|
|
|
"full_reflection_class_name", |
|
|
|
|
GetReflectionClassName(file_->dependency(i))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
printer->Print("},\n" |
|
|
|
@ -226,7 +226,7 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { |
|
|
|
|
// The "last" parameter indicates whether this message descriptor is the last one being printed in this immediate
|
|
|
|
|
// context. It governs whether or not a trailing comma and newline is written after the constructor, effectively
|
|
|
|
|
// just controlling the formatting in the generated code.
|
|
|
|
|
void UmbrellaClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last) { |
|
|
|
|
void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last) { |
|
|
|
|
if (IsMapEntryMessage(descriptor)) { |
|
|
|
|
printer->Print("null, "); |
|
|
|
|
return; |