Commit 2212f56b authored by Jon Skeet's avatar Jon Skeet

Added documentation to generated code.

There are now summaries for:
- The Types nested class (which holds nested types)
- The file descriptor class for each proto
- The enum generated for each oneof

(Also fixed two typos.)

Generated code in next commit.
parent 0e5686a7
...@@ -38,7 +38,7 @@ using System.IO; ...@@ -38,7 +38,7 @@ using System.IO;
namespace Google.Protobuf namespace Google.Protobuf
{ {
/// <summary> /// <summary>
/// Readings and decodes protocol message fields. /// Reads and decodes protocol message fields.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
......
...@@ -252,7 +252,7 @@ namespace Google.Protobuf.Reflection ...@@ -252,7 +252,7 @@ namespace Google.Protobuf.Reflection
{ {
if (fieldType != FieldType.Message) if (fieldType != FieldType.Message)
{ {
throw new InvalidOperationException("MessageType is only valid for enum fields."); throw new InvalidOperationException("MessageType is only valid for message fields.");
} }
return messageType; return messageType;
} }
......
...@@ -169,6 +169,7 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -169,6 +169,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
printer->Print( printer->Print(
vars, vars,
"private object $name$_;\n" "private object $name$_;\n"
"/// <summary>Enum of possibly cases for the \"$original_name$\" oneof.</summary>\n"
"public enum $property_name$OneofCase {\n"); "public enum $property_name$OneofCase {\n");
printer->Indent(); printer->Indent();
printer->Print("None = 0,\n"); printer->Print("None = 0,\n");
...@@ -202,7 +203,10 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -202,7 +203,10 @@ void MessageGenerator::Generate(io::Printer* printer) {
printer->Print("#region Nested types\n" printer->Print("#region Nested types\n"
"[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n");
WriteGeneratedCodeAttributes(printer); WriteGeneratedCodeAttributes(printer);
printer->Print("public static partial class Types {\n"); printer->Print(
vars,
"/// <summary>Container for nested types declared in the $class_name$ message type.</summary>\n"
"public static partial class Types {\n");
printer->Indent(); printer->Indent();
for (int i = 0; i < descriptor_->enum_type_count(); i++) { for (int i = 0; i < descriptor_->enum_type_count(); i++) {
EnumGenerator enumGenerator(descriptor_->enum_type(i)); EnumGenerator enumGenerator(descriptor_->enum_type(i));
......
...@@ -138,8 +138,10 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { ...@@ -138,8 +138,10 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) {
"[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n");
WriteGeneratedCodeAttributes(printer); WriteGeneratedCodeAttributes(printer);
printer->Print( printer->Print(
"/// <summary>Holder for reflection information generated from $file_name$</summary>\n"
"$access_level$ static partial class $umbrella_class_name$ {\n" "$access_level$ static partial class $umbrella_class_name$ {\n"
"\n", "\n",
"file_name", file_->name(),
"access_level", class_access_level(), "access_level", class_access_level(),
"umbrella_class_name", umbrellaClassname_); "umbrella_class_name", umbrellaClassname_);
printer->Indent(); printer->Indent();
...@@ -148,12 +150,14 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { ...@@ -148,12 +150,14 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) {
void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) {
printer->Print( printer->Print(
"#region Descriptor\n" "#region Descriptor\n"
"/// <summary>File descriptor for $file_name$</summary>\n"
"public static pbr::FileDescriptor Descriptor {\n" "public static pbr::FileDescriptor Descriptor {\n"
" get { return descriptor; }\n" " get { return descriptor; }\n"
"}\n" "}\n"
"private static pbr::FileDescriptor descriptor;\n" "private static pbr::FileDescriptor descriptor;\n"
"\n" "\n"
"static $umbrella_class_name$() {\n", "static $umbrella_class_name$() {\n",
"file_name", file_->name(),
"umbrella_class_name", umbrellaClassname_); "umbrella_class_name", umbrellaClassname_);
printer->Indent(); printer->Indent();
printer->Print( printer->Print(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment