Răsfoiți Sursa

Merge pull request #1785 from jskeet/merge-csharp

Merge C# changes from master to 3.0.0-beta4
Jon Skeet 9 ani în urmă
părinte
comite
e1f146bc4f
46 a modificat fișierele cu 538 adăugiri și 881 ștergeri
  1. 7 5
      .travis.yml
  2. 10 16
      Makefile.am
  3. 6 3
      appveyor.bat
  4. 6 0
      appveyor.yml
  5. 1 1
      conformance/Makefile.am
  6. 8 13
      csharp/.gitignore
  7. 2 5
      csharp/build_packages.bat
  8. 7 8
      csharp/buildall.sh
  9. 0 75
      csharp/src/AddressBook/AddressBook.csproj
  10. 19 0
      csharp/src/AddressBook/AddressBook.xproj
  11. 0 18
      csharp/src/AddressBook/Properties/AssemblyInfo.cs
  12. 1 1
      csharp/src/AddressBook/SampleUsage.cs
  13. 0 3
      csharp/src/AddressBook/app.config
  14. 20 0
      csharp/src/AddressBook/project.json
  15. 0 6
      csharp/src/Google.Protobuf.Conformance/App.config
  16. 0 61
      csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj
  17. 19 0
      csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj
  18. 0 48
      csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs
  19. 19 0
      csharp/src/Google.Protobuf.Conformance/project.json
  20. 0 68
      csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj
  21. 19 0
      csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj
  22. 2 1
      csharp/src/Google.Protobuf.JsonDump/Program.cs
  23. 0 19
      csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs
  24. 0 3
      csharp/src/Google.Protobuf.JsonDump/app.config
  25. 19 0
      csharp/src/Google.Protobuf.JsonDump/project.json
  26. 88 2
      csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
  27. 2 1
      csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
  28. 0 143
      csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  29. 19 0
      csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
  30. 0 6
      csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml
  31. 0 20
      csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs
  32. 1 1
      csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
  33. 2 2
      csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs
  34. 0 5
      csharp/src/Google.Protobuf.Test/packages.config
  35. 44 0
      csharp/src/Google.Protobuf.Test/project.json
  36. 27 38
      csharp/src/Google.Protobuf.sln
  37. 15 16
      csharp/src/Google.Protobuf/Collections/MapField.cs
  38. 68 45
      csharp/src/Google.Protobuf/Collections/RepeatedField.cs
  39. 0 168
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  40. 0 54
      csharp/src/Google.Protobuf/Google.Protobuf.nuspec
  41. 19 0
      csharp/src/Google.Protobuf/Google.Protobuf.xproj
  42. 0 18
      csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs
  43. 0 4
      csharp/src/Google.Protobuf/packages.config
  44. 65 0
      csharp/src/Google.Protobuf/project.json
  45. 7 0
      jenkins/docker/Dockerfile
  46. 16 4
      tests.sh

+ 7 - 5
.travis.yml

@@ -14,7 +14,6 @@ script:
 env:
 env:
   - CONFIG=cpp
   - CONFIG=cpp
   - CONFIG=cpp_distcheck
   - CONFIG=cpp_distcheck
-  - CONFIG=csharp
   - CONFIG=golang
   - CONFIG=golang
   - CONFIG=java_jdk6
   - CONFIG=java_jdk6
   - CONFIG=java_jdk7
   - CONFIG=java_jdk7
@@ -52,10 +51,6 @@ matrix:
       env: CONFIG=javanano_jdk7
       env: CONFIG=javanano_jdk7
     - os: osx
     - os: osx
       env: CONFIG=javanano_oracle7
       env: CONFIG=javanano_oracle7
-    # Requires installing mono, currently travis.sh is doing that with apt-get
-    # which doesn't work on OS X.
-    - os: osx
-      env: CONFIG=csharp
     # Requires installing golang, currently travis.sh is doing that with apt-get
     # Requires installing golang, currently travis.sh is doing that with apt-get
     # which doesn't work on OS X.
     # which doesn't work on OS X.
     - os: osx
     - os: osx
@@ -70,6 +65,13 @@ matrix:
       env: CONFIG=objectivec_osx
       env: CONFIG=objectivec_osx
     - os: linux
     - os: linux
       env: CONFIG=objectivec_cocoapods_integration
       env: CONFIG=objectivec_cocoapods_integration
+  # The dotnet environment requires Ubuntu 14.04 or 16.04. This
+  # configuration is effectively an "extra" one, outside the
+  # autogenerated matrix.
+  include:
+    - os: linux
+      env: CONFIG=csharp
+      dist: trusty
   allow_failures:
   allow_failures:
     # These currently do not work on OS X but are being worked on by @haberman.
     # These currently do not work on OS X but are being worked on by @haberman.
     - os: osx
     - os: osx

+ 10 - 16
Makefile.am

@@ -59,22 +59,19 @@ csharp_EXTRA_DIST=                                                           \
   csharp/keys/README.md                                                      \
   csharp/keys/README.md                                                      \
   csharp/protos/unittest_issues.proto                                        \
   csharp/protos/unittest_issues.proto                                        \
   csharp/src/AddressBook/AddPerson.cs                                        \
   csharp/src/AddressBook/AddPerson.cs                                        \
-  csharp/src/AddressBook/AddressBook.csproj                                  \
   csharp/src/AddressBook/Addressbook.cs                                      \
   csharp/src/AddressBook/Addressbook.cs                                      \
+  csharp/src/AddressBook/AddressBook.xproj                                   \
   csharp/src/AddressBook/ListPeople.cs                                       \
   csharp/src/AddressBook/ListPeople.cs                                       \
   csharp/src/AddressBook/Program.cs                                          \
   csharp/src/AddressBook/Program.cs                                          \
-  csharp/src/AddressBook/Properties/AssemblyInfo.cs                          \
   csharp/src/AddressBook/SampleUsage.cs                                      \
   csharp/src/AddressBook/SampleUsage.cs                                      \
-  csharp/src/AddressBook/app.config                                          \
-  csharp/src/Google.Protobuf.Conformance/App.config                          \
+  csharp/src/AddressBook/project.json                                        \
   csharp/src/Google.Protobuf.Conformance/Conformance.cs                      \
   csharp/src/Google.Protobuf.Conformance/Conformance.cs                      \
-  csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj  \
+  csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj   \
   csharp/src/Google.Protobuf.Conformance/Program.cs                          \
   csharp/src/Google.Protobuf.Conformance/Program.cs                          \
-  csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs          \
-  csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj        \
+  csharp/src/Google.Protobuf.Conformance/project.json                        \
+  csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj         \
   csharp/src/Google.Protobuf.JsonDump/Program.cs                             \
   csharp/src/Google.Protobuf.JsonDump/Program.cs                             \
-  csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs             \
-  csharp/src/Google.Protobuf.JsonDump/app.config                             \
+  csharp/src/Google.Protobuf.JsonDump/project.json                           \
   csharp/src/Google.Protobuf.Test/ByteStringTest.cs                          \
   csharp/src/Google.Protobuf.Test/ByteStringTest.cs                          \
   csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs              \
   csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs              \
   csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \
   csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \
@@ -87,13 +84,11 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf.Test/EqualityTester.cs                          \
   csharp/src/Google.Protobuf.Test/EqualityTester.cs                          \
   csharp/src/Google.Protobuf.Test/FieldCodecTest.cs                          \
   csharp/src/Google.Protobuf.Test/FieldCodecTest.cs                          \
   csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs                    \
   csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs                    \
-  csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj                \
+  csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj                 \
   csharp/src/Google.Protobuf.Test/IssuesTest.cs                              \
   csharp/src/Google.Protobuf.Test/IssuesTest.cs                              \
   csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs                       \
   csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs                       \
   csharp/src/Google.Protobuf.Test/JsonParserTest.cs                          \
   csharp/src/Google.Protobuf.Test/JsonParserTest.cs                          \
   csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs                       \
   csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs                       \
-  csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml                 \
-  csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs                 \
   csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs              \
   csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs              \
   csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs              \
   csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs              \
   csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \
   csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \
@@ -110,7 +105,7 @@ csharp_EXTRA_DIST=                                                           \
   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             \
-  csharp/src/Google.Protobuf.Test/packages.config                            \
+  csharp/src/Google.Protobuf.Test/project.json                               \
   csharp/src/Google.Protobuf.sln                                             \
   csharp/src/Google.Protobuf.sln                                             \
   csharp/src/Google.Protobuf/ByteArray.cs                                    \
   csharp/src/Google.Protobuf/ByteArray.cs                                    \
   csharp/src/Google.Protobuf/ByteString.cs                                   \
   csharp/src/Google.Protobuf/ByteString.cs                                   \
@@ -124,8 +119,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs                 \
   csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs                 \
   csharp/src/Google.Protobuf/FieldCodec.cs                                   \
   csharp/src/Google.Protobuf/FieldCodec.cs                                   \
   csharp/src/Google.Protobuf/FrameworkPortability.cs                         \
   csharp/src/Google.Protobuf/FrameworkPortability.cs                         \
-  csharp/src/Google.Protobuf/Google.Protobuf.csproj                          \
-  csharp/src/Google.Protobuf/Google.Protobuf.nuspec                          \
+  csharp/src/Google.Protobuf/Google.Protobuf.xproj                           \
   csharp/src/Google.Protobuf/IDeepCloneable.cs                               \
   csharp/src/Google.Protobuf/IDeepCloneable.cs                               \
   csharp/src/Google.Protobuf/IMessage.cs                                     \
   csharp/src/Google.Protobuf/IMessage.cs                                     \
   csharp/src/Google.Protobuf/InvalidJsonException.cs                         \
   csharp/src/Google.Protobuf/InvalidJsonException.cs                         \
@@ -183,7 +177,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \
   csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \
   csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \
   csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \
   csharp/src/Google.Protobuf/WireFormat.cs                                   \
   csharp/src/Google.Protobuf/WireFormat.cs                                   \
-  csharp/src/Google.Protobuf/packages.config                                 \
+  csharp/src/Google.Protobuf/project.json                                    \
   csharp/src/packages/repositories.config
   csharp/src/packages/repositories.config
 
 
 java_EXTRA_DIST=                                                                   \
 java_EXTRA_DIST=                                                                   \

+ 6 - 3
appveyor.bat

@@ -19,9 +19,12 @@ goto :EOF
 :build_csharp
 :build_csharp
 echo Building C#
 echo Building C#
 cd csharp\src
 cd csharp\src
-nuget restore
-msbuild Google.Protobuf.sln /p:Platform="Any CPU" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
-nunit-console Google.Protobuf.Test\bin\%configuration%\Google.Protobuf.Test.dll || goto error
+dotnet restore
+dotnet build -c %configuration% Google.Protobuf Google.Protobuf.Test Google.Protobuf.Conformance || goto error
+
+echo Testing C#
+dotnet test -c %configuration% Google.Protobuf.Test || goto error
+
 goto :EOF
 goto :EOF
 
 
 :error
 :error

+ 6 - 0
appveyor.yml

@@ -14,10 +14,16 @@ environment:
 
 
     - language: csharp
     - language: csharp
 
 
+# Our build scripts run tests automatically; we don't want AppVeyor
+# to try to detect them itself.
+test: off
+
 install:
 install:
   - ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
   - ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
   - 7z x gmock-1.7.0.zip
   - 7z x gmock-1.7.0.zip
   - rename gmock-1.7.0 gmock
   - rename gmock-1.7.0 gmock
+  - ps: Start-FileDownload https://go.microsoft.com/fwlink/?LinkID=809122 -FileName dotnetsdk.exe
+  - dotnetsdk.exe /install /quiet /norestart
 
 
 before_build:
 before_build:
   - if %platform%==Win32 set generator=Visual Studio 12
   - if %platform%==Win32 set generator=Visual Studio 12

+ 1 - 1
conformance/Makefile.am

@@ -246,7 +246,7 @@ conformance-java-lite: javac_middleman_lite
 conformance-csharp: $(other_language_protoc_outputs)
 conformance-csharp: $(other_language_protoc_outputs)
 	@echo "Writing shortcut script conformance-csharp..."
 	@echo "Writing shortcut script conformance-csharp..."
 	@echo '#! /bin/sh' > conformance-csharp
 	@echo '#! /bin/sh' > conformance-csharp
-	@echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp
+	@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
 	@chmod +x conformance-csharp
 	@chmod +x conformance-csharp
 
 
 # Targets for actually running tests.
 # Targets for actually running tests.

+ 8 - 13
csharp/.gitignore

@@ -1,16 +1,10 @@
-#
-# 	Untracked directories
-#
-src/AddressBook/bin
-src/AddressBook/obj
-src/Google.Protobuf/bin/
-src/Google.Protobuf/obj/
-src/Google.Protobuf.Conformance/bin/
-src/Google.Protobuf.Conformance/obj/
-src/Google.Protobuf.Test/bin/
-src/Google.Protobuf.Test/obj/
-src/Google.Protobuf.JsonDump/bin/
-src/Google.Protobuf.JsonDump/obj/
+# Output
+bin
+obj
+project.lock.json
+TestResult.xml
+
+# Possibly legacy now?
 mono/bin
 mono/bin
 mono/tmp
 mono/tmp
 mono/protoc
 mono/protoc
@@ -23,6 +17,7 @@ lib/NUnit
 #
 #
 # 	Untracked files
 # 	Untracked files
 #
 #
+.vs
 *.user
 *.user
 *.suo
 *.suo
 *.nupkg
 *.nupkg

+ 2 - 5
csharp/build_packages.bat

@@ -1,10 +1,7 @@
 @rem Builds Google.Protobuf NuGet packages
 @rem Builds Google.Protobuf NuGet packages
 
 
-@rem Adjust the location of nuget.exe
-set NUGET=C:\nuget\nuget.exe
-
-@rem Build src/Google.Protobuf.sln solution in Release configuration first.
-%NUGET% pack src\Google.Protobuf\Google.Protobuf.nuspec -Symbols || goto :error
+dotnet restore src
+dotnet pack -c Release src\Google.Protobuf || goto :error
 
 
 goto :EOF
 goto :EOF
 
 

+ 7 - 8
csharp/buildall.sh

@@ -1,17 +1,16 @@
 #!/bin/bash
 #!/bin/bash
-# Use mono to build solution and run all tests.
 
 
-# Adjust these to reflect the location of nunit-console in your system.
-NUNIT_CONSOLE=nunit-console
-
-# The rest you can leave intact
 CONFIG=Release
 CONFIG=Release
 SRC=$(dirname $0)/src
 SRC=$(dirname $0)/src
 
 
 set -ex
 set -ex
 
 
-echo Building the solution.
-xbuild /p:Configuration=$CONFIG $SRC/Google.Protobuf.sln
+echo Building relevant projects.
+dotnet build -c $CONFIG $SRC/Google.Protobuf $SRC/Google.Protobuf.Test $SRC/Google.Protobuf.Conformance
 
 
 echo Running tests.
 echo Running tests.
-$NUNIT_CONSOLE $SRC/Google.Protobuf.Test/bin/$CONFIG/Google.Protobuf.Test.dll
+# 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

+ 0 - 75
csharp/src/AddressBook/AddressBook.csproj

@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{A31F5FB2-4FF3-432A-B35B-5CD203606311}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Google.Protobuf.Examples.AddressBook</RootNamespace>
-    <AssemblyName>AddressBook</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="mscorlib" />
-    <Reference Include="System" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="AddPerson.cs" />
-    <Compile Include="Addressbook.cs" />
-    <Compile Include="SampleUsage.cs" />
-    <Compile Include="ListPeople.cs" />
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
-      <Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
-      <Name>Google.Protobuf</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="app.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 19 - 0
csharp/src/AddressBook/AddressBook.xproj

@@ -0,0 +1,19 @@
+<?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>

+ 0 - 18
csharp/src/AddressBook/Properties/AssemblyInfo.cs

@@ -1,18 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("AddressBook")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("AddressBook")]
-[assembly: AssemblyCopyright("Copyright ©  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyVersion("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]

+ 1 - 1
csharp/src/AddressBook/SampleUsage.cs

@@ -66,7 +66,7 @@ namespace Google.Protobuf.Examples.AddressBook
             // The message performs a deep-comparison on equality:
             // The message performs a deep-comparison on equality:
             if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
             if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
             {
             {
-                throw new ApplicationException("There is a bad person in here!");
+                throw new Exception("There is a bad person in here!");
             }
             }
         }
         }
     }
     }

+ 0 - 3
csharp/src/AddressBook/app.config

@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<configuration>
-	<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

+ 20 - 0
csharp/src/AddressBook/project.json

@@ -0,0 +1,20 @@
+{
+  "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"
+        }
+      }
+    }
+  }
+}

+ 0 - 6
csharp/src/Google.Protobuf.Conformance/App.config

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
-    </startup>
-</configuration>

+ 0 - 61
csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj

@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{0607D1B8-80D6-4B35-9857-1263C1B32B94}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Google.Protobuf.Conformance</RootNamespace>
-    <AssemblyName>Google.Protobuf.Conformance</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="Microsoft.CSharp" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Conformance.cs" />
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
-      <Project>{6908bdce-d925-43f3-94ac-a531e6df2591}</Project>
-      <Name>Google.Protobuf</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 19 - 0
csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj

@@ -0,0 +1,19 @@
+<?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>

+ 0 - 48
csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs

@@ -1,48 +0,0 @@
-#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 System.Reflection;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Google.Protobuf.Conformance")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Google.Protobuf.Conformance")]
-[assembly: AssemblyCopyright("Copyright ©  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyVersion("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]

+ 19 - 0
csharp/src/Google.Protobuf.Conformance/project.json

@@ -0,0 +1,19 @@
+{
+  "buildOptions": {
+    "debugType": "portable",
+    "emitEntryPoint": true
+  },
+  "dependencies": {
+    "Google.Protobuf": { "target": "project" }
+  },
+  "frameworks": {
+    "netcoreapp1.0": {
+      "dependencies": {
+        "Microsoft.NETCore.App": {
+          "type": "platform",
+          "version": "1.0.0"
+        }
+      }
+    }
+  }
+}

+ 0 - 68
csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj

@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{D7282E99-2DC3-405B-946F-177DB2FD2AE2}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Google.Protobuf.JsonDump</RootNamespace>
-    <AssemblyName>Google.Protobuf.JsonDump</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="mscorlib" />
-    <Reference Include="System" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
-      <Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
-      <Name>Google.Protobuf</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="app.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 19 - 0
csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj

@@ -0,0 +1,19 @@
+<?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>

+ 2 - 1
csharp/src/Google.Protobuf.JsonDump/Program.cs

@@ -32,6 +32,7 @@
 
 
 using System;
 using System;
 using System.IO;
 using System.IO;
+using System.Reflection;
 
 
 namespace Google.Protobuf.ProtoDump
 namespace Google.Protobuf.ProtoDump
 {
 {
@@ -55,7 +56,7 @@ namespace Google.Protobuf.ProtoDump
                 Console.Error.WriteLine("Unable to load type {0}.", args[0]);
                 Console.Error.WriteLine("Unable to load type {0}.", args[0]);
                 return 1;
                 return 1;
             }
             }
-            if (!typeof(IMessage).IsAssignableFrom(type))
+            if (!typeof(IMessage).GetTypeInfo().IsAssignableFrom(type))
             {
             {
                 Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
                 Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
                 return 1;
                 return 1;

+ 0 - 19
csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs

@@ -1,19 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("ProtoDump")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("ProtoDump")]
-[assembly: AssemblyCopyright("Copyright ©  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyVersion("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]

+ 0 - 3
csharp/src/Google.Protobuf.JsonDump/app.config

@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

+ 19 - 0
csharp/src/Google.Protobuf.JsonDump/project.json

@@ -0,0 +1,19 @@
+{
+  "buildOptions": {
+    "debugType": "portable",
+    "emitEntryPoint": true
+  },
+  "dependencies": {
+    "Google.Protobuf": { "target": "project" }
+  },
+  "frameworks": {
+    "netcoreapp1.0": {
+      "dependencies": {
+        "Microsoft.NETCore.App": {
+          "type": "platform",
+          "version": "1.0.0"
+        }
+      }
+    }
+  }
+}

+ 88 - 2
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs

@@ -75,10 +75,96 @@ namespace Google.Protobuf.Collections
         }
         }
 
 
         [Test]
         [Test]
-        public void Add_RepeatedField()
+        public void AddRange_SlowPath()
+        {
+            var list = new RepeatedField<string>();
+            list.AddRange(new[] { "foo", "bar" }.Select(x => x));
+            Assert.AreEqual(2, list.Count);
+            Assert.AreEqual("foo", list[0]);
+            Assert.AreEqual("bar", list[1]);
+        }
+
+        [Test]
+        public void AddRange_SlowPath_NullsProhibited_ReferenceType()
+        {
+            var list = new RepeatedField<string>();
+            // It's okay for this to throw ArgumentNullException if necessary.
+            // It's not ideal, but not awful.
+            Assert.Catch<ArgumentException>(() => list.AddRange(new[] { "foo", null }.Select(x => x)));
+        }
+
+        [Test]
+        public void AddRange_SlowPath_NullsProhibited_NullableValueType()
+        {
+            var list = new RepeatedField<int?>();
+            // It's okay for this to throw ArgumentNullException if necessary.
+            // It's not ideal, but not awful.
+            Assert.Catch<ArgumentException>(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x)));
+        }
+
+        [Test]
+        public void AddRange_Optimized_NonNullableValueType()
+        {
+            var list = new RepeatedField<int>();
+            list.AddRange(new List<int> { 20, 30 });
+            Assert.AreEqual(2, list.Count);
+            Assert.AreEqual(20, list[0]);
+            Assert.AreEqual(30, list[1]);
+        }
+
+        [Test]
+        public void AddRange_Optimized_ReferenceType()
+        {
+            var list = new RepeatedField<string>();
+            list.AddRange(new List<string> { "foo", "bar" });
+            Assert.AreEqual(2, list.Count);
+            Assert.AreEqual("foo", list[0]);
+            Assert.AreEqual("bar", list[1]);
+        }
+
+        [Test]
+        public void AddRange_Optimized_NullableValueType()
+        {
+            var list = new RepeatedField<int?>();
+            list.AddRange(new List<int?> { 20, 30 });
+            Assert.AreEqual(2, list.Count);
+            Assert.AreEqual((int?) 20, list[0]);
+            Assert.AreEqual((int?) 30, list[1]);
+        }
+
+        [Test]
+        public void AddRange_Optimized_NullsProhibited_ReferenceType()
+        {
+            // We don't just trust that a collection with a nullable element type doesn't contain nulls
+            var list = new RepeatedField<string>();
+            // It's okay for this to throw ArgumentNullException if necessary.
+            // It's not ideal, but not awful.
+            Assert.Catch<ArgumentException>(() => list.AddRange(new List<string> { "foo", null }));
+        }
+
+        [Test]
+        public void AddRange_Optimized_NullsProhibited_NullableValueType()
+        {
+            // We don't just trust that a collection with a nullable element type doesn't contain nulls
+            var list = new RepeatedField<int?>();
+            // It's okay for this to throw ArgumentNullException if necessary.
+            // It's not ideal, but not awful.
+            Assert.Catch<ArgumentException>(() => list.AddRange(new List<int?> { 20, null }));
+        }
+
+        [Test]
+        public void AddRange_AlreadyNotEmpty()
+        {
+            var list = new RepeatedField<int> { 1, 2, 3 };
+            list.AddRange(new List<int> { 4, 5, 6 });
+            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list);
+        }
+
+        [Test]
+        public void AddRange_RepeatedField()
         {
         {
             var list = new RepeatedField<string> { "original" };
             var list = new RepeatedField<string> { "original" };
-            list.Add(new RepeatedField<string> { "foo", "bar" });
+            list.AddRange(new RepeatedField<string> { "foo", "bar" });
             Assert.AreEqual(3, list.Count);
             Assert.AreEqual(3, list.Count);
             Assert.AreEqual("original", list[0]);
             Assert.AreEqual("original", list[0]);
             Assert.AreEqual("foo", list[1]);
             Assert.AreEqual("foo", list[1]);

+ 2 - 1
csharp/src/Google.Protobuf.Test/FieldCodecTest.cs

@@ -32,6 +32,7 @@
 
 
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
+using System.Reflection;
 using Google.Protobuf.TestProtos;
 using Google.Protobuf.TestProtos;
 using NUnit.Framework;
 using NUnit.Framework;
 
 
@@ -162,7 +163,7 @@ namespace Google.Protobuf
                 codedOutput.Flush();
                 codedOutput.Flush();
                 Assert.AreEqual(0, stream.Position);
                 Assert.AreEqual(0, stream.Position);
                 Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue));
                 Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue));
-                if (typeof(T).IsValueType)
+                if (typeof(T).GetTypeInfo().IsValueType)
                 {
                 {
                     Assert.AreEqual(default(T), codec.DefaultValue);
                     Assert.AreEqual(default(T), codec.DefaultValue);
                 }
                 }

+ 0 - 143
csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj

@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{DD01ED24-3750-4567-9A23-1DB676A15610}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Google.Protobuf</RootNamespace>
-    <AssemblyName>Google.Protobuf.Test</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <OldToolsVersion>3.5</OldToolsVersion>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-    <NuGetPackageImportStamp>
-    </NuGetPackageImportStamp>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
-    <DefineConstants>DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
-    <DefineConstants>TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\ReleaseSigned</OutputPath>
-    <IntermediateOutputPath>obj\ReleaseSigned\</IntermediateOutputPath>
-    <DefineConstants>TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <Prefer32Bit>false</Prefer32Bit>
-    <SignAssembly>True</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\keys\Google.Protobuf.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="mscorlib" />
-    <Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="ByteStringTest.cs" />
-    <Compile Include="CodedInputStreamExtensions.cs" />
-    <Compile Include="CodedInputStreamTest.cs" />
-    <Compile Include="CodedOutputStreamTest.cs" />
-    <Compile Include="Compatibility\PropertyInfoExtensionsTest.cs" />
-    <Compile Include="Compatibility\TypeExtensionsTest.cs" />
-    <Compile Include="EqualityTester.cs" />
-    <Compile Include="FieldCodecTest.cs" />
-    <Compile Include="GeneratedMessageTest.cs" />
-    <Compile Include="Collections\MapFieldTest.cs" />
-    <Compile Include="Collections\RepeatedFieldTest.cs" />
-    <Compile Include="JsonFormatterTest.cs" />
-    <Compile Include="JsonParserTest.cs" />
-    <Compile Include="JsonTokenizerTest.cs" />
-    <Compile Include="Reflection\DescriptorsTest.cs" />
-    <Compile Include="Reflection\FieldAccessTest.cs" />
-    <Compile Include="Reflection\TypeRegistryTest.cs" />
-    <Compile Include="SampleEnum.cs" />
-    <Compile Include="SampleMessages.cs" />
-    <Compile Include="TestProtos\ForeignMessagePartial.cs" />
-    <Compile Include="TestProtos\MapUnittestProto3.cs" />
-    <Compile Include="TestProtos\UnittestImportProto3.cs" />
-    <Compile Include="TestProtos\UnittestImportPublicProto3.cs" />
-    <Compile Include="TestProtos\UnittestIssues.cs" />
-    <Compile Include="TestProtos\UnittestProto3.cs" />
-    <Compile Include="DeprecatedMemberTest.cs" />
-    <Compile Include="IssuesTest.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="TestCornerCases.cs" />
-    <Compile Include="TestProtos\UnittestWellKnownTypes.cs" />
-    <Compile Include="WellKnownTypes\AnyTest.cs" />
-    <Compile Include="WellKnownTypes\DurationTest.cs" />
-    <Compile Include="WellKnownTypes\FieldMaskTest.cs" />
-    <Compile Include="WellKnownTypes\TimestampTest.cs" />
-    <Compile Include="WellKnownTypes\WrappersTest.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
-      <Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
-      <Name>Google.Protobuf</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
-  </ItemGroup>
-  <ItemGroup />
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 19 - 0
csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj

@@ -0,0 +1,19 @@
+<?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>

+ 0 - 6
csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml

@@ -1,6 +0,0 @@
-<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
->
-    <Deployment.Parts>
-    </Deployment.Parts>
-</Deployment>

+ 0 - 20
csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs

@@ -1,20 +0,0 @@
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("Google.Protobuf.Test")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Google.Protobuf.Test")]
-[assembly: AssemblyCopyright("Copyright ©  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: AssemblyVersion("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]

+ 1 - 1
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs

@@ -96,7 +96,7 @@ namespace Google.Protobuf.WellKnownTypes
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var any = Any.Pack(message);
             var any = Any.Pack(message);
             var text = any.ToString();
             var text = any.ToString();
-            Assert.That(text, Is.StringContaining("\"@value\": \"" + message.ToByteString().ToBase64() + "\""));
+            Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteString().ToBase64() + "\""));
         }
         }
 
 
         [Test]
         [Test]

+ 2 - 2
csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs

@@ -46,8 +46,8 @@ namespace Google.Protobuf.WellKnownTypes
             var mask = new FieldMask { Paths = { input } };
             var mask = new FieldMask { Paths = { input } };
             var text = mask.ToString();
             var text = mask.ToString();
             // More specific test below
             // More specific test below
-            Assert.That(text, Is.StringContaining("@warning"));
-            Assert.That(text, Is.StringContaining(input));
+            Assert.That(text, Does.Contain("@warning"));
+            Assert.That(text, Does.Contain(input));
         }
         }
 
 
         [Test]
         [Test]

+ 0 - 5
csharp/src/Google.Protobuf.Test/packages.config

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="NUnit" version="2.6.4" targetFramework="net45" userInstalled="true" />
-  <package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" userInstalled="true" />
-</packages>

+ 44 - 0
csharp/src/Google.Protobuf.Test/project.json

@@ -0,0 +1,44 @@
+{
+  "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"
+      }
+    }
+  }
+}

+ 27 - 38
csharp/src/Google.Protobuf.sln

@@ -1,54 +1,43 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2015
-VisualStudioVersion = 14.0.24720.0
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
 MinimumVisualStudioVersion = 14.0.24720.0
 MinimumVisualStudioVersion = 14.0.24720.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{6908BDCE-D925-43F3-94AC-A531E6DF2591}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AddressBook", "AddressBook\AddressBook.xproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{DD01ED24-3750-4567-9A23-1DB676A15610}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.xproj", "{9B576380-726D-4142-8238-60A43AB0E35A}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{A31F5FB2-4FF3-432A-B35B-5CD203606311}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.xproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.xproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{0607D1B8-80D6-4B35-9857-1263C1B32B94}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.xproj", "{9695E08F-9829-497D-B95C-B38F28D48690}"
 EndProject
 EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
 		Release|Any CPU = Release|Any CPU
 		Release|Any CPU = Release|Any CPU
-		ReleaseSigned|Any CPU = ReleaseSigned|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.Build.0 = Release|Any CPU
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
-		{6908BDCE-D925-43F3-94AC-A531E6DF2591}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
-		{DD01ED24-3750-4567-9A23-1DB676A15610}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.Release|Any CPU.Build.0 = Release|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
-		{A31F5FB2-4FF3-432A-B35B-5CD203606311}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.Build.0 = Release|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
-		{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Release|Any CPU.Build.0 = Release|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
-		{0607D1B8-80D6-4B35-9857-1263C1B32B94}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
+		{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 15 - 16
csharp/src/Google.Protobuf/Collections/MapField.cs

@@ -30,14 +30,13 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endregion
 #endregion
 
 
+using Google.Protobuf.Compatibility;
 using Google.Protobuf.Reflection;
 using Google.Protobuf.Reflection;
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using System.Text;
-using Google.Protobuf.Compatibility;
 
 
 namespace Google.Protobuf.Collections
 namespace Google.Protobuf.Collections
 {
 {
@@ -113,7 +112,7 @@ namespace Google.Protobuf.Collections
             // Validation of arguments happens in ContainsKey and the indexer
             // Validation of arguments happens in ContainsKey and the indexer
             if (ContainsKey(key))
             if (ContainsKey(key))
             {
             {
-                throw new ArgumentException("Key already exists in map", "key");
+                throw new ArgumentException("Key already exists in map", nameof(key));
             }
             }
             this[key] = value;
             this[key] = value;
         }
         }
@@ -125,7 +124,7 @@ namespace Google.Protobuf.Collections
         /// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
         /// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
         public bool ContainsKey(TKey key)
         public bool ContainsKey(TKey key)
         {
         {
-            ProtoPreconditions.CheckNotNullUnconstrained(key, "key");
+            ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
             return map.ContainsKey(key);
             return map.ContainsKey(key);
         }
         }
 
 
@@ -142,7 +141,7 @@ namespace Google.Protobuf.Collections
         /// <returns><c>true</c> if the map contained the given key before the entry was removed; <c>false</c> otherwise.</returns>
         /// <returns><c>true</c> if the map contained the given key before the entry was removed; <c>false</c> otherwise.</returns>
         public bool Remove(TKey key)
         public bool Remove(TKey key)
         {
         {
-            ProtoPreconditions.CheckNotNullUnconstrained(key, "key");
+            ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
             LinkedListNode<KeyValuePair<TKey, TValue>> node;
             LinkedListNode<KeyValuePair<TKey, TValue>> node;
             if (map.TryGetValue(key, out node))
             if (map.TryGetValue(key, out node))
             {
             {
@@ -190,7 +189,7 @@ namespace Google.Protobuf.Collections
         {
         {
             get
             get
             {
             {
-                ProtoPreconditions.CheckNotNullUnconstrained(key, "key");
+                ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
                 TValue value;
                 TValue value;
                 if (TryGetValue(key, out value))
                 if (TryGetValue(key, out value))
                 {
                 {
@@ -200,11 +199,11 @@ namespace Google.Protobuf.Collections
             }
             }
             set
             set
             {
             {
-                ProtoPreconditions.CheckNotNullUnconstrained(key, "key");
+                ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
                 // value == null check here is redundant, but avoids boxing.
                 // value == null check here is redundant, but avoids boxing.
                 if (value == null)
                 if (value == null)
                 {
                 {
-                    ProtoPreconditions.CheckNotNullUnconstrained(value, "value");
+                    ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value));
                 }
                 }
                 LinkedListNode<KeyValuePair<TKey, TValue>> node;
                 LinkedListNode<KeyValuePair<TKey, TValue>> node;
                 var pair = new KeyValuePair<TKey, TValue>(key, value);
                 var pair = new KeyValuePair<TKey, TValue>(key, value);
@@ -236,7 +235,7 @@ namespace Google.Protobuf.Collections
         /// <param name="entries">The entries to add to the map.</param>
         /// <param name="entries">The entries to add to the map.</param>
         public void Add(IDictionary<TKey, TValue> entries)
         public void Add(IDictionary<TKey, TValue> entries)
         {
         {
-            ProtoPreconditions.CheckNotNull(entries, "entries");
+            ProtoPreconditions.CheckNotNull(entries, nameof(entries));
             foreach (var pair in entries)
             foreach (var pair in entries)
             {
             {
                 Add(pair.Key, pair.Value);
                 Add(pair.Key, pair.Value);
@@ -315,7 +314,7 @@ namespace Google.Protobuf.Collections
         {
         {
             if (item.Key == null)
             if (item.Key == null)
             {
             {
-                throw new ArgumentException("Key is null", "item");
+                throw new ArgumentException("Key is null", nameof(item));
             }
             }
             LinkedListNode<KeyValuePair<TKey, TValue>> node;
             LinkedListNode<KeyValuePair<TKey, TValue>> node;
             if (map.TryGetValue(item.Key, out node) &&
             if (map.TryGetValue(item.Key, out node) &&
@@ -503,7 +502,7 @@ namespace Google.Protobuf.Collections
 
 
         void IDictionary.Remove(object key)
         void IDictionary.Remove(object key)
         {
         {
-            ProtoPreconditions.CheckNotNull(key, "key");
+            ProtoPreconditions.CheckNotNull(key, nameof(key));
             if (!(key is TKey))
             if (!(key is TKey))
             {
             {
                 return;
                 return;
@@ -532,7 +531,7 @@ namespace Google.Protobuf.Collections
         {
         {
             get
             get
             {
             {
-                ProtoPreconditions.CheckNotNull(key, "key");
+                ProtoPreconditions.CheckNotNull(key, nameof(key));
                 if (!(key is TKey))
                 if (!(key is TKey))
                 {
                 {
                     return null;
                     return null;
@@ -714,11 +713,11 @@ namespace Google.Protobuf.Collections
             {
             {
                 if (arrayIndex < 0)
                 if (arrayIndex < 0)
                 {
                 {
-                    throw new ArgumentOutOfRangeException("arrayIndex");
+                    throw new ArgumentOutOfRangeException(nameof(arrayIndex));
                 }
                 }
                 if (arrayIndex + Count  >= array.Length)
                 if (arrayIndex + Count  >= array.Length)
                 {
                 {
-                    throw new ArgumentException("Not enough space in the array", "array");
+                    throw new ArgumentException("Not enough space in the array", nameof(array));
                 }
                 }
                 foreach (var item in this)
                 foreach (var item in this)
                 {
                 {
@@ -745,11 +744,11 @@ namespace Google.Protobuf.Collections
             {
             {
                 if (index < 0)
                 if (index < 0)
                 {
                 {
-                    throw new ArgumentOutOfRangeException("index");
+                    throw new ArgumentOutOfRangeException(nameof(index));
                 }
                 }
                 if (index + Count >= array.Length)
                 if (index + Count >= array.Length)
                 {
                 {
-                    throw new ArgumentException("Not enough space in the array", "array");
+                    throw new ArgumentException("Not enough space in the array", nameof(array));
                 }
                 }
                 foreach (var item in this)
                 foreach (var item in this)
                 {
                 {

+ 68 - 45
csharp/src/Google.Protobuf/Collections/RepeatedField.cs

@@ -34,7 +34,6 @@ using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
-using System.Text;
 
 
 namespace Google.Protobuf.Collections
 namespace Google.Protobuf.Collections
 {
 {
@@ -227,10 +226,7 @@ namespace Google.Protobuf.Collections
         /// <param name="item">The item to add.</param>
         /// <param name="item">The item to add.</param>
         public void Add(T item)
         public void Add(T item)
         {
         {
-            if (item == null)
-            {
-                throw new ArgumentNullException("item");
-            }
+            ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item));
             EnsureSize(count + 1);
             EnsureSize(count + 1);
             array[count++] = item;
             array[count++] = item;
         }
         }
@@ -285,46 +281,82 @@ namespace Google.Protobuf.Collections
         /// <summary>
         /// <summary>
         /// Gets the number of elements contained in the collection.
         /// Gets the number of elements contained in the collection.
         /// </summary>
         /// </summary>
-        public int Count { get { return count; } }
+        public int Count => count;
 
 
         /// <summary>
         /// <summary>
         /// Gets a value indicating whether the collection is read-only.
         /// Gets a value indicating whether the collection is read-only.
         /// </summary>
         /// </summary>
-        public bool IsReadOnly { get { return false; } }
-
-        // TODO: Remove this overload and just handle it in the one below, at execution time?
+        public bool IsReadOnly => false;
 
 
         /// <summary>
         /// <summary>
         /// Adds all of the specified values into this collection.
         /// Adds all of the specified values into this collection.
         /// </summary>
         /// </summary>
         /// <param name="values">The values to add to this collection.</param>
         /// <param name="values">The values to add to this collection.</param>
-        public void Add(RepeatedField<T> values)
+        public void AddRange(IEnumerable<T> values)
         {
         {
-            if (values == null)
+            ProtoPreconditions.CheckNotNull(values, nameof(values));
+
+            // Optimization 1: If the collection we're adding is already a RepeatedField<T>,
+            // we know the values are valid.
+            var otherRepeatedField = values as RepeatedField<T>;
+            if (otherRepeatedField != null)
             {
             {
-                throw new ArgumentNullException("values");
+                EnsureSize(count + otherRepeatedField.count);
+                Array.Copy(otherRepeatedField.array, 0, array, count, otherRepeatedField.count);
+                count += otherRepeatedField.count;
+                return;
+            }
+
+            // Optimization 2: The collection is an ICollection, so we can expand
+            // just once and ask the collection to copy itself into the array.
+            var collection = values as ICollection;
+            if (collection != null)
+            {
+                var extraCount = collection.Count;
+                // For reference types and nullable value types, we need to check that there are no nulls
+                // present. (This isn't a thread-safe approach, but we don't advertise this is thread-safe.)
+                // We expect the JITter to optimize this test to true/false, so it's effectively conditional
+                // specialization.
+                if (default(T) == null)
+                {
+                    // TODO: Measure whether iterating once to check and then letting the collection copy
+                    // itself is faster or slower than iterating and adding as we go. For large
+                    // collections this will not be great in terms of cache usage... but the optimized
+                    // copy may be significantly faster than doing it one at a time.
+                    foreach (var item in collection)
+                    {
+                        if (item == null)
+                        {
+                            throw new ArgumentException("Sequence contained null element", nameof(values));
+                        }
+                    }
+                }
+                EnsureSize(count + extraCount);
+                collection.CopyTo(array, count);
+                count += extraCount;
+                return;
+            }
+
+            // We *could* check for ICollection<T> as well, but very very few collections implement
+            // ICollection<T> but not ICollection. (HashSet<T> does, for one...)
+
+            // Fall back to a slower path of adding items one at a time.
+            foreach (T item in values)
+            {
+                Add(item);
             }
             }
-            EnsureSize(count + values.count);
-            // We know that all the values will be valid, because it's a RepeatedField.
-            Array.Copy(values.array, 0, array, count, values.count);
-            count += values.count;
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Adds all of the specified values into this collection.
+        /// Adds all of the specified values into this collection. This method is present to
+        /// allow repeated fields to be constructed from queries within collection initializers.
+        /// Within non-collection-initializer code, consider using the equivalent <see cref="AddRange"/>
+        /// method instead for clarity.
         /// </summary>
         /// </summary>
         /// <param name="values">The values to add to this collection.</param>
         /// <param name="values">The values to add to this collection.</param>
         public void Add(IEnumerable<T> values)
         public void Add(IEnumerable<T> values)
         {
         {
-            if (values == null)
-            {
-                throw new ArgumentNullException("values");
-            }
-            // TODO: Check for ICollection and get the Count, to optimize?
-            foreach (T item in values)
-            {
-                Add(item);
-            }
+            AddRange(values);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -418,10 +450,7 @@ namespace Google.Protobuf.Collections
         /// <returns>The zero-based index of the item, or -1 if it is not found.</returns>
         /// <returns>The zero-based index of the item, or -1 if it is not found.</returns>
         public int IndexOf(T item)
         public int IndexOf(T item)
         {
         {
-            if (item == null)
-            {
-                throw new ArgumentNullException("item");
-            }
+            ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item));
             EqualityComparer<T> comparer = EqualityComparer<T>.Default;
             EqualityComparer<T> comparer = EqualityComparer<T>.Default;
             for (int i = 0; i < count; i++)
             for (int i = 0; i < count; i++)
             {
             {
@@ -440,13 +469,10 @@ namespace Google.Protobuf.Collections
         /// <param name="item">The item to insert.</param>
         /// <param name="item">The item to insert.</param>
         public void Insert(int index, T item)
         public void Insert(int index, T item)
         {
         {
-            if (item == null)
-            {
-                throw new ArgumentNullException("item");
-            }
+            ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item));
             if (index < 0 || index > count)
             if (index < 0 || index > count)
             {
             {
-                throw new ArgumentOutOfRangeException("index");
+                throw new ArgumentOutOfRangeException(nameof(index));
             }
             }
             EnsureSize(count + 1);
             EnsureSize(count + 1);
             Array.Copy(array, index, array, index + 1, count - index);
             Array.Copy(array, index, array, index + 1, count - index);
@@ -462,7 +488,7 @@ namespace Google.Protobuf.Collections
         {
         {
             if (index < 0 || index >= count)
             if (index < 0 || index >= count)
             {
             {
-                throw new ArgumentOutOfRangeException("index");
+                throw new ArgumentOutOfRangeException(nameof(index));
             }
             }
             Array.Copy(array, index + 1, array, index, count - index - 1);
             Array.Copy(array, index + 1, array, index, count - index - 1);
             count--;
             count--;
@@ -494,7 +520,7 @@ namespace Google.Protobuf.Collections
             {
             {
                 if (index < 0 || index >= count)
                 if (index < 0 || index >= count)
                 {
                 {
-                    throw new ArgumentOutOfRangeException("index");
+                    throw new ArgumentOutOfRangeException(nameof(index));
                 }
                 }
                 return array[index];
                 return array[index];
             }
             }
@@ -502,27 +528,24 @@ namespace Google.Protobuf.Collections
             {
             {
                 if (index < 0 || index >= count)
                 if (index < 0 || index >= count)
                 {
                 {
-                    throw new ArgumentOutOfRangeException("index");
-                }
-                if (value == null)
-                {
-                    throw new ArgumentNullException("value");
+                    throw new ArgumentOutOfRangeException(nameof(index));
                 }
                 }
+                ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value));
                 array[index] = value;
                 array[index] = value;
             }
             }
         }
         }
 
 
         #region Explicit interface implementation for IList and ICollection.
         #region Explicit interface implementation for IList and ICollection.
-        bool IList.IsFixedSize { get { return false; } }
+        bool IList.IsFixedSize => false;
 
 
         void ICollection.CopyTo(Array array, int index)
         void ICollection.CopyTo(Array array, int index)
         {
         {
             Array.Copy(this.array, 0, array, index, count);
             Array.Copy(this.array, 0, array, index, count);
         }
         }
 
 
-        bool ICollection.IsSynchronized { get { return false; } }
+        bool ICollection.IsSynchronized => false;
 
 
-        object ICollection.SyncRoot { get { return this; } }
+        object ICollection.SyncRoot => this;
 
 
         object IList.this[int index]
         object IList.this[int index]
         {
         {

+ 0 - 168
csharp/src/Google.Protobuf/Google.Protobuf.csproj

@@ -1,168 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Google.Protobuf</RootNamespace>
-    <AssemblyName>Google.Protobuf</AssemblyName>
-    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <OldToolsVersion>3.5</OldToolsVersion>
-    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
-    <NuGetPackageImportStamp>
-    </NuGetPackageImportStamp>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
-    <DocumentationFile>bin\Debug\Google.Protobuf.xml</DocumentationFile>
-    <NoWarn>
-    </NoWarn>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
-    <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
-    <NoWarn>
-    </NoWarn>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\ReleaseSigned</OutputPath>
-    <IntermediateOutputPath>obj\ReleaseSigned\</IntermediateOutputPath>
-    <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
-    <NoWarn>
-    </NoWarn>
-    <DefineConstants>TRACE;SIGNED</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoStdLib>true</NoStdLib>
-    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
-    <SignAssembly>True</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\keys\Google.Protobuf.snk</AssemblyOriginatorKeyFile>
-    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="mscorlib" />
-    <Reference Include="System" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="ByteArray.cs" />
-    <Compile Include="ByteString.cs" />
-    <Compile Include="CodedOutputStream.ComputeSize.cs" />
-    <Compile Include="CodedInputStream.cs" />
-    <Compile Include="CodedOutputStream.cs" />
-    <Compile Include="Collections\MapField.cs" />
-    <Compile Include="Collections\ReadOnlyDictionary.cs" />
-    <Compile Include="Collections\RepeatedField.cs" />
-    <Compile Include="Compatibility\PropertyInfoExtensions.cs" />
-    <Compile Include="Compatibility\TypeExtensions.cs" />
-    <Compile Include="FieldCodec.cs" />
-    <Compile Include="FrameworkPortability.cs" />
-    <Compile Include="ICustomDiagnosticMessage.cs" />
-    <Compile Include="IDeepCloneable.cs" />
-    <Compile Include="InvalidJsonException.cs" />
-    <Compile Include="JsonFormatter.cs" />
-    <Compile Include="JsonParser.cs" />
-    <Compile Include="JsonToken.cs" />
-    <Compile Include="JsonTokenizer.cs" />
-    <Compile Include="MessageExtensions.cs" />
-    <Compile Include="IMessage.cs" />
-    <Compile Include="InvalidProtocolBufferException.cs" />
-    <Compile Include="LimitedInputStream.cs" />
-    <Compile Include="MessageParser.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Reflection\Descriptor.cs" />
-    <Compile Include="Reflection\DescriptorBase.cs" />
-    <Compile Include="Reflection\DescriptorPool.cs" />
-    <Compile Include="Reflection\DescriptorUtil.cs" />
-    <Compile Include="Reflection\DescriptorValidationException.cs" />
-    <Compile Include="Reflection\EnumDescriptor.cs" />
-    <Compile Include="Reflection\EnumValueDescriptor.cs" />
-    <Compile Include="Reflection\FieldAccessorBase.cs" />
-    <Compile Include="Reflection\FieldDescriptor.cs" />
-    <Compile Include="Reflection\FieldType.cs" />
-    <Compile Include="Reflection\FileDescriptor.cs" />
-    <Compile Include="Reflection\GeneratedClrTypeInfo.cs" />
-    <Compile Include="Reflection\IDescriptor.cs" />
-    <Compile Include="Reflection\IFieldAccessor.cs" />
-    <Compile Include="Reflection\MapFieldAccessor.cs" />
-    <Compile Include="Reflection\MessageDescriptor.cs" />
-    <Compile Include="Reflection\MethodDescriptor.cs" />
-    <Compile Include="Reflection\OneofAccessor.cs" />
-    <Compile Include="Reflection\OneofDescriptor.cs" />
-    <Compile Include="Reflection\OriginalNameAttribute.cs" />
-    <Compile Include="Reflection\PackageDescriptor.cs" />
-    <Compile Include="Reflection\PartialClasses.cs" />
-    <Compile Include="Reflection\ReflectionUtil.cs" />
-    <Compile Include="Reflection\RepeatedFieldAccessor.cs" />
-    <Compile Include="Reflection\ServiceDescriptor.cs" />
-    <Compile Include="Reflection\SingleFieldAccessor.cs" />
-    <Compile Include="ProtoPreconditions.cs" />
-    <Compile Include="Reflection\TypeRegistry.cs" />
-    <Compile Include="WellKnownTypes\Any.cs" />
-    <Compile Include="WellKnownTypes\AnyPartial.cs" />
-    <Compile Include="WellKnownTypes\Api.cs" />
-    <Compile Include="WellKnownTypes\Duration.cs" />
-    <Compile Include="WellKnownTypes\DurationPartial.cs" />
-    <Compile Include="WellKnownTypes\Empty.cs" />
-    <Compile Include="WellKnownTypes\FieldMask.cs" />
-    <Compile Include="WellKnownTypes\FieldMaskPartial.cs" />
-    <Compile Include="WellKnownTypes\SourceContext.cs" />
-    <Compile Include="WellKnownTypes\Struct.cs" />
-    <Compile Include="WellKnownTypes\TimeExtensions.cs" />
-    <Compile Include="WellKnownTypes\Timestamp.cs" />
-    <Compile Include="WellKnownTypes\TimestampPartial.cs" />
-    <Compile Include="WellKnownTypes\Type.cs" />
-    <Compile Include="WellKnownTypes\ValuePartial.cs" />
-    <Compile Include="WellKnownTypes\Wrappers.cs" />
-    <Compile Include="WellKnownTypes\WrappersPartial.cs" />
-    <Compile Include="WireFormat.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="Google.Protobuf.nuspec" />
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup />
-  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
-  <Import Project="..\packages\NuSpec.ReferenceGenerator.1.4.1\build\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NuSpec.ReferenceGenerator.targets" Condition="Exists('..\packages\NuSpec.ReferenceGenerator.1.4.1\build\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NuSpec.ReferenceGenerator.targets')" />
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\NuSpec.ReferenceGenerator.1.4.1\build\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NuSpec.ReferenceGenerator.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NuSpec.ReferenceGenerator.1.4.1\build\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NuSpec.ReferenceGenerator.targets'))" />
-  </Target>
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 0 - 54
csharp/src/Google.Protobuf/Google.Protobuf.nuspec

@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<package>
-  <metadata>
-    <id>Google.Protobuf</id>
-    <title>Google Protocol Buffers C#</title>
-    <summary>C# runtime library for Protocol Buffers - Google's data interchange format.</summary>
-    <description>See project site for more info.</description>
-    <version>3.0.0-beta4</version>
-    <authors>Google Inc.</authors>
-    <owners>protobuf-packages</owners>
-    <licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
-    <projectUrl>https://github.com/google/protobuf</projectUrl>
-    <requireLicenseAcceptance>false</requireLicenseAcceptance>
-    <releaseNotes>C# proto3 support</releaseNotes>
-    <copyright>Copyright 2015, Google Inc.</copyright>
-    <tags>Protocol Buffers Binary Serialization Format Google proto proto3</tags>
-    <dependencies>
-      <!-- Dependencies for older, monolithic-assembly platforms -->
-      <group targetFramework="net45" />
-      <group targetFramework="wp8" />
-      <group targetFramework="win8" />
-      <group targetFramework="wpa81" />
-      <group targetFramework="xamarin.ios" />
-      <group targetFramework="monotouch" />
-      <group targetFramework="monoandroid" />
-      <!-- Dependencies for newer, more granular platforms (.NET Core etc) -->
-      <group targetFramework="dotnet">
-        <dependency id="System.Collections" version="4.0.0" />
-        <dependency id="System.Diagnostics.Debug" version="4.0.0" />
-        <dependency id="System.Globalization" version="4.0.0" />
-        <dependency id="System.IO" version="4.0.0" />
-        <dependency id="System.Linq" version="4.0.0" />
-        <dependency id="System.Linq.Expressions" version="4.0.0" />
-        <dependency id="System.ObjectModel" version="4.0.0" />
-        <dependency id="System.Reflection" version="4.0.0" />
-        <dependency id="System.Reflection.Extensions" version="4.0.0" />
-        <dependency id="System.Runtime" version="4.0.0" />
-        <dependency id="System.Runtime.Extensions" version="4.0.0" />
-        <dependency id="System.Text.Encoding" version="4.0.0" />
-        <dependency id="System.Text.RegularExpressions" version="4.0.0" />
-        <dependency id="System.Threading" version="4.0.0" />
-      </group>
-    </dependencies>
-  </metadata>
-  <files>
-    <file src="bin/ReleaseSigned/Google.Protobuf.dll" target="lib/portable-net45+netcore45+wpa81+wp8" />
-    <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/portable-net45+netcore45+wpa81+wp8" />
-    <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/portable-net45+netcore45+wpa81+wp8" />
-    <file src="bin/ReleaseSigned/Google.Protobuf.dll" target="lib/dotnet" />
-    <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/dotnet" />
-    <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/dotnet" />
-    <file src="**\*.cs" target="src" />
-  </files>
-</package>

+ 19 - 0
csharp/src/Google.Protobuf/Google.Protobuf.xproj

@@ -0,0 +1,19 @@
+<?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>

+ 0 - 18
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs

@@ -30,7 +30,6 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endregion
 #endregion
 
 
-using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Security;
 using System.Security;
 
 
@@ -38,30 +37,13 @@ using System.Security;
 // set of attributes. Change these attribute values to modify the information
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 // associated with an assembly.
 
 
-[assembly: AssemblyTitle("Google.Protobuf")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Google.Protobuf")]
-[assembly: AssemblyCopyright("Copyright ©  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
 #if !NCRUNCH
 #if !NCRUNCH
 [assembly: AllowPartiallyTrustedCallers]
 [assembly: AllowPartiallyTrustedCallers]
 #endif
 #endif
 
 
-#if SIGNED
 [assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" +
 [assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" +
     "002400000480000094000000060200000024000052534131000400000100010025800fbcfc63a1" +
     "002400000480000094000000060200000024000052534131000400000100010025800fbcfc63a1" +
     "7c66b303aae80b03a6beaa176bb6bef883be436f2a1579edd80ce23edf151a1f4ced97af83abcd" +
     "7c66b303aae80b03a6beaa176bb6bef883be436f2a1579edd80ce23edf151a1f4ced97af83abcd" +
     "981207041fd5b2da3b498346fcfcd94910d52f25537c4a43ce3fbe17dc7d43e6cbdb4d8f1242dc" +
     "981207041fd5b2da3b498346fcfcd94910d52f25537c4a43ce3fbe17dc7d43e6cbdb4d8f1242dc" +
     "b6bd9b5906be74da8daa7d7280f97130f318a16c07baf118839b156299a48522f9fae2371c9665" +
     "b6bd9b5906be74da8daa7d7280f97130f318a16c07baf118839b156299a48522f9fae2371c9665" +
     "c5ae9cb6")]
     "c5ae9cb6")]
-#else
-[assembly: InternalsVisibleTo("Google.Protobuf.Test")]
-#endif
-
-[assembly: AssemblyVersion("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]
-[assembly: AssemblyInformationalVersion("3.0.0-beta4")]

+ 0 - 4
csharp/src/Google.Protobuf/packages.config

@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="NuSpec.ReferenceGenerator" version="1.4.1" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
-</packages>

+ 65 - 0
csharp/src/Google.Protobuf/project.json

@@ -0,0 +1,65 @@
+{
+  "version": "3.0.0-beta4",
+  "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"
+      }
+    }
+  }
+}

+ 7 - 0
jenkins/docker/Dockerfile

@@ -23,6 +23,13 @@ run echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /e
   echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list && \
   echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list && \
   apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
   apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
 
 
+# Install dotnet SDK based on https://www.microsoft.com/net/core#debian
+# (Ubuntu instructions need apt to support https)
+RUN apt-get update && apt-get install -y curl libunwind8 gettext && \
+  curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=809130 && \
+  mkdir -p /opt/dotnet && tar zxf dotnet.tar.gz -C /opt/dotnet && \
+  ln -s /opt/dotnet/dotnet /usr/local/bin
+
 # Install dependencies.  We start with the basic ones require to build protoc
 # Install dependencies.  We start with the basic ones require to build protoc
 # and the C++ build
 # and the C++ build
 RUN apt-get update && apt-get install -y \
 RUN apt-get update && apt-get install -y \

+ 16 - 4
tests.sh

@@ -57,15 +57,27 @@ build_csharp() {
   if [ "$TRAVIS" == "true" ]; then
   if [ "$TRAVIS" == "true" ]; then
     # Install latest version of Mono
     # Install latest version of Mono
     sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
     sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
     echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
     echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
-    echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
     sudo apt-get update -qq
     sudo apt-get update -qq
     sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
     sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
-    wget www.nuget.org/NuGet.exe -O nuget.exe
-    NUGET=../../nuget.exe
+    
+    # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net.
+    sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
+    sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
+    sudo apt-get update -qq
+    sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121
   fi
   fi
 
 
-  (cd csharp/src; mono $NUGET restore)
+  # Perform "dotnet new" once to get the setup preprocessing out of the
+  # way. That spews a lot of output (including backspaces) into logs
+  # otherwise, and can cause problems. It doesn't matter if this step
+  # is performed multiple times; it's cheap after the first time anyway.
+  mkdir dotnettmp
+  (cd dotnettmp; dotnet new > /dev/null)
+  rm -rf dotnettmp
+
+  (cd csharp/src; dotnet restore)
   csharp/buildall.sh
   csharp/buildall.sh
   cd conformance && make test_csharp && cd ..
   cd conformance && make test_csharp && cd ..
 }
 }