From 2212f56bcdfd5d830a18a3c4aaecb0a6ad564e54 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 29 Sep 2015 13:37:15 +0100 Subject: 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. --- src/google/protobuf/compiler/csharp/csharp_message.cc | 6 +++++- src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index a71a7909..a2c4fe57 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -169,6 +169,7 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print( vars, "private object $name$_;\n" + "/// Enum of possibly cases for the \"$original_name$\" oneof.\n" "public enum $property_name$OneofCase {\n"); printer->Indent(); printer->Print("None = 0,\n"); @@ -202,7 +203,10 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print("#region Nested types\n" "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); WriteGeneratedCodeAttributes(printer); - printer->Print("public static partial class Types {\n"); + printer->Print( + vars, + "/// Container for nested types declared in the $class_name$ message type.\n" + "public static partial class Types {\n"); printer->Indent(); for (int i = 0; i < descriptor_->enum_type_count(); i++) { EnumGenerator enumGenerator(descriptor_->enum_type(i)); diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index 4b347708..b7328f9a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -138,8 +138,10 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); WriteGeneratedCodeAttributes(printer); printer->Print( + "/// Holder for reflection information generated from $file_name$\n" "$access_level$ static partial class $umbrella_class_name$ {\n" "\n", + "file_name", file_->name(), "access_level", class_access_level(), "umbrella_class_name", umbrellaClassname_); printer->Indent(); @@ -148,12 +150,14 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print( "#region Descriptor\n" + "/// File descriptor for $file_name$\n" "public static pbr::FileDescriptor Descriptor {\n" " get { return descriptor; }\n" "}\n" "private static pbr::FileDescriptor descriptor;\n" "\n" "static $umbrella_class_name$() {\n", + "file_name", file_->name(), "umbrella_class_name", umbrellaClassname_); printer->Indent(); printer->Print( -- cgit v1.2.3 From 1351d20c3165b1d3f5b40172c3ec7fed4ef21fc5 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 29 Sep 2015 14:34:05 +0100 Subject: Move the summary comments above the attributes. (Generated code changes coming next...) --- src/google/protobuf/compiler/csharp/csharp_message.cc | 12 ++++++------ src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index a2c4fe57..4510d0b6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -200,13 +200,13 @@ void MessageGenerator::Generate(io::Printer* printer) { // Nested messages and enums if (HasNestedGeneratedTypes()) { - printer->Print("#region Nested types\n" - "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); - WriteGeneratedCodeAttributes(printer); printer->Print( - vars, - "/// Container for nested types declared in the $class_name$ message type.\n" - "public static partial class Types {\n"); + vars, + "#region Nested types\n" + "/// Container for nested types declared in the $class_name$ message type.\n" + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); + WriteGeneratedCodeAttributes(printer); + printer->Print("public static partial class Types {\n"); printer->Indent(); for (int i = 0; i < descriptor_->enum_type_count(); i++) { EnumGenerator enumGenerator(descriptor_->enum_type(i)); diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index b7328f9a..7cf101b0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -135,13 +135,13 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { } printer->Print( - "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); + "/// Holder for reflection information generated from $file_name$\n" + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n", + "file_name", file_->name()); WriteGeneratedCodeAttributes(printer); printer->Print( - "/// Holder for reflection information generated from $file_name$\n" "$access_level$ static partial class $umbrella_class_name$ {\n" "\n", - "file_name", file_->name(), "access_level", class_access_level(), "umbrella_class_name", umbrellaClassname_); printer->Indent(); -- cgit v1.2.3 From 6bbbdfa24c51c9aae1c58f25c84ad9759f05eab9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 30 Sep 2015 06:59:38 +0100 Subject: Fix typo in oneof case enum comment --- csharp/src/Google.Protobuf.Conformance/Conformance.cs | 6 +++--- csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs | 4 ++-- csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs | 4 ++-- .../src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs | 2 +- csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs | 2 +- src/google/protobuf/compiler/csharp/csharp_message.cc | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs index d13c6d62..f05d03b2 100644 --- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -227,7 +227,7 @@ namespace Conformance { } private object payload_; - /// Enum of possibly cases for the "payload" oneof. + /// Enum of possible cases for the "payload" oneof. public enum PayloadOneofCase { None = 0, ProtobufPayload = 1, @@ -434,7 +434,7 @@ namespace Conformance { } private object result_; - /// Enum of possibly cases for the "result" oneof. + /// Enum of possible cases for the "result" oneof. public enum ResultOneofCase { None = 0, ParseError = 1, @@ -1244,7 +1244,7 @@ namespace Conformance { } private object oneofField_; - /// Enum of possibly cases for the "oneof_field" oneof. + /// Enum of possible cases for the "oneof_field" oneof. public enum OneofFieldOneofCase { None = 0, OneofUint32 = 111, diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs index c44f90b1..6c1a594f 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs @@ -1170,7 +1170,7 @@ namespace UnitTest.Issues.TestProtos { } private object o1_; - /// Enum of possibly cases for the "o1" oneof. + /// Enum of possible cases for the "o1" oneof. public enum O1OneofCase { None = 0, O1String = 2, @@ -1187,7 +1187,7 @@ namespace UnitTest.Issues.TestProtos { } private object o2_; - /// Enum of possibly cases for the "o2" oneof. + /// Enum of possible cases for the "o2" oneof. public enum O2OneofCase { None = 0, O2Int32 = 6, diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs index ccafafc0..f7ad620c 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -717,7 +717,7 @@ namespace Google.Protobuf.TestProtos { } private object oneofField_; - /// Enum of possibly cases for the "oneof_field" oneof. + /// Enum of possible cases for the "oneof_field" oneof. public enum OneofFieldOneofCase { None = 0, OneofUint32 = 111, @@ -4274,7 +4274,7 @@ namespace Google.Protobuf.TestProtos { } private object foo_; - /// Enum of possibly cases for the "foo" oneof. + /// Enum of possible cases for the "foo" oneof. public enum FooOneofCase { None = 0, FooInt = 1, diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs index 9b7e1704..126bc265 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -1470,7 +1470,7 @@ namespace Google.Protobuf.TestProtos { } private object oneofField_; - /// Enum of possibly cases for the "oneof_field" oneof. + /// Enum of possible cases for the "oneof_field" oneof. public enum OneofFieldOneofCase { None = 0, AnyField = 1, diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index 30a1569b..257d52d8 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -255,7 +255,7 @@ namespace Google.Protobuf.WellKnownTypes { } private object kind_; - /// Enum of possibly cases for the "kind" oneof. + /// Enum of possible cases for the "kind" oneof. public enum KindOneofCase { None = 0, NullValue = 1, diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 4510d0b6..16f7b0af 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -169,7 +169,7 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print( vars, "private object $name$_;\n" - "/// Enum of possibly cases for the \"$original_name$\" oneof.\n" + "/// Enum of possible cases for the \"$original_name$\" oneof.\n" "public enum $property_name$OneofCase {\n"); printer->Indent(); printer->Print("None = 0,\n"); -- cgit v1.2.3