Explorar o código

Rename GeneratedCodeInfo to GeneratedClrTypeInfo

Recently, descriptor.proto gained a GeneratedCodeInfo message, which means the generated code conflicts with our type.
Unfortunately this affects codegen as well, although this is a part of the public API which is very unlikely to affect hand-written code.

Generated code changes in next commit.
Jon Skeet %!s(int64=9) %!d(string=hai) anos
pai
achega
a3ea9d1203

+ 1 - 1
Makefile.am

@@ -146,7 +146,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs                   \
   csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs                   \
   csharp/src/Google.Protobuf/Reflection/FieldType.cs                         \
   csharp/src/Google.Protobuf/Reflection/FieldType.cs                         \
   csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs                    \
   csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs                    \
-  csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs                 \
+  csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs              \
   csharp/src/Google.Protobuf/Reflection/IDescriptor.cs                       \
   csharp/src/Google.Protobuf/Reflection/IDescriptor.cs                       \
   csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs                    \
   csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs                    \
   csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs                  \
   csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs                  \

+ 1 - 1
csharp/src/Google.Protobuf/Google.Protobuf.csproj

@@ -109,7 +109,7 @@
     <Compile Include="Reflection\FieldDescriptor.cs" />
     <Compile Include="Reflection\FieldDescriptor.cs" />
     <Compile Include="Reflection\FieldType.cs" />
     <Compile Include="Reflection\FieldType.cs" />
     <Compile Include="Reflection\FileDescriptor.cs" />
     <Compile Include="Reflection\FileDescriptor.cs" />
-    <Compile Include="Reflection\GeneratedCodeInfo.cs" />
+    <Compile Include="Reflection\GeneratedClrTypeInfo.cs" />
     <Compile Include="Reflection\IDescriptor.cs" />
     <Compile Include="Reflection\IDescriptor.cs" />
     <Compile Include="Reflection\IFieldAccessor.cs" />
     <Compile Include="Reflection\IFieldAccessor.cs" />
     <Compile Include="Reflection\MapFieldAccessor.cs" />
     <Compile Include="Reflection\MapFieldAccessor.cs" />

+ 3 - 3
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs

