aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
commit3af881c7e2db0553207876acbdb91c6e77974e44 (patch)
tree35e2a96cce802d4235bd29afa396e28ead892fa2 /csharp
parent86975301f1876ce1934612777b8ca6c76520f5cc (diff)
parent942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff)
Merge master into 3.4.x
Diffstat (limited to 'csharp')
-rw-r--r--csharp/README.md61
-rw-r--r--csharp/build_packages.bat4
-rwxr-xr-xcsharp/buildall.sh5
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs2
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs2
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj30
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj19
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs47
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json44
-rwxr-xr-xcsharp/compatibility_tests/v3.0.0/test.sh8
-rw-r--r--csharp/global.json5
-rw-r--r--csharp/src/AddressBook/AddressBook.csproj14
-rw-r--r--csharp/src/AddressBook/AddressBook.xproj19
-rw-r--r--csharp/src/AddressBook/project.json20
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj14
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj19
-rw-r--r--csharp/src/Google.Protobuf.Conformance/project.json21
-rw-r--r--csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj13
-rw-r--r--csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj19
-rw-r--r--csharp/src/Google.Protobuf.JsonDump/project.json19
-rw-r--r--csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs9
-rw-r--r--csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs9
-rw-r--r--csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs16
-rw-r--r--csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj30
-rw-r--r--csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj21
-rwxr-xr-xcsharp/src/Google.Protobuf.Test/Program.cs48
-rw-r--r--csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs28
-rw-r--r--csharp/src/Google.Protobuf.Test/project.json45
-rw-r--r--csharp/src/Google.Protobuf.sln16
-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
-rw-r--r--csharp/src/global.json5
-rw-r--r--csharp/src/packages/repositories.config4
38 files changed, 510 insertions, 475 deletions
diff --git a/csharp/README.md b/csharp/README.md
index 65d2311f..c1d12419 100644
--- a/csharp/README.md
+++ b/csharp/README.md
@@ -31,28 +31,23 @@ which only uses features from C# 3 and earlier.
Building
========
-Open the `src/Google.Protobuf.sln` solution in Visual Studio 2015 or
+Open the `src/Google.Protobuf.sln` solution in Visual Studio 2017 or
later.
Although *users* of this project are only expected to have Visual
Studio 2012 or later, *developers* of the library are required to
-have Visual Studio 2015 or later, as the library uses C# 6 features
-in its implementation. These features have no impact when using the
-compiled code - they're only relevant when building the
-`Google.Protobuf` assembly.
+have Visual Studio 2017 or later, as the library uses C# 6 features
+in its implementation, as well as the new Visual Studio 2017 csproj
+format. These features have no impact when using the compiled code -
+they're only relevant when building the `Google.Protobuf` assembly.
Testing
=======
-The unit tests use [NUnit 3](https://github.com/nunit/nunit). Vanilla NUnit doesn't
-support .NET Core, so to run the tests you'll need to use
-[dotnet-test-nunit](https://github.com/nunit/dotnet-test-nunit).
-`dotnet-test-nunit` can also run tests for .NET 4.5+, so to run the tests
-for both .NET Core and .NET 4.5, you can simply open the
-`Package Manager Console` in Visual Studio and execute:
-```
-dotnet test Google.Protobuf.Test
-```
+The unit tests use [NUnit 3](https://github.com/nunit/nunit). NUnit doesn't yet
+support `dotnet test`, so for now the test project is a console application
+using NUnitLite. Simply run `Google.Protobuf.Test.exe` to run the unit tests
+directly, or else use `dotnet run`.
.NET 3.5
========
@@ -62,35 +57,15 @@ to make enabling .NET 3.5 support relatively painless in case you require it.
There's no guarantee that this will continue in the future, so rely on .NET
3.5 support at your peril.
-To enable .NET 3.5 support:
-
-1. Modify [src/Google.Protobuf/project.json](src/Google.Protobuf/project.json) to add `"net35": {}` to `"frameworks"`.
-2. Modify [src/Google.Protobuf.Test/project.json](src/Google.Protobuf/project.json):
- 1. Add `"net35": {}` to `"frameworks"`.
- 2. `dotnet-test-nunit` doesn't support .NET 3.5, so remove it from
- the project-wide `"dependencies"` and add it to the framework-specific
- dependencies under `"net451"` and `"netcoreapp1.0"`.
-
-Note that `dotnet-test-nunit` doesn't support .NET 3.5. You can instead run the
-tests with [NUnit 3 console](https://github.com/nunit/nunit-console)
-by running something like:
-```
-nunit3-console.exe "Google.Protobuf.Test\bin\Debug\net35\win7-x64\Google.Protobuf.Test.dll" --inprocess
-```
-
-The exact path may differ depending on your environment (e.g., the `win7-x64`
-directory may be called something else). The `--inprocess` flag seems to be a
-necessary workaround for a bug in NUnit; otherwise, you'll receive
-an error "Exception has been thrown by the target of an invocation"
-([possibly related issue](https://github.com/nunit/nunit/issues/1480)).
-
-If you still want to run the .NET 4.5 and .NET Core tests, you can do so by
-specifying the framework when using `dotnet-test-nunit`, i.e. from
-`Package Manager Console` in Visual Studio:
-```
-dotnet test Google.Protobuf.Test --framework netcoreapp1.0
-dotnet test Google.Protobuf.Test --framework net451
-```
+To enable .NET 3.5 support, you must edit the `TargetFrameworks` elements of
+[src/Google.Protobuf/Google.Protobuf.csproj](src/Google.Protobuf/Google.Protobuf.csproj)
+(and [src/Google.Protobuf.Test/Google.Protobuf.Test.csproj](src/Google.Protobuf.Test/Google.Protobuf.Test.csproj)
+if you want to run the unit tests):
+
+Open the .csproj file in a text editor and simply add `net35` to the list of
+target frameworks, noting that the `TargetFrameworks` element appears twice in
+the file (once in the first `PropertyGroup` element, and again in the second
+`PropertyGroup` element, i.e., the one with the conditional).
History of C# protobufs
=======================
diff --git a/csharp/build_packages.bat b/csharp/build_packages.bat
index 37732e7c..d7205659 100644
--- a/csharp/build_packages.bat
+++ b/csharp/build_packages.bat
@@ -1,7 +1,7 @@
@rem Builds Google.Protobuf NuGet packages
-dotnet restore src
-dotnet pack -c Release src\Google.Protobuf || goto :error
+dotnet restore src/Google.Protobuf.sln
+dotnet pack -c Release src/Google.Protobuf.sln || goto :error
goto :EOF
diff --git a/csharp/buildall.sh b/csharp/buildall.sh
index cab32229..dd4b463d 100755
--- a/csharp/buildall.sh
+++ b/csharp/buildall.sh
@@ -6,11 +6,12 @@ SRC=$(dirname $0)/src
set -ex
echo Building relevant projects.
-dotnet build -c $CONFIG $SRC/Google.Protobuf $SRC/Google.Protobuf.Test $SRC/Google.Protobuf.Conformance
+dotnet restore $SRC/Google.Protobuf.sln
+dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
echo Running tests.
# Only test netcoreapp1.0, which uses the .NET Core runtime.
# If we want to test the .NET 4.5 version separately, we could
# run Mono explicitly. However, we don't have any differences between
# the .NET 4.5 and netstandard1.0 assemblies.
-dotnet test -c $CONFIG -f netcoreapp1.0 $SRC/Google.Protobuf.Test
+dotnet run -c $CONFIG -f netcoreapp1.0 -p $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs
index c0a9ffd1..ff44895c 100644
--- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs
@@ -403,7 +403,7 @@ namespace Google.Protobuf
output.Flush();
ms.Position = 0;
- CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0);
+ CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false);
uint tag = input.ReadTag();
Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
index 48bf6d60..01bd3218 100644
--- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
@@ -334,7 +334,7 @@ namespace Google.Protobuf
}
// Now test Input stream:
{
- CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0);
+ CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
Assert.AreEqual(0, cin.Position);
// Field 1:
uint tag = cin.ReadTag();
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
new file mode 100644
index 00000000..06d07b9f
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
+ <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly>true</SignAssembly>
+ <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
+ <IsPackable>False</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="NUnit" Version="3.6.1" />
+ <PackageReference Include="NUnitLite" Version="3.6.1" />
+ </ItemGroup>
+
+ <!--
+ - 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>netcoreapp1.0</TargetFrameworks>
+ </PropertyGroup>
+
+</Project>
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
deleted file mode 100644
index a9a1cc04..00000000
--- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.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>580eb013-d3c7-4578-b845-015f4a3b0591</ProjectGuid>
- <RootNamespace>Google.Protobuf.Test</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/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs
new file mode 100644
index 00000000..9078e59b
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs
@@ -0,0 +1,47 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 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 NUnitLite;
+using System.Reflection;
+
+// Note: this file wasn't in the actual 3.0, but is required due to build
+// system changes
+
+namespace Google.Protobuf.Test
+{
+ class Program
+ {
+ public static int Main(string[] args)
+ {
+ return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args);
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json
deleted file mode 100644
index 87b732c9..00000000
--- a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "keyFile": "../../keys/Google.Protobuf.snk"
- },
-
- "configurations": {
- "Debug": {
- "buildOptions": {
- "define": [ "DEBUG", "TRACE" ]
- }
- },
- "Release": {
- "buildOptions": {
- "define": [ "RELEASE", "TRACE" ],
- "optimize": true
- }
- }
- },
-
- "dependencies": {
- "Google.Protobuf": { "target": "project" },
- "NUnit": "3.4.0",
- "dotnet-test-nunit": "3.4.0-alpha-2",
- },
-
- "testRunner": "nunit",
-
- "frameworks": {
- "netcoreapp1.0": {
- "imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
- "buildOptions": {
- "define": [ "PCL" ]
- },
- "dependencies": {
- "Microsoft.NETCore.App": {
- "version": "1.0.0",
- "type": "platform"
- },
- "System.Console": "4.0.0"
- }
- }
- }
-} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh
index bb04fc2c..54d28dfc 100755
--- a/csharp/compatibility_tests/v3.0.0/test.sh
+++ b/csharp/compatibility_tests/v3.0.0/test.sh
@@ -18,8 +18,11 @@ function run_test() {
protos/src/google/protobuf/map_unittest_proto3.proto
# Build and test.
- dotnet build -c release src/Google.Protobuf src/Google.Protobuf.Test
- dotnet test -c release -f netcoreapp1.0 src/Google.Protobuf.Test
+ dotnet restore src/Google.Protobuf/Google.Protobuf.csproj
+ dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+ dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
+ dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
+ dotnet run -c Release -f netcoreapp1.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
}
set -ex
@@ -72,7 +75,6 @@ chmod +x old_protoc
# Copy the new runtime and keys.
cp ../../src/Google.Protobuf src/Google.Protobuf -r
cp ../../keys . -r
-dotnet restore
# Test A.1:
# proto set 1: use old version
diff --git a/csharp/global.json b/csharp/global.json
new file mode 100644
index 00000000..3622b564
--- /dev/null
+++ b/csharp/global.json
@@ -0,0 +1,5 @@
+{
+ "sdk": {
+ "version": "1.0.0"
+ }
+}
diff --git a/csharp/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj
new file mode 100644
index 00000000..6edfdcab
--- /dev/null
+++ b/csharp/src/AddressBook/AddressBook.csproj
@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ <OutputType>Exe</OutputType>
+ <StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
+ <IsPackable>False</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/csharp/src/AddressBook/AddressBook.xproj b/csharp/src/AddressBook/AddressBook.xproj
deleted file mode 100644
index 4c9925e8..00000000
--- a/csharp/src/AddressBook/AddressBook.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>afb63919-1e05-43b4-802a-8fb8c9b2f463</ProjectGuid>
- <RootNamespace>AddressBook</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/AddressBook/project.json b/csharp/src/AddressBook/project.json
deleted file mode 100644
index c500bdc2..00000000
--- a/csharp/src/AddressBook/project.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "emitEntryPoint": true,
- "additionalArguments": [ "/main:Google.Protobuf.Examples.AddressBook.Program" ]
- },
- "dependencies": {
- "Google.Protobuf": { "target": "project" }
- },
- "frameworks": {
- "netcoreapp1.0": {
- "dependencies": {
- "Microsoft.NETCore.App": {
- "type": "platform",
- "version": "1.0.0"
- }
- }
- }
- }
-}
diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
new file mode 100644
index 00000000..b654c0b2
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ <OutputType>Exe</OutputType>
+ <IsPackable>False</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
+ <ProjectReference Include="..\Google.Protobuf.Test\Google.Protobuf.Test.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj
deleted file mode 100644
index 99ff1465..00000000
--- a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.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>dddc055b-e185-4181-bab0-072f0f984569</ProjectGuid>
- <RootNamespace>Google.Protobuf.Conformance</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.Conformance/project.json b/csharp/src/Google.Protobuf.Conformance/project.json
deleted file mode 100644
index 4cf05231..00000000
--- a/csharp/src/Google.Protobuf.Conformance/project.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "emitEntryPoint": true
- },
- "dependencies": {
- "Google.Protobuf": { "target": "project" },
- "Google.Protobuf.Test": { "target": "project" }
- },
- "frameworks": {
- "netcoreapp1.0": {
- "imports": [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
- "dependencies": {
- "Microsoft.NETCore.App": {
- "type": "platform",
- "version": "1.0.0"
- }
- }
- }
- }
-}
diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
new file mode 100644
index 00000000..4eda641a
--- /dev/null
+++ b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ <OutputType>Exe</OutputType>
+ <IsPackable>False</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj
deleted file mode 100644
index 27095be5..00000000
--- a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.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>9695e08f-9829-497d-b95c-b38f28d48690</ProjectGuid>
- <RootNamespace>Google.Protobuf.JsonDump</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.JsonDump/project.json b/csharp/src/Google.Protobuf.JsonDump/project.json
deleted file mode 100644
index 84b23c45..00000000
--- a/csharp/src/Google.Protobuf.JsonDump/project.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "emitEntryPoint": true
- },
- "dependencies": {
- "Google.Protobuf": { "target": "project" }
- },
- "frameworks": {
- "netcoreapp1.0": {
- "dependencies": {
- "Microsoft.NETCore.App": {
- "type": "platform",
- "version": "1.0.0"
- }
- }
- }
- }
-}
diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
index c0a9ffd1..e719d2a0 100644
--- a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
+++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
@@ -403,7 +403,7 @@ namespace Google.Protobuf
output.Flush();
ms.Position = 0;
- CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0);
+ CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false);
uint tag = input.ReadTag();
Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
@@ -594,5 +594,12 @@ namespace Google.Protobuf
}
Assert.IsTrue(memoryStream.CanRead); // We left the stream open
}
+
+ [Test]
+ public void Dispose_FromByteArray()
+ {
+ var stream = new CodedInputStream(new byte[10]);
+ stream.Dispose();
+ }
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
index 48bf6d60..98cabd55 100644
--- a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
+++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
@@ -334,7 +334,7 @@ namespace Google.Protobuf
}
// Now test Input stream:
{
- CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0);
+ CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
Assert.AreEqual(0, cin.Position);
// Field 1:
uint tag = cin.ReadTag();
@@ -415,5 +415,12 @@ namespace Google.Protobuf
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
}
+
+ [Test]
+ public void Dispose_FromByteArray()
+ {
+ var stream = new CodedOutputStream(new byte[10]);
+ stream.Dispose();
+ }
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
index 9d3d69af..68b4de45 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -540,6 +540,22 @@ namespace Google.Protobuf.Collections
Assert.Throws<ArgumentException>(() => map.ToString());
}
+#if !NET35
+ [Test]
+ public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ CollectionAssert.AreEquivalent(((IDictionary<string, string>)map).Keys, ((IReadOnlyDictionary<string, string>)map).Keys);
+ }
+
+ [Test]
+ public void IDictionaryValues_Equals_IReadOnlyDictionaryValues()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ CollectionAssert.AreEquivalent(((IDictionary<string, string>)map).Values, ((IReadOnlyDictionary<string, string>)map).Values);
+ }
+#endif
+
private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value)
{
return new KeyValuePair<TKey, TValue>(key, value);
diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
new file mode 100644
index 00000000..06d07b9f
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
+ <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly>true</SignAssembly>
+ <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
+ <IsPackable>False</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="NUnit" Version="3.6.1" />
+ <PackageReference Include="NUnitLite" Version="3.6.1" />
+ </ItemGroup>
+
+ <!--
+ - 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>netcoreapp1.0</TargetFrameworks>
+ </PropertyGroup>
+
+</Project>
diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
deleted file mode 100644
index 6370441e..00000000
--- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
+++ /dev/null
@@ -1,21 +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>580eb013-d3c7-4578-b845-015f4a3b0591</ProjectGuid>
- <RootNamespace>Google.Protobuf.Test</RootNamespace>
- <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
- <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
- </PropertyGroup>
- <PropertyGroup>
- <SchemaVersion>2.0</SchemaVersion>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
- </ItemGroup>
- <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project> \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/Program.cs b/csharp/src/Google.Protobuf.Test/Program.cs
new file mode 100755
index 00000000..954c02b5
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/Program.cs
@@ -0,0 +1,48 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 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 NUnitLite;
+using System.Reflection;
+
+namespace Google.Protobuf.Test
+{
+ class Program
+ {
+ public static int Main(string[] args)
+ {
+ #if NET35
+ return new AutoRun(typeof(Program).Assembly).Execute(args);
+ #else
+ return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args);
+ #endif
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
index 4aecc998..a3edd595 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
@@ -91,6 +91,24 @@ namespace Google.Protobuf.WellKnownTypes
}
[Test]
+ public void TryUnpack_WrongType()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ Assert.False(any.TryUnpack(out TestOneof unpacked));
+ Assert.Null(unpacked);
+ }
+
+ [Test]
+ public void TryUnpack_RightType()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ Assert.IsTrue(any.TryUnpack(out TestAllTypes unpacked));
+ Assert.AreEqual(message, unpacked);
+ }
+
+ [Test]
public void ToString_WithValues()
{
var message = SampleMessages.CreateFullTestAllTypes();
@@ -100,6 +118,16 @@ namespace Google.Protobuf.WellKnownTypes
}
[Test]
+ [TestCase("proto://foo.bar", "foo.bar")]
+ [TestCase("/foo/bar/baz", "baz")]
+ [TestCase("foobar", "")]
+ public void GetTypeName(string typeUrl, string expectedTypeName)
+ {
+ var any = new Any { TypeUrl = typeUrl };
+ Assert.AreEqual(expectedTypeName, Any.GetTypeName(typeUrl));
+ }
+
+ [Test]
public void ToString_Empty()
{
var any = new Any();
diff --git a/csharp/src/Google.Protobuf.Test/project.json b/csharp/src/Google.Protobuf.Test/project.json
deleted file mode 100644
index dff0ab73..00000000
--- a/csharp/src/Google.Protobuf.Test/project.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "buildOptions": {
- "debugType": "portable",
- "keyFile": "../../keys/Google.Protobuf.snk"
- },
-
- "configurations": {
- "Debug": {
- "buildOptions": {
- "define": [ "DEBUG", "TRACE" ]
- }
- },
- "Release": {
- "buildOptions": {
- "define": [ "RELEASE", "TRACE" ],
- "optimize": true
- }
- }
- },
-
- "dependencies": {
- "Google.Protobuf": { "target": "project" },
- "dotnet-test-nunit": "3.4.0-beta-3",
- "NUnit": "3.6.0"
- },
-
- "testRunner": "nunit",
-
- "frameworks": {
- "net451": {},
- "netcoreapp1.0": {
- "imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
- "buildOptions": {
- "define": [ "PCL" ]
- },
- "dependencies": {
- "Microsoft.NETCore.App": {
- "version": "1.0.0",
- "type": "platform"
- },
- "System.Console": "4.0.0"
- }
- }
- }
-}
diff --git a/csharp/src/Google.Protobuf.sln b/csharp/src/Google.Protobuf.sln
index 3c62bba3..443ee3e9 100644
--- a/csharp/src/Google.Protobuf.sln
+++ b/csharp/src/Google.Protobuf.sln
@@ -1,16 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 14.0.24720.0
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AddressBook", "AddressBook\AddressBook.xproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}"
+# Visual Studio 15
+VisualStudioVersion = 15.0.26114.2
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.xproj", "{9B576380-726D-4142-8238-60A43AB0E35A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{9B576380-726D-4142-8238-60A43AB0E35A}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.xproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.xproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.xproj", "{9695E08F-9829-497D-B95C-B38F28D48690}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{9695E08F-9829-497D-B95C-B38F28D48690}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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",
+ "ChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOg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 "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"
- }
- }
- }
-}
diff --git a/csharp/src/global.json b/csharp/src/global.json
deleted file mode 100644
index 9d5558b1..00000000
--- a/csharp/src/global.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "sdk": {
- "version": "1.0.0-preview2-003131"
- }
-}
diff --git a/csharp/src/packages/repositories.config b/csharp/src/packages/repositories.config
deleted file mode 100644
index 70379412..00000000
--- a/csharp/src/packages/repositories.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<repositories>
- <repository path="..\Google.Protobuf.Test\packages.config" />
-</repositories> \ No newline at end of file