Commit 8d8177c7 authored by Jisi Liu's avatar Jisi Liu

Merge remote-tracking branch 'origin/master' into fix-author

parents 46e8ff63 cccf6fed
...@@ -95,6 +95,7 @@ csharp_EXTRA_DIST= \ ...@@ -95,6 +95,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \
...@@ -149,6 +150,7 @@ csharp_EXTRA_DIST= \ ...@@ -149,6 +150,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs \ csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs \
csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs \ csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs \
csharp/src/Google.Protobuf/WellKnownTypes/Any.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Any.cs \
csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs \
csharp/src/Google.Protobuf/WellKnownTypes/Api.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Api.cs \
csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs \
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \
...@@ -454,6 +456,7 @@ objectivec_EXTRA_DIST= \ ...@@ -454,6 +456,7 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/GPBMessageTests+Runtime.m \ objectivec/Tests/GPBMessageTests+Runtime.m \
objectivec/Tests/GPBMessageTests+Serialization.m \ objectivec/Tests/GPBMessageTests+Serialization.m \
objectivec/Tests/GPBMessageTests.m \ objectivec/Tests/GPBMessageTests.m \
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm \
objectivec/Tests/GPBPerfTests.m \ objectivec/Tests/GPBPerfTests.m \
objectivec/Tests/GPBStringTests.m \ objectivec/Tests/GPBStringTests.m \
objectivec/Tests/GPBSwiftTests.swift \ objectivec/Tests/GPBSwiftTests.swift \
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library. # dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Protobuf' s.name = 'Protobuf'
s.version = '3.0.0-alpha-4' s.version = '3.0.0-alpha-4.1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf' s.homepage = 'https://github.com/google/protobuf'
s.license = 'New BSD' s.license = 'New BSD'
...@@ -21,7 +21,7 @@ Pod::Spec.new do |s| ...@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}', 'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}',
'objectivec/google/protobuf/Struct.pbobjc.{h,m}', 'objectivec/google/protobuf/Struct.pbobjc.{h,m}',
'objectivec/google/protobuf/Timestamp.pbobjc.h', 'objectivec/google/protobuf/Timestamp.pbobjc.h',
'objectivec/google/protobuf/Type.pbobjc.{h,m}' 'objectivec/google/protobuf/Type.pbobjc.{h,m}',
'objectivec/google/protobuf/Wrappers.pbobjc.{h,m}' 'objectivec/google/protobuf/Wrappers.pbobjc.{h,m}'
# Timestamp.pbobjc.m and Duration.pbobjc.m are #imported by GPBWellKnownTypes.m. So we can't # Timestamp.pbobjc.m and Duration.pbobjc.m are #imported by GPBWellKnownTypes.m. So we can't
# compile them (duplicate symbols), but we need them available for the importing: # compile them (duplicate symbols), but we need them available for the importing:
......
...@@ -14,6 +14,7 @@ set(libprotoc_files ...@@ -14,6 +14,7 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc
......
...@@ -35,11 +35,10 @@ if [ -z "$PROTOC" ]; then ...@@ -35,11 +35,10 @@ if [ -z "$PROTOC" ]; then
fi fi
fi fi
# Descriptor proto # descriptor.proto and well-known types
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/Reflection \ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
src/google/protobuf/descriptor.proto --csharp_opt=base_namespace=Google.Protobuf \
src/google/protobuf/descriptor.proto \
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/WellKnownTypes \
src/google/protobuf/any.proto \ src/google/protobuf/any.proto \
src/google/protobuf/api.proto \ src/google/protobuf/api.proto \
src/google/protobuf/duration.proto \ src/google/protobuf/duration.proto \
...@@ -51,15 +50,18 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/WellKnownTypes \ ...@@ -51,15 +50,18 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/WellKnownTypes \
src/google/protobuf/type.proto \ src/google/protobuf/type.proto \
src/google/protobuf/wrappers.proto src/google/protobuf/wrappers.proto
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ # Test protos where the namespace matches the target location
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=Google.Protobuf \
src/google/protobuf/map_unittest_proto3.proto \ src/google/protobuf/map_unittest_proto3.proto \
src/google/protobuf/unittest_proto3.proto \ src/google/protobuf/unittest_proto3.proto \
src/google/protobuf/unittest_import_proto3.proto \ src/google/protobuf/unittest_import_proto3.proto \
src/google/protobuf/unittest_import_public_proto3.proto \ src/google/protobuf/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto src/google/protobuf/unittest_well_known_types.proto
# Different base namespace to the protos above
$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=UnitTest.Issues \
csharp/protos/unittest_issues.proto csharp/protos/unittest_issues.proto
# AddressBook sample protos # AddressBook sample protos
......
...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection; ...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Google.Protobuf.Examples.AddressBook { namespace Google.Protobuf.Examples.AddressBook {
/// <summary>Holder for reflection information generated from addressbook.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Addressbook { public static partial class Addressbook {
#region Descriptor #region Descriptor
/// <summary>File descriptor for addressbook.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
...@@ -71,6 +73,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -71,6 +73,7 @@ namespace Google.Protobuf.Examples.AddressBook {
return new Person(this); return new Person(this);
} }
/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
...@@ -80,8 +83,12 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -80,8 +83,12 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
} }
/// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 2; public const int IdFieldNumber = 2;
private int id_; private int id_;
/// <summary>
/// Unique ID number for this person.
/// </summary>
public int Id { public int Id {
get { return id_; } get { return id_; }
set { set {
...@@ -89,6 +96,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -89,6 +96,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
} }
/// <summary>Field number for the "email" field.</summary>
public const int EmailFieldNumber = 3; public const int EmailFieldNumber = 3;
private string email_ = ""; private string email_ = "";
public string Email { public string Email {
...@@ -98,6 +106,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -98,6 +106,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
} }
/// <summary>Field number for the "phones" field.</summary>
public const int PhonesFieldNumber = 4; public const int PhonesFieldNumber = 4;
private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phones_codec private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phones_codec
= pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser); = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser);
...@@ -212,6 +221,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -212,6 +221,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
#region Nested types #region Nested types
/// <summary>Container for nested types declared in the Person message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Types { public static partial class Types {
public enum PhoneType { public enum PhoneType {
...@@ -248,6 +258,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -248,6 +258,7 @@ namespace Google.Protobuf.Examples.AddressBook {
return new PhoneNumber(this); return new PhoneNumber(this);
} }
/// <summary>Field number for the "number" field.</summary>
public const int NumberFieldNumber = 1; public const int NumberFieldNumber = 1;
private string number_ = ""; private string number_ = "";
public string Number { public string Number {
...@@ -257,6 +268,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -257,6 +268,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
} }
/// <summary>Field number for the "type" field.</summary>
public const int TypeFieldNumber = 2; public const int TypeFieldNumber = 2;
private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE; private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE;
public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type { public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
...@@ -353,6 +365,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -353,6 +365,9 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
/// <summary>
/// Our address book file is just one of these.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class AddressBook : pb::IMessage<AddressBook> { public sealed partial class AddressBook : pb::IMessage<AddressBook> {
private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook()); private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
...@@ -380,6 +395,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -380,6 +395,7 @@ namespace Google.Protobuf.Examples.AddressBook {
return new AddressBook(this); return new AddressBook(this);
} }
/// <summary>Field number for the "people" field.</summary>
public const int PeopleFieldNumber = 1; public const int PeopleFieldNumber = 1;
private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec
= pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser); = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
......
...@@ -109,6 +109,7 @@ ...@@ -109,6 +109,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestCornerCases.cs" /> <Compile Include="TestCornerCases.cs" />
<Compile Include="TestProtos\UnittestWellKnownTypes.cs" /> <Compile Include="TestProtos\UnittestWellKnownTypes.cs" />
<Compile Include="WellKnownTypes\AnyTest.cs" />
<Compile Include="WellKnownTypes\DurationTest.cs" /> <Compile Include="WellKnownTypes\DurationTest.cs" />
<Compile Include="WellKnownTypes\TimestampTest.cs" /> <Compile Include="WellKnownTypes\TimestampTest.cs" />
<Compile Include="WellKnownTypes\WrappersTest.cs" /> <Compile Include="WellKnownTypes\WrappersTest.cs" />
......
...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection; ...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos { namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/unittest_import_proto3.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class UnittestImportProto3 { public static partial class UnittestImportProto3 {
#region Descriptor #region Descriptor
/// <summary>File descriptor for google/protobuf/unittest_import_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
...@@ -76,6 +78,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -76,6 +78,7 @@ namespace Google.Protobuf.TestProtos {
return new ImportMessage(this); return new ImportMessage(this);
} }
/// <summary>Field number for the "d" field.</summary>
public const int DFieldNumber = 1; public const int DFieldNumber = 1;
private int d_; private int d_;
public int D { public int D {
......
...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection; ...@@ -9,10 +9,12 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos { namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/unittest_import_public_proto3.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class UnittestImportPublicProto3 { public static partial class UnittestImportPublicProto3 {
#region Descriptor #region Descriptor
/// <summary>File descriptor for google/protobuf/unittest_import_public_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
...@@ -62,6 +64,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -62,6 +64,7 @@ namespace Google.Protobuf.TestProtos {
return new PublicImportMessage(this); return new PublicImportMessage(this);
} }
/// <summary>Field number for the "e" field.</summary>
public const int EFieldNumber = 1; public const int EFieldNumber = 1;
private int e_; private int e_;
public int E { public int E {
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf.WellKnownTypes
{
public class AnyTest
{
[Test]
public void Pack()
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message);
Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl);
Assert.AreEqual(message.CalculateSize(), any.Value.Length);
}
[Test]
public void Unpack_WrongType()
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message);
Assert.Throws<InvalidProtocolBufferException>(() => any.Unpack<TestOneof>());
}
[Test]
public void Unpack_Success()
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message);
var unpacked = any.Unpack<TestAllTypes>();
Assert.AreEqual(message, unpacked);
}
}
}
...@@ -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>
......
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
<Compile Include="Reflection\SingleFieldAccessor.cs" /> <Compile Include="Reflection\SingleFieldAccessor.cs" />
<Compile Include="Preconditions.cs" /> <Compile Include="Preconditions.cs" />
<Compile Include="WellKnownTypes\Any.cs" /> <Compile Include="WellKnownTypes\Any.cs" />
<Compile Include="WellKnownTypes\AnyPartial.cs" />
<Compile Include="WellKnownTypes\Api.cs" /> <Compile Include="WellKnownTypes\Api.cs" />
<Compile Include="WellKnownTypes\Duration.cs" /> <Compile Include="WellKnownTypes\Duration.cs" />
<Compile Include="WellKnownTypes\DurationPartial.cs" /> <Compile Include="WellKnownTypes\DurationPartial.cs" />
......
...@@ -96,6 +96,8 @@ namespace Google.Protobuf.Reflection ...@@ -96,6 +96,8 @@ namespace Google.Protobuf.Reflection
return descriptor; return descriptor;
} }
// dependencies contains direct dependencies and any *public* dependencies
// of those dependencies (transitively)... so we don't need to recurse here.
foreach (FileDescriptor dependency in dependencies) foreach (FileDescriptor dependency in dependencies)
{ {
dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result); dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result);
......
...@@ -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;
} }
......
...@@ -11,10 +11,12 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -11,10 +11,12 @@ namespace Google.Protobuf.WellKnownTypes {
namespace Proto { namespace Proto {
/// <summary>Holder for reflection information generated from google/protobuf/any.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Any { public static partial class Any {
#region Descriptor #region Descriptor
/// <summary>File descriptor for google/protobuf/any.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
...@@ -38,6 +40,33 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -38,6 +40,33 @@ namespace Google.Protobuf.WellKnownTypes {
} }
} }
#region Messages #region Messages
/// <summary>
/// `Any` contains an arbitrary serialized message along with a URL
/// that describes the type of the serialized message.
/// JSON
/// ====
/// The JSON representation of an `Any` value uses the regular
/// representation of the deserialized, embedded message, with an
/// additional field `@type` which contains the type URL. Example:
/// package google.profile;
/// message Person {
/// string first_name = 1;
/// string last_name = 2;
/// }
/// {
/// "@type": "type.googleapis.com/google.profile.Person",
/// "firstName": &lt;string>,
/// "lastName": &lt;string>
/// }
/// If the embedded message type is well-known and has a custom JSON
/// representation, that representation will be embedded adding a field
/// `value` which holds the custom JSON in addition to the the `@type`
/// field. Example (for message [google.protobuf.Duration][google.protobuf.Duration]):
/// {
/// "@type": "type.googleapis.com/google.protobuf.Duration",
/// "value": "1.212s"
/// }
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class Any : pb::IMessage<Any> { public sealed partial class Any : pb::IMessage<Any> {
private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any()); private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
...@@ -66,8 +95,27 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -66,8 +95,27 @@ namespace Google.Protobuf.WellKnownTypes {
return new Any(this); return new Any(this);
} }
/// <summary>Field number for the "type_url" field.</summary>
public const int TypeUrlFieldNumber = 1; public const int TypeUrlFieldNumber = 1;
private string typeUrl_ = ""; private string typeUrl_ = "";
/// <summary>
/// A URL/resource name whose content describes the type of the
/// serialized message.
/// For URLs which use the schema `http`, `https`, or no schema, the
/// following restrictions and interpretations apply:
/// * If no schema is provided, `https` is assumed.
/// * The last segment of the URL's path must represent the fully
/// qualified name of the type (as in `path/google.protobuf.Duration`).
/// * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type]
/// value in binary format, or produce an error.
/// * Applications are allowed to cache lookup results based on the
/// URL, or have them precompiled into a binary to avoid any
/// lookup. Therefore, binary compatibility needs to be preserved
/// on changes to types. (Use versioned type names to manage
/// breaking changes.)
/// Schemas other than `http`, `https` (or the empty schema) might be
/// used with implementation specific semantics.
/// </summary>
public string TypeUrl { public string TypeUrl {
get { return typeUrl_; } get { return typeUrl_; }
set { set {
...@@ -75,8 +123,12 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -75,8 +123,12 @@ namespace Google.Protobuf.WellKnownTypes {
} }
} }
/// <summary>Field number for the "value" field.</summary>
public const int ValueFieldNumber = 2; public const int ValueFieldNumber = 2;
private pb::ByteString value_ = pb::ByteString.Empty; private pb::ByteString value_ = pb::ByteString.Empty;
/// <summary>
/// Must be valid serialized data of the above specified type.
/// </summary>
public pb::ByteString Value { public pb::ByteString Value {
get { return value_; } get { return value_; }
set { set {
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using Google.Protobuf.Reflection;
namespace Google.Protobuf.WellKnownTypes
{
public partial class Any
{
// This could be moved to MessageDescriptor if we wanted to, but keeping it here means
// all the Any-specific code is in the same place.
private static string GetTypeUrl(MessageDescriptor descriptor)
{
return "type.googleapis.com/" + descriptor.FullName;
}
/// <summary>
/// Unpacks the content of this Any message into the target message type,
/// which must match the type URL within this Any message.
/// </summary>
/// <typeparam name="T">The type of message to unpack the content into.</typeparam>
/// <returns>The unpacked message.</returns>
/// <exception cref="InvalidProtocolBufferException">The target message type doesn't match the type URL in this message</exception>
public T Unpack<T>() where T : IMessage, new()
{
// Note: this doesn't perform as well is it might. We could take a MessageParser<T> in an alternative overload,
// which would be expected to perform slightly better... although the difference is likely to be negligible.
T target = new T();
string targetTypeUrl = GetTypeUrl(target.Descriptor);
if (TypeUrl != targetTypeUrl)
{
throw new InvalidProtocolBufferException(string.Format("Type url for {0} is {1}; Any message's type url is {2}",
target.Descriptor.Name, targetTypeUrl, TypeUrl));
}
target.MergeFrom(Value);
return target;
}
/// <summary>
/// Packs the specified message into an Any message.
/// </summary>
/// <param name="message">The message to pack.</param>
/// <returns>An Any message with the content and type URL of <paramref name="message"/>.</returns>
public static Any Pack(IMessage message)
{
Preconditions.CheckNotNull(message, "message");
return new Any { TypeUrl = GetTypeUrl(message.Descriptor), Value = message.ToByteString() };
}
}
}
...@@ -11,10 +11,12 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -11,10 +11,12 @@ namespace Google.Protobuf.WellKnownTypes {
namespace Proto { namespace Proto {
/// <summary>Holder for reflection information generated from google/protobuf/empty.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Empty { public static partial class Empty {
#region Descriptor #region Descriptor
/// <summary>File descriptor for google/protobuf/empty.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
...@@ -24,9 +26,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -24,9 +26,9 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1",
"ZiIHCgVFbXB0eUJKChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", "ZiIHCgVFbXB0eUJNChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv",
"UAGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", "UAGgAQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNi",
"b3RvMw==")); "BnByb3RvMw=="));
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
...@@ -38,6 +40,15 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -38,6 +40,15 @@ namespace Google.Protobuf.WellKnownTypes {
} }
} }
#region Messages #region Messages
/// <summary>
/// A generic empty message that you can re-use to avoid defining duplicated
/// empty messages in your APIs. A typical example is to use it as the request
/// or the response type of an API method. For instance:
/// service Foo {
/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
/// }
/// The JSON representation for `Empty` is empty JSON object `{}`.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class Empty : pb::IMessage<Empty> { public sealed partial class Empty : pb::IMessage<Empty> {
private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty()); private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty());
......
...@@ -92,3 +92,8 @@ do ...@@ -92,3 +92,8 @@ do
PROCESS_ROUND=$((PROCESS_ROUND + 1)) PROCESS_ROUND=$((PROCESS_ROUND + 1))
done done
cd .. cd ..
if test -x objectivec/generate_descriptors_proto.sh; then
echo "Generating messages for objc."
objectivec/generate_descriptors_proto.sh $@
fi
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
envlist = envlist =
# cpp implementation on py34 is currently broken due to # cpp implementation on py34 is currently broken due to
# changes introduced by http://bugs.python.org/issue22079. # changes introduced by http://bugs.python.org/issue22079.
#py{26,27,33,34}-{cpp,python} py{26,27,33,34}-{cpp,python}
py{26,27,33}-{cpp,python}, py34-{python}
[testenv] [testenv]
usedevelop=true usedevelop=true
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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