diff options
Diffstat (limited to 'csharp')
39 files changed, 485 insertions, 852 deletions
diff --git a/csharp/.gitignore b/csharp/.gitignore index c88f741e..8ba88499 100644 --- a/csharp/.gitignore +++ b/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/tmp mono/protoc @@ -23,6 +17,7 @@ lib/NUnit # # Untracked files # +.vs *.user *.suo *.nupkg diff --git a/csharp/build_packages.bat b/csharp/build_packages.bat index 1502f063..37732e7c 100644 --- a/csharp/build_packages.bat +++ b/csharp/build_packages.bat @@ -1,10 +1,7 @@ @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 diff --git a/csharp/buildall.sh b/csharp/buildall.sh index 45af705f..cab32229 100755 --- a/csharp/buildall.sh +++ b/csharp/buildall.sh @@ -1,17 +1,16 @@ #!/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 SRC=$(dirname $0)/src 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. -$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 diff --git a/csharp/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj deleted file mode 100644 index 8f8ca7e2..00000000 --- a/csharp/src/AddressBook/AddressBook.csproj +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/AddressBook/AddressBook.xproj b/csharp/src/AddressBook/AddressBook.xproj new file mode 100644 index 00000000..4c9925e8 --- /dev/null +++ b/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>
\ No newline at end of file diff --git a/csharp/src/AddressBook/Properties/AssemblyInfo.cs b/csharp/src/AddressBook/Properties/AssemblyInfo.cs deleted file mode 100644 index 9cb014c0..00000000 --- a/csharp/src/AddressBook/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")]
diff --git a/csharp/src/AddressBook/SampleUsage.cs b/csharp/src/AddressBook/SampleUsage.cs index aaaedda4..941d865a 100644 --- a/csharp/src/AddressBook/SampleUsage.cs +++ b/csharp/src/AddressBook/SampleUsage.cs @@ -66,7 +66,7 @@ namespace Google.Protobuf.Examples.AddressBook // The message performs a deep-comparison on equality:
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!");
}
}
}
diff --git a/csharp/src/AddressBook/app.config b/csharp/src/AddressBook/app.config deleted file mode 100644 index a80813af..00000000 --- a/csharp/src/AddressBook/app.config +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0"?> -<configuration> - <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> diff --git a/csharp/src/AddressBook/project.json b/csharp/src/AddressBook/project.json new file mode 100644 index 00000000..c500bdc2 --- /dev/null +++ b/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" + } + } + } + } +} diff --git a/csharp/src/Google.Protobuf.Conformance/App.config b/csharp/src/Google.Protobuf.Conformance/App.config deleted file mode 100644 index 8e156463..00000000 --- a/csharp/src/Google.Protobuf.Conformance/App.config +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<configuration> - <startup> - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> - </startup> -</configuration>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj deleted file mode 100644 index 82f728d1..00000000 --- a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj b/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj new file mode 100644 index 00000000..99ff1465 --- /dev/null +++ b/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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs deleted file mode 100644 index d22e90fd..00000000 --- a/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")] diff --git a/csharp/src/Google.Protobuf.Conformance/project.json b/csharp/src/Google.Protobuf.Conformance/project.json new file mode 100644 index 00000000..84b23c45 --- /dev/null +++ b/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" + } + } + } + } +} diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj deleted file mode 100644 index ede1f778..00000000 --- a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj b/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj new file mode 100644 index 00000000..27095be5 --- /dev/null +++ b/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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/Program.cs b/csharp/src/Google.Protobuf.JsonDump/Program.cs index 99e60e90..296b2f3f 100644 --- a/csharp/src/Google.Protobuf.JsonDump/Program.cs +++ b/csharp/src/Google.Protobuf.JsonDump/Program.cs @@ -32,6 +32,7 @@ using System;
using System.IO;
+using System.Reflection;
namespace Google.Protobuf.ProtoDump
{
@@ -55,7 +56,7 @@ namespace Google.Protobuf.ProtoDump Console.Error.WriteLine("Unable to load type {0}.", args[0]);
return 1;
}
- if (!typeof(IMessage).IsAssignableFrom(type))
+ if (!typeof(IMessage).GetTypeInfo().IsAssignableFrom(type))
{
Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
return 1;
diff --git a/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs deleted file mode 100644 index d980b013..00000000 --- a/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")]
diff --git a/csharp/src/Google.Protobuf.JsonDump/app.config b/csharp/src/Google.Protobuf.JsonDump/app.config deleted file mode 100644 index 51278a45..00000000 --- a/csharp/src/Google.Protobuf.JsonDump/app.config +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> -<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> diff --git a/csharp/src/Google.Protobuf.JsonDump/project.json b/csharp/src/Google.Protobuf.JsonDump/project.json new file mode 100644 index 00000000..84b23c45 --- /dev/null +++ b/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" + } + } + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs index 8ed54cfb..6852f75f 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -75,10 +75,96 @@ namespace Google.Protobuf.Collections } [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" }; - list.Add(new RepeatedField<string> { "foo", "bar" }); + list.AddRange(new RepeatedField<string> { "foo", "bar" }); Assert.AreEqual(3, list.Count); Assert.AreEqual("original", list[0]); Assert.AreEqual("foo", list[1]); diff --git a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs index c616470e..0e2bad59 100644 --- a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs +++ b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.IO; +using System.Reflection; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -162,7 +163,7 @@ namespace Google.Protobuf codedOutput.Flush(); Assert.AreEqual(0, stream.Position); Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue)); - if (typeof(T).IsValueType) + if (typeof(T).GetTypeInfo().IsValueType) { Assert.AreEqual(default(T), codec.DefaultValue); } diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj deleted file mode 100644 index 4f37c5e2..00000000 --- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj new file mode 100644 index 00000000..a9a1cc04 --- /dev/null +++ b/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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml b/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml deleted file mode 100644 index a9552327..00000000 --- a/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml +++ /dev/null @@ -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>
diff --git a/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index d00acf85..00000000 --- a/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")]
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs index f21be7d9..4aecc998 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs @@ -96,7 +96,7 @@ namespace Google.Protobuf.WellKnownTypes var message = SampleMessages.CreateFullTestAllTypes(); var any = Any.Pack(message); var text = any.ToString(); - Assert.That(text, Is.StringContaining("\"@value\": \"" + message.ToByteString().ToBase64() + "\"")); + Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteString().ToBase64() + "\"")); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs index 89bc8275..1d9908b4 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs @@ -46,8 +46,8 @@ namespace Google.Protobuf.WellKnownTypes var mask = new FieldMask { Paths = { input } }; var text = mask.ToString(); // 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] diff --git a/csharp/src/Google.Protobuf.Test/packages.config b/csharp/src/Google.Protobuf.Test/packages.config deleted file mode 100644 index c7653992..00000000 --- a/csharp/src/Google.Protobuf.Test/packages.config +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/project.json b/csharp/src/Google.Protobuf.Test/project.json new file mode 100644 index 00000000..87b732c9 --- /dev/null +++ b/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" + } + } + } +}
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.sln b/csharp/src/Google.Protobuf.sln index 72d87f76..3c62bba3 100644 --- a/csharp/src/Google.Protobuf.sln +++ b/csharp/src/Google.Protobuf.sln @@ -1,54 +1,43 @@ 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
-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
-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
-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
-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
-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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
- ReleaseSigned|Any CPU = ReleaseSigned|Any CPU
EndGlobalSection
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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 053f7558..537ce261 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -30,14 +30,13 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Compatibility; using Google.Protobuf.Reflection; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using Google.Protobuf.Compatibility; namespace Google.Protobuf.Collections { @@ -113,7 +112,7 @@ namespace Google.Protobuf.Collections // Validation of arguments happens in ContainsKey and the indexer 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; } @@ -125,7 +124,7 @@ namespace Google.Protobuf.Collections /// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns> public bool ContainsKey(TKey key) { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(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> public bool Remove(TKey key) { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); LinkedListNode<KeyValuePair<TKey, TValue>> node; if (map.TryGetValue(key, out node)) { @@ -190,7 +189,7 @@ namespace Google.Protobuf.Collections { get { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); TValue value; if (TryGetValue(key, out value)) { @@ -200,11 +199,11 @@ namespace Google.Protobuf.Collections } set { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); // value == null check here is redundant, but avoids boxing. if (value == null) { - ProtoPreconditions.CheckNotNullUnconstrained(value, "value"); + ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value)); } LinkedListNode<KeyValuePair<TKey, TValue>> node; 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> public void Add(IDictionary<TKey, TValue> entries) { - ProtoPreconditions.CheckNotNull(entries, "entries"); + ProtoPreconditions.CheckNotNull(entries, nameof(entries)); foreach (var pair in entries) { Add(pair.Key, pair.Value); @@ -315,7 +314,7 @@ namespace Google.Protobuf.Collections { if (item.Key == null) { - throw new ArgumentException("Key is null", "item"); + throw new ArgumentException("Key is null", nameof(item)); } LinkedListNode<KeyValuePair<TKey, TValue>> node; if (map.TryGetValue(item.Key, out node) && @@ -503,7 +502,7 @@ namespace Google.Protobuf.Collections void IDictionary.Remove(object key) { - ProtoPreconditions.CheckNotNull(key, "key"); + ProtoPreconditions.CheckNotNull(key, nameof(key)); if (!(key is TKey)) { return; @@ -532,7 +531,7 @@ namespace Google.Protobuf.Collections { get { - ProtoPreconditions.CheckNotNull(key, "key"); + ProtoPreconditions.CheckNotNull(key, nameof(key)); if (!(key is TKey)) { return null; @@ -714,11 +713,11 @@ namespace Google.Protobuf.Collections { if (arrayIndex < 0) { - throw new ArgumentOutOfRangeException("arrayIndex"); + throw new ArgumentOutOfRangeException(nameof(arrayIndex)); } 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) { @@ -745,11 +744,11 @@ namespace Google.Protobuf.Collections { if (index < 0) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } 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) { diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index d1db856c..7bb56448 100644 --- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -34,7 +34,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; -using System.Text; namespace Google.Protobuf.Collections { @@ -227,10 +226,7 @@ namespace Google.Protobuf.Collections /// <param name="item">The item to add.</param> public void Add(T item) { - if (item == null) - { - throw new ArgumentNullException("item"); - } + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); EnsureSize(count + 1); array[count++] = item; } @@ -285,46 +281,82 @@ namespace Google.Protobuf.Collections /// <summary> /// Gets the number of elements contained in the collection. /// </summary> - public int Count { get { return count; } } + public int Count => count; /// <summary> /// Gets a value indicating whether the collection is read-only. /// </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> /// Adds all of the specified values into this collection. /// </summary> /// <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> - /// 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> /// <param name="values">The values to add to this collection.</param> 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> @@ -418,10 +450,7 @@ namespace Google.Protobuf.Collections /// <returns>The zero-based index of the item, or -1 if it is not found.</returns> public int IndexOf(T item) { - if (item == null) - { - throw new ArgumentNullException("item"); - } + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); EqualityComparer<T> comparer = EqualityComparer<T>.Default; for (int i = 0; i < count; i++) { @@ -440,13 +469,10 @@ namespace Google.Protobuf.Collections /// <param name="item">The item to insert.</param> public void Insert(int index, T item) { - if (item == null) - { - throw new ArgumentNullException("item"); - } + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); if (index < 0 || index > count) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); @@ -462,7 +488,7 @@ namespace Google.Protobuf.Collections { if (index < 0 || index >= count) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } Array.Copy(array, index + 1, array, index, count - index - 1); count--; @@ -494,7 +520,7 @@ namespace Google.Protobuf.Collections { if (index < 0 || index >= count) { - throw new ArgumentOutOfRangeException("index"); + throw new ArgumentOutOfRangeException(nameof(index)); } return array[index]; } @@ -502,27 +528,24 @@ namespace Google.Protobuf.Collections { 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; } } #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) { 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] { diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj deleted file mode 100644 index 5557612a..00000000 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec deleted file mode 100644 index e7b47ffb..00000000 --- a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec +++ /dev/null @@ -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> diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.xproj b/csharp/src/Google.Protobuf/Google.Protobuf.xproj new file mode 100644 index 00000000..c68e0db3 --- /dev/null +++ b/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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs index 1673edfb..9b179bd7 100644 --- a/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs +++ b/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs @@ -30,7 +30,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
-using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
@@ -38,30 +37,13 @@ using System.Security; // set of attributes. Change these attribute values to modify the information
// 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
[assembly: AllowPartiallyTrustedCallers]
#endif
-#if SIGNED
[assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" +
"002400000480000094000000060200000024000052534131000400000100010025800fbcfc63a1" +
"7c66b303aae80b03a6beaa176bb6bef883be436f2a1579edd80ce23edf151a1f4ced97af83abcd" +
"981207041fd5b2da3b498346fcfcd94910d52f25537c4a43ce3fbe17dc7d43e6cbdb4d8f1242dc" +
"b6bd9b5906be74da8daa7d7280f97130f318a16c07baf118839b156299a48522f9fae2371c9665" +
"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")]
diff --git a/csharp/src/Google.Protobuf/packages.config b/csharp/src/Google.Protobuf/packages.config deleted file mode 100644 index 40b8fd92..00000000 --- a/csharp/src/Google.Protobuf/packages.config +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf/project.json b/csharp/src/Google.Protobuf/project.json new file mode 100644 index 00000000..c8eae6d0 --- /dev/null +++ b/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" + } + } + } +} |