@@ -43,7 +43,7 @@ namespace Google.Protobuf.Reflection
     /// </summary>
     /// </summary>
     public sealed class FileDescriptor : IDescriptor
     public sealed class FileDescriptor : IDescriptor
     {
     {
-        private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedCodeInfo generatedCodeInfo)
+        private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo)
         {
         {
             SerializedData = descriptorData;
             SerializedData = descriptorData;
             DescriptorPool = pool;
             DescriptorPool = pool;
@@ -223,7 +223,7 @@ namespace Google.Protobuf.Reflection
         /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
         /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
         /// a valid descriptor. This can occur for a number of reasons, such as a field
         /// a valid descriptor. This can occur for a number of reasons, such as a field
         /// having an undefined type or because two messages were defined with the same name.</exception>
         /// having an undefined type or because two messages were defined with the same name.</exception>
-        private static FileDescriptor BuildFrom(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies, GeneratedCodeInfo generatedCodeInfo)
+        private static FileDescriptor BuildFrom(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo)
         {
         {
             // Building descriptors involves two steps: translating and linking.
             // Building descriptors involves two steps: translating and linking.
             // In the translation step (implemented by FileDescriptor's
             // In the translation step (implemented by FileDescriptor's
@@ -291,7 +291,7 @@ namespace Google.Protobuf.Reflection
         public static FileDescriptor FromGeneratedCode(
         public static FileDescriptor FromGeneratedCode(
             byte[] descriptorData,
             byte[] descriptorData,
             FileDescriptor[] dependencies,
             FileDescriptor[] dependencies,
-            GeneratedCodeInfo generatedCodeInfo)
+            GeneratedClrTypeInfo generatedCodeInfo)
         {
         {
             FileDescriptorProto proto;
             FileDescriptorProto proto;
             try
             try

+ 7 - 7
csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs → csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs

@@ -38,10 +38,10 @@ namespace Google.Protobuf.Reflection
     /// These are constructed as required, and are not long-lived. Hand-written code should
     /// These are constructed as required, and are not long-lived. Hand-written code should
     /// never need to use this type.
     /// never need to use this type.
     /// </summary>
     /// </summary>
-    public sealed class GeneratedCodeInfo
+    public sealed class GeneratedClrTypeInfo
     {
     {
         private static readonly string[] EmptyNames = new string[0];
         private static readonly string[] EmptyNames = new string[0];
-        private static readonly GeneratedCodeInfo[] EmptyCodeInfo = new GeneratedCodeInfo[0];
+        private static readonly GeneratedClrTypeInfo[] EmptyCodeInfo = new GeneratedClrTypeInfo[0];
 
 
         /// <summary>
         /// <summary>
         /// Irrelevant for file descriptors; the CLR type for the message for message descriptors.
         /// Irrelevant for file descriptors; the CLR type for the message for message descriptors.
@@ -70,7 +70,7 @@ namespace Google.Protobuf.Reflection
         /// The reflection information for types within this file/message descriptor. Elements may be null
         /// The reflection information for types within this file/message descriptor. Elements may be null
         /// if there is no corresponding generated type, e.g. for map entry types.
         /// if there is no corresponding generated type, e.g. for map entry types.
         /// </summary>
         /// </summary>
-        public GeneratedCodeInfo[] NestedTypes { get; }
+        public GeneratedClrTypeInfo[] NestedTypes { get; }
 
 
         /// <summary>
         /// <summary>
         /// The CLR types for enums within this file/message descriptor.
         /// The CLR types for enums within this file/message descriptor.
@@ -78,11 +78,11 @@ namespace Google.Protobuf.Reflection
         public Type[] NestedEnums { get; }
         public Type[] NestedEnums { get; }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a GeneratedCodeInfo for a message descriptor, with nested types, nested enums, the CLR type, property names and oneof names.
+        /// Creates a GeneratedClrTypeInfo for a message descriptor, with nested types, nested enums, the CLR type, property names and oneof names.
         /// Each array parameter may be null, to indicate a lack of values.
         /// Each array parameter may be null, to indicate a lack of values.
         /// The parameter order is designed to make it feasible to format the generated code readably.
         /// The parameter order is designed to make it feasible to format the generated code readably.
         /// </summary>
         /// </summary>
-        public GeneratedCodeInfo(Type clrType, MessageParser parser, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, GeneratedCodeInfo[] nestedTypes)
+        public GeneratedClrTypeInfo(Type clrType, MessageParser parser, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, GeneratedClrTypeInfo[] nestedTypes)
         {
         {
             NestedTypes = nestedTypes ?? EmptyCodeInfo;
             NestedTypes = nestedTypes ?? EmptyCodeInfo;
             NestedEnums = nestedEnums ?? ReflectionUtil.EmptyTypes;
             NestedEnums = nestedEnums ?? ReflectionUtil.EmptyTypes;
@@ -93,9 +93,9 @@ namespace Google.Protobuf.Reflection
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a GeneratedCodeInfo for a file descriptor, with only types and enums.
+        /// Creates a GeneratedClrTypeInfo for a file descriptor, with only types and enums.
         /// </summary>
         /// </summary>
-        public GeneratedCodeInfo(Type[] nestedEnums, GeneratedCodeInfo[] nestedTypes)
+        public GeneratedClrTypeInfo(Type[] nestedEnums, GeneratedClrTypeInfo[] nestedTypes)
             : this(null, null, null, null, nestedEnums, nestedTypes)
             : this(null, null, null, null, nestedEnums, nestedTypes)
         {
         {
         }
         }

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs

@@ -60,7 +60,7 @@ namespace Google.Protobuf.Reflection
         private readonly IList<FieldDescriptor> fieldsInNumberOrder;
         private readonly IList<FieldDescriptor> fieldsInNumberOrder;
         private readonly IDictionary<string, FieldDescriptor> jsonFieldMap;
         private readonly IDictionary<string, FieldDescriptor> jsonFieldMap;
         
         
-        internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedCodeInfo generatedCodeInfo)
+        internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedClrTypeInfo generatedCodeInfo)
             : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
             : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
         {
         {
             Proto = proto;
             Proto = proto;

+ 4 - 4
src/google/protobuf/compiler/csharp/csharp_reflection_class.cc

@@ -182,7 +182,7 @@ void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) {
     }
     }
   }
   }
   printer->Print("},\n"
   printer->Print("},\n"
-      "    new pbr::GeneratedCodeInfo(");
+      "    new pbr::GeneratedClrTypeInfo(");
   // Specify all the generated code information, recursively.
   // Specify all the generated code information, recursively.
   if (file_->enum_type_count() > 0) {
   if (file_->enum_type_count() > 0) {
       printer->Print("new[] {");
       printer->Print("new[] {");
@@ -195,7 +195,7 @@ void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) {
       printer->Print("null, ");
       printer->Print("null, ");
   }
   }
   if (file_->message_type_count() > 0) {
   if (file_->message_type_count() > 0) {
-      printer->Print("new pbr::GeneratedCodeInfo[] {\n");
+      printer->Print("new pbr::GeneratedClrTypeInfo[] {\n");
       printer->Indent();
       printer->Indent();
       printer->Indent();
       printer->Indent();
       printer->Indent();
       printer->Indent();
@@ -232,7 +232,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
     return;
     return;
   }
   }
   // Generated message type
   // Generated message type
-  printer->Print("new pbr::GeneratedCodeInfo(typeof($type_name$), $type_name$.Parser, ", "type_name", GetClassName(descriptor));
+  printer->Print("new pbr::GeneratedClrTypeInfo(typeof($type_name$), $type_name$.Parser, ", "type_name", GetClassName(descriptor));
   
   
   // Fields
   // Fields
   if (descriptor->field_count() > 0) {
   if (descriptor->field_count() > 0) {
@@ -273,7 +273,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
   // Nested types
   // Nested types
   if (descriptor->nested_type_count() > 0) {
   if (descriptor->nested_type_count() > 0) {
       // Need to specify array type explicitly here, as all elements may be null. 
       // Need to specify array type explicitly here, as all elements may be null. 
-      printer->Print("new pbr::GeneratedCodeInfo[] { ");
+      printer->Print("new pbr::GeneratedClrTypeInfo[] { ");
       for (int i = 0; i < descriptor->nested_type_count(); i++) {
       for (int i = 0; i < descriptor->nested_type_count(); i++) {
           WriteGeneratedCodeInfo(descriptor->nested_type(i), printer, i == descriptor->nested_type_count() - 1);
           WriteGeneratedCodeInfo(descriptor->nested_type(i), printer, i == descriptor->nested_type_count() - 1);
       }
       }