aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf')
-rw-r--r--csharp/src/Google.Protobuf/CodedInputStream.cs17
-rw-r--r--csharp/src/Google.Protobuf/Collections/MapField.cs11
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.csproj33
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.xproj19
-rw-r--r--csharp/src/Google.Protobuf/Reflection/Descriptor.cs181
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs43
-rw-r--r--csharp/src/Google.Protobuf/project.json65
7 files changed, 211 insertions, 158 deletions
diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs
index 072e2e17..84f90a25 100644
--- a/csharp/src/Google.Protobuf/CodedInputStream.cs
+++ b/csharp/src/Google.Protobuf/CodedInputStream.cs
@@ -121,7 +121,7 @@ namespace Google.Protobuf
/// <summary>
/// Creates a new CodedInputStream reading data from the given byte array.
/// </summary>
- public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length)
+ public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length, true)
{
}
@@ -129,7 +129,7 @@ namespace Google.Protobuf
/// Creates a new <see cref="CodedInputStream"/> that reads from the given byte array slice.
/// </summary>
public CodedInputStream(byte[] buffer, int offset, int length)
- : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length)
+ : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length, true)
{
if (offset < 0 || offset > buffer.Length)
{
@@ -158,16 +158,15 @@ namespace Google.Protobuf
/// <c cref="CodedInputStream"/> is disposed; <c>false</c> to dispose of the given stream when the
/// returned object is disposed.</param>
public CodedInputStream(Stream input, bool leaveOpen)
- : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0)
+ : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0, leaveOpen)
{
- this.leaveOpen = leaveOpen;
}
/// <summary>
/// Creates a new CodedInputStream reading data from the given
/// stream and buffer, using the default limits.
/// </summary>
- internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize)
+ internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, bool leaveOpen)
{
this.input = input;
this.buffer = buffer;
@@ -175,6 +174,7 @@ namespace Google.Protobuf
this.bufferSize = bufferSize;
this.sizeLimit = DefaultSizeLimit;
this.recursionLimit = DefaultRecursionLimit;
+ this.leaveOpen = leaveOpen;
}
/// <summary>
@@ -185,8 +185,8 @@ namespace Google.Protobuf
/// This chains to the version with the default limits instead of vice versa to avoid
/// having to check that the default values are valid every time.
/// </remarks>
- internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit)
- : this(input, buffer, bufferPos, bufferSize)
+ internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit, bool leaveOpen)
+ : this(input, buffer, bufferPos, bufferSize, leaveOpen)
{
if (sizeLimit <= 0)
{
@@ -217,7 +217,8 @@ namespace Google.Protobuf
/// and recursion limits.</returns>
public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit)
{
- return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit);
+ // Note: we may want an overload accepting leaveOpen
+ return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit, false);
}
/// <summary>
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs
index ef5651c9..8dac8e30 100644
--- a/csharp/src/Google.Protobuf/Collections/MapField.cs
+++ b/csharp/src/Google.Protobuf/Collections/MapField.cs
@@ -67,6 +67,9 @@ namespace Google.Protobuf.Collections
/// </para>
/// </remarks>
public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IDictionary<TKey, TValue>, IEquatable<MapField<TKey, TValue>>, IDictionary
+#if !NET35
+ , IReadOnlyDictionary<TKey, TValue>
+#endif
{
// TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.)
private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>> map =
@@ -548,6 +551,14 @@ namespace Google.Protobuf.Collections
}
#endregion
+ #region IReadOnlyDictionary explicit interface implementation
+#if !NET35
+ IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys => Keys;
+
+ IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values => Values;
+#endif
+ #endregion
+
private class DictionaryEnumerator : IDictionaryEnumerator
{
private readonly IEnumerator<KeyValuePair<TKey, TValue>> enumerator;
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
new file mode 100644
index 00000000..46418e39
--- /dev/null
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -0,0 +1,33 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
+ <Copyright>Copyright 2015, Google Inc.</Copyright>
+ <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
+ <VersionPrefix>3.3.0</VersionPrefix>
+ <Authors>Google Inc.</Authors>
+ <TargetFrameworks>netstandard1.0;net451</TargetFrameworks>
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
+ <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly>true</SignAssembly>
+ <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
+ <PackageTags>Protocol;Buffers;Binary;Serialization;Format;Google;proto;proto3</PackageTags>
+ <PackageReleaseNotes>C# proto3 support</PackageReleaseNotes>
+ <PackageProjectUrl>https://github.com/google/protobuf</PackageProjectUrl>
+ <PackageLicenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</PackageLicenseUrl>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>https://github.com/google/protobuf.git</RepositoryUrl>
+ <IncludeSymbols>true</IncludeSymbols>
+ <IncludeSource>true</IncludeSource>
+ </PropertyGroup>
+
+ <!--
+ - Override target frameworks on non-Windows to just .NET Core
+ - Doing this conditionally in the initial PropertyGroup confuses
+ - Visual Studio.
+ -->
+ <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
+ <TargetFrameworks>netstandard1.0</TargetFrameworks>
+ </PropertyGroup>
+
+</Project>
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.xproj b/csharp/src/Google.Protobuf/Google.Protobuf.xproj
deleted file mode 100644
index c68e0db3..00000000
--- a/csharp/src/Google.Protobuf/Google.Protobuf.xproj
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
- <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
- </PropertyGroup>
- <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
- <PropertyGroup Label="Globals">
- <ProjectGuid>9b576380-726d-4142-8238-60a43ab0e35a</ProjectGuid>
- <RootNamespace>Google.Protobuf</RootNamespace>
- <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
- <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
- </PropertyGroup>
-
- <PropertyGroup>
- <SchemaVersion>2.0</SchemaVersion>
- </PropertyGroup>
- <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project> \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
index 472310df..8311a2c6 100644
--- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -83,7 +83,7 @@ namespace Google.Protobuf.Reflection {
"bmFtZRgBIAEoCRISCgppbnB1dF90eXBlGAIgASgJEhMKC291dHB1dF90eXBl",
"GAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5nb29nbGUucHJvdG9idWYuTWV0",
"aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFtaW5nGAUgASgIOgVmYWxzZRIf",
- "ChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxzZSK0BQoLRmlsZU9wdGlv",
+ "ChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxzZSLwBQoLRmlsZU9wdGlv",
"bnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGphdmFfb3V0ZXJfY2xhc3Nu",
"YW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVfZmlsZXMYCiABKAg6BWZhbHNl",
"EikKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2FuZF9oYXNoGBQgASgIQgIYARIl",
@@ -92,64 +92,66 @@ namespace Google.Protobuf.Reflection {
"T3B0aW1pemVNb2RlOgVTUEVFRBISCgpnb19wYWNrYWdlGAsgASgJEiIKE2Nj",
"X2dlbmVyaWNfc2VydmljZXMYECABKAg6BWZhbHNlEiQKFWphdmFfZ2VuZXJp",
"Y19zZXJ2aWNlcxgRIAEoCDoFZmFsc2USIgoTcHlfZ2VuZXJpY19zZXJ2aWNl",
- "cxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgXIAEoCDoFZmFsc2USHwo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WdhdGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoMZG91YmxlX3Zh",
+ "bHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEoDBIXCg9hZ2dyZWdhdGVf",
+ "dmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0GAEgAigJEhQK",
+ "DGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNlQ29kZUluZm8SOgoIbG9j",
+ "YXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYuU291cmNlQ29kZUluZm8u",
+ "TG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgYASADKAVCAhABEhAKBHNw",
+ "YW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVudHMYAyABKAkSGQoRdHJh",
+ "aWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGluZ19kZXRhY2hlZF9jb21t",
+ "ZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUluZm8SQQoKYW5ub3RhdGlv",
+ "bhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRDb2RlSW5mby5B",
+ "bm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0aBgBIAMoBUICEAESEwoL",
+ "c291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyABKAUSCwoDZW5kGAQgASgF",
+ "QowBChNjb20uZ29vZ2xlLnByb3RvYnVmQhBEZXNjcmlwdG9yUHJvdG9zSAFa",
+ "PmdpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3Byb3RvYy1nZW4tZ28vZGVz",
+ "Y3JpcHRvcjtkZXNjcmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVmLlJl",
+ "ZmxlY3Rpb24="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -164,7 +166,7 @@ namespace Google.Protobuf.Reflection {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null),
@@ -2954,12 +2956,14 @@ namespace Google.Protobuf.Reflection {
ccGenericServices_ = other.ccGenericServices_;
javaGenericServices_ = other.javaGenericServices_;
pyGenericServices_ = other.pyGenericServices_;
+ phpGenericServices_ = other.phpGenericServices_;
deprecated_ = other.deprecated_;
ccEnableArenas_ = other.ccEnableArenas_;
objcClassPrefix_ = other.objcClassPrefix_;
csharpNamespace_ = other.csharpNamespace_;
swiftPrefix_ = other.swiftPrefix_;
phpClassPrefix_ = other.phpClassPrefix_;
+ phpNamespace_ = other.phpNamespace_;
uninterpretedOption_ = other.uninterpretedOption_.Clone();
}
@@ -3130,6 +3134,17 @@ namespace Google.Protobuf.Reflection {
}
}
+ /// <summary>Field number for the "php_generic_services" field.</summary>
+ public const int PhpGenericServicesFieldNumber = 19;
+ private bool phpGenericServices_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool PhpGenericServices {
+ get { return phpGenericServices_; }
+ set {
+ phpGenericServices_ = value;
+ }
+ }
+
/// <summary>Field number for the "deprecated" field.</summary>
public const int DeprecatedFieldNumber = 23;
private bool deprecated_;
@@ -3223,6 +3238,22 @@ namespace Google.Protobuf.Reflection {
}
}
+ /// <summary>Field number for the "php_namespace" field.</summary>
+ public const int PhpNamespaceFieldNumber = 41;
+ private string phpNamespace_ = "";
+ /// <summary>
+ /// Use this option to change the namespace of php generated classes. Default
+ /// is empty. When this option is empty, the package name will be used for
+ /// determining the namespace.
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string PhpNamespace {
+ get { return phpNamespace_; }
+ set {
+ phpNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
/// <summary>Field number for the "uninterpreted_option" field.</summary>
public const int UninterpretedOptionFieldNumber = 999;
private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec
@@ -3259,12 +3290,14 @@ namespace Google.Protobuf.Reflection {
if (CcGenericServices != other.CcGenericServices) return false;
if (JavaGenericServices != other.JavaGenericServices) return false;
if (PyGenericServices != other.PyGenericServices) return false;
+ if (PhpGenericServices != other.PhpGenericServices) return false;
if (Deprecated != other.Deprecated) return false;
if (CcEnableArenas != other.CcEnableArenas) return false;
if (ObjcClassPrefix != other.ObjcClassPrefix) return false;
if (CsharpNamespace != other.CsharpNamespace) return false;
if (SwiftPrefix != other.SwiftPrefix) return false;
if (PhpClassPrefix != other.PhpClassPrefix) return false;
+ if (PhpNamespace != other.PhpNamespace) return false;
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
return true;
}
@@ -3282,12 +3315,14 @@ namespace Google.Protobuf.Reflection {
if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode();
if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode();
if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode();
+ if (PhpGenericServices != false) hash ^= PhpGenericServices.GetHashCode();
if (Deprecated != false) hash ^= Deprecated.GetHashCode();
if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode();
if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode();
if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode();
if (SwiftPrefix.Length != 0) hash ^= SwiftPrefix.GetHashCode();
if (PhpClassPrefix.Length != 0) hash ^= PhpClassPrefix.GetHashCode();
+ if (PhpNamespace.Length != 0) hash ^= PhpNamespace.GetHashCode();
hash ^= uninterpretedOption_.GetHashCode();
return hash;
}
@@ -3331,6 +3366,10 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(144, 1);
output.WriteBool(PyGenericServices);
}
+ if (PhpGenericServices != false) {
+ output.WriteRawTag(152, 1);
+ output.WriteBool(PhpGenericServices);
+ }
if (JavaGenerateEqualsAndHash != false) {
output.WriteRawTag(160, 1);
output.WriteBool(JavaGenerateEqualsAndHash);
@@ -3363,6 +3402,10 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(194, 2);
output.WriteString(PhpClassPrefix);
}
+ if (PhpNamespace.Length != 0) {
+ output.WriteRawTag(202, 2);
+ output.WriteString(PhpNamespace);
+ }
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
}
@@ -3399,6 +3442,9 @@ namespace Google.Protobuf.Reflection {
if (PyGenericServices != false) {
size += 2 + 1;
}
+ if (PhpGenericServices != false) {
+ size += 2 + 1;
+ }
if (Deprecated != false) {
size += 2 + 1;
}
@@ -3417,6 +3463,9 @@ namespace Google.Protobuf.Reflection {
if (PhpClassPrefix.Length != 0) {
size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpClassPrefix);
}
+ if (PhpNamespace.Length != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpNamespace);
+ }
size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec);
return size;
}
@@ -3456,6 +3505,9 @@ namespace Google.Protobuf.Reflection {
if (other.PyGenericServices != false) {
PyGenericServices = other.PyGenericServices;
}
+ if (other.PhpGenericServices != false) {
+ PhpGenericServices = other.PhpGenericServices;
+ }
if (other.Deprecated != false) {
Deprecated = other.Deprecated;
}
@@ -3474,6 +3526,9 @@ namespace Google.Protobuf.Reflection {
if (other.PhpClassPrefix.Length != 0) {
PhpClassPrefix = other.PhpClassPrefix;
}
+ if (other.PhpNamespace.Length != 0) {
+ PhpNamespace = other.PhpNamespace;
+ }
uninterpretedOption_.Add(other.uninterpretedOption_);
}
@@ -3517,6 +3572,10 @@ namespace Google.Protobuf.Reflection {
PyGenericServices = input.ReadBool();
break;
}
+ case 152: {
+ PhpGenericServices = input.ReadBool();
+ break;
+ }
case 160: {
JavaGenerateEqualsAndHash = input.ReadBool();
break;
@@ -3549,6 +3608,10 @@ namespace Google.Protobuf.Reflection {
PhpClassPrefix = input.ReadString();
break;
}
+ case 330: {
+ PhpNamespace = input.ReadString();
+ break;
+ }
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
break;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
index f4fac738..fca689dc 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
@@ -44,17 +44,25 @@ namespace Google.Protobuf.WellKnownTypes
prefix.EndsWith("/") ? prefix + descriptor.FullName : prefix + "/" + descriptor.FullName;
/// <summary>
- /// Retrieves the type name for a type URL. This is always just the last part of the URL,
- /// after the trailing slash. No validation of anything before the trailing slash is performed.
- /// If the type URL does not include a slash, an empty string is returned rather than an exception
- /// being thrown; this won't match any types, and the calling code is probably in a better position
- /// to give a meaningful error.
- /// There is no handling of fragments or queries at the moment.
+ /// Retrieves the type name for a type URL, matching the <see cref="DescriptorBase.FullName"/>
+ /// of the packed message type.
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is always just the last part of the URL, after the final slash. No validation of
+ /// anything before the trailing slash is performed. If the type URL does not include a slash,
+ /// an empty string is returned rather than an exception being thrown; this won't match any types,
+ /// and the calling code is probably in a better position to give a meaningful error.
+ /// </para>
+ /// <para>
+ /// There is no handling of fragments or queries at the moment.
+ /// </para>
+ /// </remarks>
/// <param name="typeUrl">The URL to extract the type name from</param>
/// <returns>The type name</returns>
- internal static string GetTypeName(string typeUrl)
+ public static string GetTypeName(string typeUrl)
{
+ ProtoPreconditions.CheckNotNull(typeUrl, nameof(typeUrl));
int lastSlash = typeUrl.LastIndexOf('/');
return lastSlash == -1 ? "" : typeUrl.Substring(lastSlash + 1);
}
@@ -81,6 +89,27 @@ namespace Google.Protobuf.WellKnownTypes
}
/// <summary>
+ /// Attempts to unpack the content of this Any message into the target message type,
+ /// if it matches the type URL within this Any message.
+ /// </summary>
+ /// <typeparam name="T">The type of message to attempt to unpack the content into.</typeparam>
+ /// <returns><c>true</c> if the message was successfully unpacked; <c>false</c> if the type name didn't match</returns>
+ public bool TryUnpack<T>(out T result) where T : IMessage, new()
+ {
+ // Note: deliberately avoid writing anything to result until the end, in case it's being
+ // monitored by other threads. (That would be a bug in the calling code, but let's not make it worse.)
+ T target = new T();
+ if (GetTypeName(TypeUrl) != target.Descriptor.FullName)
+ {
+ result = default(T); // Can't use null as there's no class constraint, but this always *will* be null in real usage.
+ return false;
+ }
+ target.MergeFrom(Value);
+ result = target;
+ return true;
+ }
+
+ /// <summary>
/// Packs the specified message into an Any message using a type URL prefix of "type.googleapis.com".
/// </summary>
/// <param name="message">The message to pack.</param>
diff --git a/csharp/src/Google.Protobuf/project.json b/csharp/src/Google.Protobuf/project.json
deleted file mode 100644
index f4376238..00000000
--- a/csharp/src/Google.Protobuf/project.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "version": "3.3.0",
- "title": "Google Protocol Buffers",
- "description": "See project site for more info.",
- "authors": [ "Google Inc." ],
- "copyright": "Copyright 2015, Google Inc.",
-
- "packOptions": {
- "summary": "C# runtime library for Protocol Buffers - Google's data interchange format.",
- "tags": [ "Protocol", "Buffers", "Binary", "Serialization", "Format", "Google", "proto", "proto3" ],
- "owners": [ "protobuf-packages" ],
- "licenseUrl": "https://github.com/google/protobuf/blob/master/LICENSE",
- "projectUrl": "https://github.com/google/protobuf",
- "releaseNotes": "C# proto3 support",
- "requireLicenseAcceptance": false,
- "repository": {
- "url": "https://github.com/nodatime/nodatime.git"
- }
- },
-
- "buildOptions": {
- "debugType": "portable",
- "keyFile": "../../keys/Google.Protobuf.snk",
- "xmlDoc": true
- },
-
- "configurations": {
- "Debug": {
- "buildOptions": {
- "define": [ "DEBUG", "TRACE" ]
- }
- },
- "Release": {
- "buildOptions": {
- "define": [ "RELEASE", "TRACE" ],
- "optimize": true
- }
- }
- },
-
- "frameworks": {
- // This target allows the package to be installed in a .NET 4.5+
- // project without asking for myriad other dependencies.
- "net45": {
- },
- "netstandard1.0": {
- "dependencies": {
- "System.Collections": "4.0.11",
- "System.Diagnostics.Debug": "4.0.11",
- "System.Globalization": "4.0.11",
- "System.IO": "4.1.0",
- "System.Linq": "4.1.0",
- "System.Linq.Expressions": "4.1.0",
- "System.ObjectModel": "4.0.12",
- "System.Reflection": "4.1.0",
- "System.Reflection.Extensions": "4.0.1",
- "System.Runtime": "4.1.0",
- "System.Runtime.Extensions": "4.1.0",
- "System.Text.Encoding": "4.0.11",
- "System.Text.RegularExpressions": "4.1.0",
- "System.Threading": "4.0.11"
- }
- }
- }
-}