commit
9fd0f1526f
411 changed files with 34404 additions and 255904 deletions
@ -0,0 +1,29 @@ |
||||
setlocal |
||||
|
||||
IF %language%==cpp GOTO build_cpp |
||||
IF %language%==csharp GOTO build_csharp |
||||
|
||||
echo Unsupported language %language%. Exiting. |
||||
goto :error |
||||
|
||||
:build_cpp |
||||
echo Building C++ |
||||
mkdir build_msvc |
||||
cd build_msvc |
||||
cmake -G "%generator%" -DBUILD_SHARED_LIBS=%BUILD_DLL% ../cmake |
||||
msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error |
||||
cd %configuration% |
||||
tests.exe || goto error |
||||
goto :EOF |
||||
|
||||
:build_csharp |
||||
echo Building C# |
||||
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 |
||||
goto :EOF |
||||
|
||||
:error |
||||
echo Failed! |
||||
EXIT /b %ERRORLEVEL% |
@ -1,8 +0,0 @@ |
||||
@echo off |
||||
SET BUILD_TARGET=%~1 |
||||
SET BUILD_CONFIG=%~2 |
||||
|
||||
IF "%BUILD_TARGET%"=="" SET BUILD_TARGET=Rebuild |
||||
IF "%BUILD_CONFIG%"=="" SET BUILD_CONFIG=Debug |
||||
|
||||
CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo build.csproj /t:%BUILD_TARGET% /toolsversion:4.0 "/p:Configuration=%BUILD_CONFIG%" %3 %4 %5 %6 |
@ -1,122 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Clean |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_CleanFolder"> |
||||
<Message Importance="normal" Text="Removing temporary directory '$(CleanFolderDirectory)'"/> |
||||
<Error Text="Can not remove empty directory name." Condition=" '$(CleanFolderDirectory)' == '' " /> |
||||
|
||||
<Exec WorkingDirectory="$(MSBuildProjectDirectory)" Condition="Exists($(CleanFolderDirectory))" Outputs="@(Ignore)" |
||||
Command="MOVE /Y "$(CleanFolderDirectory)" "$(CleanFolderDirectory)-deleted" > NUL" /> |
||||
|
||||
<RemoveDir Directories="$(CleanFolderDirectory)-deleted" Condition="Exists('$(CleanFolderDirectory)-deleted')" /> |
||||
</Target> |
||||
|
||||
<Target Name="_CleanTempOutput"> |
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="CleanFolderDirectory=%(TempBuildFolder.Identity);" Targets="_CleanFolder" /> |
||||
</Target> |
||||
|
||||
<Target Name="_CleanAll" DependsOnTargets="_CleanTempOutput"> |
||||
<MakeDir Directories="$(BuildTempDirectory)" /> |
||||
<MakeDir Directories="$(BuildOutputDirectory)" /> |
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Build |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_CompileAll"> |
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;" Targets="_BuildAllConfigurations" /> |
||||
</Target> |
||||
|
||||
<Target Name="_BuildAllConfigurations"> |
||||
<MSBuild Properties="TargetVersion=cf20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=cf35;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=net20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=net35;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=net40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=sl20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=sl30;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=sl40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="TargetVersion=pl40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Tools |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_BuildTools"> |
||||
|
||||
<MSBuild Targets="Build" ToolsVersion="3.5" Projects="$(ProjectDirectory)\src\ProtocolBuffers.sln" Properties="Configuration=Release;Platform=Any CPU;" /> |
||||
<Copy SourceFiles="%(ToolsOutputItem.Identity)" DestinationFolder="$(BuildOutputDirectory)\tools" /> |
||||
|
||||
<Copy SourceFiles="$(LibDirectory)\NUnit-config\nunit-console.v2.0.config" DestinationFiles="$(NUnitExePath).config" /> |
||||
<Exec |
||||
WorkingDirectory="%(ToolsTestContainer.RootDir)%(ToolsTestContainer.Directory)" |
||||
Command=""$(NUnitExePath)" /nologo /noshadow "%(ToolsTestContainer.Identity)" /xml:"$(BuildTempDirectory)\%(ToolsTestContainer.Filename).xml"" /> |
||||
|
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For GenerateSource |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_GenerateProjects"> |
||||
<Exec Command=""$(CsProjectProjector)" csproj_templates src\ProtocolBuffersLibrary.sln" WorkingDirectory="$(ProjectDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_CleanTempSource"> |
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="CleanFolderDirectory=$(SourceTempDirectory);" Targets="_CleanFolder" /> |
||||
<MakeDir Directories="$(SourceTempDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_GenerateSource" DependsOnTargets="_CleanTempSource"> |
||||
<Message Importance="high" Text="Generating source from proto files" /> |
||||
<Exec Command=""$(ProtocExePath)" --proto_path=$(ProtosDirectory) --descriptor_set_out=compiled.pb @(Protos->'%(RelativeDir)%(Filename)%(Extension)', ' ')" WorkingDirectory="$(SourceTempDirectory)" /> |
||||
<Exec Command=""$(ProtogenExePath)" compiled.pb" WorkingDirectory="$(SourceTempDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_CopyGeneratedSource" DependsOnTargets="_GenerateSource"> |
||||
<Copy SourceFiles="%(GeneratedSource.Identity)" DestinationFiles="%(GeneratedSource.TargetDirectory)\%(GeneratedSource.Filename)%(GeneratedSource.Extension)" /> |
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Package |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_PackageAll"> |
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=_Publish;" Targets="_BuildAllConfigurations" /> |
||||
</Target> |
||||
|
||||
<Target Name="_GeneratePackage"> |
||||
<Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputPackage)\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" /> |
||||
<Exec Command=""$(ZipExePath)" a -tzip $(BuildTempDirectory)\$(PackageName)-binaries.zip * -x!*.pdb -r" WorkingDirectory="$(BuildOutputPackage)" /> |
||||
<Exec Command=""$(ZipExePath)" a -tzip $(BuildTempDirectory)\$(PackageName)-symbols.zip * -r" WorkingDirectory="$(BuildOutputPackage)" /> |
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Benchmark |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_RunBenchmarks"> |
||||
<ItemGroup> |
||||
<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,ProtoBench" /> |
||||
<BenchmarkParameter Include="google_message1.dat" /> |
||||
<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,ProtoBench" /> |
||||
<BenchmarkParameter Include="google_message1.dat" /> |
||||
<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,ProtoBench" /> |
||||
<BenchmarkParameter Include="google_message2.dat" /> |
||||
<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,ProtoBench" /> |
||||
<BenchmarkParameter Include="google_message2.dat" /> |
||||
</ItemGroup> |
||||
|
||||
<Message Text="Running ProtoBench.exe" /> |
||||
<Exec Command="ProtoBench.exe $(BenchmarkArgs) @(BenchmarkParameter->'%(Identity)', ' ') "/log:$(BenchmarkOutputFile)"" |
||||
WorkingDirectory="$(SourceDirectory)\ProtoBench\bin\NET35\Release" /> |
||||
|
||||
</Target> |
||||
|
||||
</Project> |
@ -1,59 +0,0 @@ |
||||
<?xml version="1.0"?> |
||||
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="nuspec.xsd"> |
||||
<metadata> |
||||
<id>Google.ProtocolBuffers</id> |
||||
<version>$version$</version> |
||||
<owners>Jon Skeet</owners> |
||||
<authors>Jon Skeet</authors> |
||||
<licenseUrl>http://code.google.com/p/protobuf-csharp-port/source/browse/license.txt</licenseUrl> |
||||
<projectUrl>http://code.google.com/p/protobuf-csharp-port/</projectUrl> |
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance> |
||||
<copyright>Copyright 2008 Google Inc. All rights reserved.</copyright> |
||||
<tags>Protocol Buffers Binary Serialization Format Google</tags> |
||||
|
||||
<title>Google.ProtocolBuffers</title> |
||||
<summary>A managed code generator and library for Google's data interchange format.</summary> |
||||
<description><![CDATA[ |
||||
Protocol Buffers is a binary serialization format and technology, released to the open source community by Google in 2008. |
||||
Its primary use is to produce small fast binary representations of a 'message' or object for serialization or transportation. |
||||
There are various implementations of Protocol Buffers in .NET. This project is a fairly close port of the Google Java implementation. |
||||
|
||||
There are two main parts: |
||||
|
||||
tools/protoc.exe, which takes the textual representation of the protocol buffer and turns it into a binary representation for use with ProtoGen.exe. |
||||
tools/ProtoGen.exe, which takes binary representations of protocol buffer descriptors (as generated by the "stock" protoc binary supplied by Google) and creates C# source code. This is only required at build time. |
||||
|
||||
lib/*/Google.ProtocolBuffers.dll, which is a supporting library. This is required at execution time. |
||||
lib/*/Google.ProtocolBuffers.Serialization.dll, a supplementary library that provides extensions for reading and writing protocol buffers to xml, json, and others. |
||||
|
||||
LINKS: |
||||
|
||||
Project Home - http://code.google.com/p/protobuf-csharp-port |
||||
Online Help - http://help.protobuffers.net |
||||
Developer Guide - http://code.google.com/apis/protocolbuffers/docs/overview.html |
||||
Language Guide - http://code.google.com/apis/protocolbuffers/docs/proto.html |
||||
|
||||
]]></description> |
||||
|
||||
<references> |
||||
<reference file="Google.ProtocolBuffers.dll"/> |
||||
<reference file="Google.ProtocolBuffers.Serialization.dll"/> |
||||
</references> |
||||
|
||||
</metadata> |
||||
<files> |
||||
<!-- Release Binaries --> |
||||
<file src="..\build_output\Release\**\Google.ProtocolBuffers.???" target="lib\" /> |
||||
<file src="..\build_output\Release\**\Google.ProtocolBuffers.Serialization.???" target="lib\" /> |
||||
<!-- Tools --> |
||||
<file src="..\build_output\tools\**\*" target="tools\" /> |
||||
<file src="..\build_output\protos\**\*" target="tools\" /> |
||||
<!-- Content --> |
||||
<file src="..\build_output\CHANGES.txt" target="tools\"/> |
||||
<file src="..\build_output\license.txt" target="tools\"/> |
||||
<file src="..\build_output\tools\protoc-license.txt" target="tools\"/> |
||||
<!-- Source --> |
||||
<file src="..\src\ProtocolBuffers\**\*.cs" target="src\ProtocolBuffers\"/> |
||||
<file src="..\src\ProtocolBuffers.Serialization\**\*.cs" target="src\ProtocolBuffers.Serialization\"/> |
||||
</files> |
||||
</package> |
@ -1,60 +0,0 @@ |
||||
<?xml version="1.0"?> |
||||
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="nuspec.xsd"> |
||||
<metadata> |
||||
<id>Google.ProtocolBuffersLite</id> |
||||
<version>$version$</version> |
||||
<owners>Jon Skeet</owners> |
||||
<authors>Jon Skeet</authors> |
||||
<licenseUrl>http://code.google.com/p/protobuf-csharp-port/source/browse/license.txt</licenseUrl> |
||||
<projectUrl>http://code.google.com/p/protobuf-csharp-port/</projectUrl> |
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance> |
||||
<copyright>Copyright 2008 Google Inc. All rights reserved.</copyright> |
||||
<tags>Protocol Buffers Binary Serialization Format Google</tags> |
||||
|
||||
<title>Google.ProtocolBuffersLite</title> |
||||
<summary>A managed code generator and library for Google's data interchange format.</summary> |
||||
<description><![CDATA[ |
||||
Protocol Buffers is a binary serialization format and technology, released to the open source community by Google in 2008. |
||||
Its primary use is to produce small fast binary representations of a 'message' or object for serialization or transportation. |
||||
There are various implementations of Protocol Buffers in .NET. This project is a fairly close port of the Google Java implementation. |
||||
|
||||
There are two main parts: |
||||
|
||||
tools/protoc.exe, which takes the textual representation of the protocol buffer and turns it into a binary representation for use with ProtoGen.exe. |
||||
tools/ProtoGen.exe, which takes binary representations of protocol buffer descriptors (as generated by the "stock" protoc binary supplied by Google) and creates C# source code. This is only required at build time. |
||||
|
||||
lib/*/Google.ProtocolBuffersLite.dll, which is a supporting library. This is required at execution time. |
||||
lib/*/Google.ProtocolBuffersLite.Serialization.dll, a supplementary library that provides extensions for reading and writing protocol buffers to xml, json, and others. |
||||
|
||||
LINKS: |
||||
|
||||
Project Home - http://code.google.com/p/protobuf-csharp-port |
||||
Online Help - http://help.protobuffers.net |
||||
Developer Guide - http://code.google.com/apis/protocolbuffers/docs/overview.html |
||||
Language Guide - http://code.google.com/apis/protocolbuffers/docs/proto.html |
||||
|
||||
]]></description> |
||||
|
||||
<references> |
||||
<reference file="Google.ProtocolBuffersLite.dll"/> |
||||
<reference file="Google.ProtocolBuffersLite.Serialization.dll"/> |
||||
</references> |
||||
|
||||
</metadata> |
||||
|
||||
<files> |
||||
<!-- Release Binaries --> |
||||
<file src="..\build_output\Release\**\Google.ProtocolBuffersLite.???" target="lib\" /> |
||||
<file src="..\build_output\Release\**\Google.ProtocolBuffersLite.Serialization.???" target="lib\" /> |
||||
<!-- Tools --> |
||||
<file src="..\build_output\tools\**\*" target="tools\" /> |
||||
<file src="..\build_output\protos\**\*" target="tools\" /> |
||||
<!-- Content --> |
||||
<file src="..\build_output\CHANGES.txt" target="tools\"/> |
||||
<file src="..\build_output\license.txt" target="tools\"/> |
||||
<file src="..\build_output\tools\protoc-license.txt" target="tools\"/> |
||||
<!-- Source --> |
||||
<file src="..\src\ProtocolBuffers\**\*.cs" target="src\ProtocolBuffers\"/> |
||||
<file src="..\src\ProtocolBuffers.Serialization\**\*.cs" target="src\ProtocolBuffers.Serialization\"/> |
||||
</files> |
||||
</package> |
@ -1,2 +0,0 @@ |
||||
@echo off |
||||
CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo build.csproj /toolsversion:4.0 /t:RunBenchmarks %1 %2 %3 %4 |
@ -1,20 +0,0 @@ |
||||
@echo off |
||||
SET BUILD_VERSION=%~1 |
||||
SET BUILD_TARGET=%~2 |
||||
SET BUILD_CONFIG=%~3 |
||||
|
||||
IF NOT "%BUILD_VERSION%"=="" GOTO RUN |
||||
ECHO. |
||||
ECHO Usage: build.bat platform [target] [config] [msbuild arguments] |
||||
ECHO. |
||||
ECHO - platform: CF20, CF35, NET20, NET35, NET40, PL40, SL20, SL30, or SL40 |
||||
ECHO - [target]: Rebuild, Clean, Build, Test, or Publish |
||||
ECHO - [config]: Debug or Release |
||||
ECHO. |
||||
EXIT /B 1 |
||||
|
||||
:RUN |
||||
IF "%BUILD_TARGET%"=="" SET BUILD_TARGET=Rebuild |
||||
IF "%BUILD_CONFIG%"=="" SET BUILD_CONFIG=Debug |
||||
|
||||
CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo target.csproj /toolsversion:4.0 %4 %5 %6 "/t:%BUILD_TARGET%" "/p:Configuration=%BUILD_CONFIG%;TargetVersion=%BUILD_VERSION%" |
@ -1,241 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
||||
<!-- build targets --> |
||||
<Target Name="Clean" DependsOnTargets="_CleanAll" /> |
||||
<Target Name="BuildTools" DependsOnTargets="_BuildTools" /> |
||||
<Target Name="GenerateProjects" DependsOnTargets="_GenerateProjects" /> |
||||
<Target Name="GenerateSource" DependsOnTargets="_GenerateSource;_CopyGeneratedSource" /> |
||||
<Target Name="RebuildSource" DependsOnTargets="Clean;BuildTools;GenerateSource" /> |
||||
<Target Name="Build" DependsOnTargets="GenerateProjects;BuildTools;GenerateSource;_CompileAll" /> |
||||
<Target Name="Rebuild" DependsOnTargets="Clean;Build" /> |
||||
<Target Name="GeneratePackage" DependsOnTargets="_PackageAll;_GeneratePackage" /> |
||||
<Target Name="FullBuild" DependsOnTargets="Rebuild;GeneratePackage" /> |
||||
<!-- misc targets --> |
||||
<Target Name="RunBenchmarks" DependsOnTargets="_CleanAll;_BuildTools;_RunBenchmarks" /> |
||||
|
||||
<PropertyGroup> |
||||
<ProjectName>Protocol Buffers</ProjectName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">Any CPU</Platform> |
||||
|
||||
<!--Directory Paths--> |
||||
<ProjectDirectory>$(MSBuildProjectDirectory)\..</ProjectDirectory> |
||||
<SourceDirectory>$(ProjectDirectory)\src</SourceDirectory> |
||||
<LibDirectory>$(ProjectDirectory)\lib</LibDirectory> |
||||
<ProtosDirectory>$(ProjectDirectory)\protos</ProtosDirectory> |
||||
|
||||
<SourceTempDirectory>$(ProjectDirectory)\build_temp\GeneratedSource</SourceTempDirectory> |
||||
<BuildTempDirectory>$(ProjectDirectory)\build_temp</BuildTempDirectory> |
||||
<BuildOutputDirectory>$(ProjectDirectory)\build_output</BuildOutputDirectory> |
||||
<BuildOutputPackage>$(BuildOutputDirectory)</BuildOutputPackage> |
||||
|
||||
<BenchmarkArgs>/v2 /fast /formats</BenchmarkArgs> |
||||
<BenchmarkOutputFile>$(BuildTempDirectory)\..\BenchmarkResults.txt</BenchmarkOutputFile> |
||||
<BenchmarkProtosDirectory>$(ProjectDirectory)\benchmarks</BenchmarkProtosDirectory> |
||||
|
||||
<PackageName Condition=" '$(PackageName)' == '' ">$(Configuration)</PackageName> |
||||
|
||||
<!--Tool Paths--> |
||||
<ProtocExePath>$(BuildOutputDirectory)\tools\protoc.exe</ProtocExePath> |
||||
<ProtogenExePath>$(BuildOutputDirectory)\tools\protogen.exe</ProtogenExePath> |
||||
<NUnitExePath>$(LibDirectory)\NUnit\tools\nunit-console.exe</NUnitExePath> |
||||
<CsProjectProjector>$(LibDirectory)\CsProjectProjector\CsProjectProjector.exe</CsProjectProjector> |
||||
<ZipExePath>$(LibDirectory)\7-Zip 9.20\7za.exe</ZipExePath> |
||||
|
||||
</PropertyGroup> |
||||
|
||||
<Import Project="Common.targets"/> |
||||
|
||||
<!-- Proto Files --> |
||||
<ItemGroup> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_issues.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_extras.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_full.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_lite.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_extras_xmltest.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_generic_services.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_rpc_interop.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\extest\unittest_rpc_interop_lite.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\descriptor.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\csharp_options.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_csharp_options.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_custom_options.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_embed_optimize_for.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_empty.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_import.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_import_lite.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_lite.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_lite_imports_nonlite.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_mset.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_no_generic_services.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_optimize_for.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\test\google_size.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\google\test\google_speed.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\tutorial\addressbook.proto" /> |
||||
<!-- for benchmark --> |
||||
<Protos Include="$(ProtosDirectory)\benchmarks\google_size.proto" /> |
||||
<Protos Include="$(ProtosDirectory)\benchmarks\google_speed.proto" /> |
||||
</ItemGroup> |
||||
<!-- Generated Source --> |
||||
<ItemGroup> |
||||
<!-- Main protos --> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\CSharpOptions.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers\DescriptorProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\DescriptorProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers\DescriptorProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
|
||||
<!-- Address book sample --> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\AddressBookProtos.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\AddressBook</TargetDirectory> |
||||
</GeneratedSource> |
||||
<!-- Unit test --> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestExtrasProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestExtrasIssuesProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestXmlSerializerTestProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestCSharpOptionsProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestCustomOptionsProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestEmbedOptimizeForProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestEmptyProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestImportLiteProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestImportProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestMessageSetProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestNoGenericServicesProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestOptimizeForProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestRpcInterop.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestRpcInteropLite.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestGenericServices.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<!-- Lite unit test --> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestExtrasFullProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestExtrasLiteProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestImportLiteProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestImportProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestLiteImportNonLiteProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestLiteProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestGoogleSizeProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestGoogleSpeedProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\GoogleSizeProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtoBench\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\GoogleSpeedProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtoBench\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestImportProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtoBench\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
<GeneratedSource Include="$(SourceTempDirectory)\UnitTestProtoFile.cs"> |
||||
<TargetDirectory>$(SourceDirectory)\ProtoBench\TestProtos</TargetDirectory> |
||||
</GeneratedSource> |
||||
</ItemGroup> |
||||
<!-- Package Items --> |
||||
<ItemGroup> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\CHANGES.txt" /> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\license.txt" /> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\protos\google\protobuf\descriptor.proto"> |
||||
<TargetDirectory>\protos\google\protobuf</TargetDirectory> |
||||
</StaticPackageItem> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\protos\google\protobuf\compiler\plugin.proto"> |
||||
<TargetDirectory>\protos\google\protobuf\compiler</TargetDirectory> |
||||
</StaticPackageItem> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\protos\google\protobuf\csharp_options.proto"> |
||||
<TargetDirectory>\protos\google\protobuf</TargetDirectory> |
||||
</StaticPackageItem> |
||||
<StaticPackageItem Include="$(ProjectDirectory)\protos\tutorial\addressbook.proto"> |
||||
<TargetDirectory>\protos\tutorial</TargetDirectory> |
||||
</StaticPackageItem> |
||||
</ItemGroup> |
||||
<!-- Tools --> |
||||
<ItemGroup> |
||||
<ToolsTestContainer Include="$(SourceDirectory)\ProtoGen.Test\bin\NET35\Release\Google.ProtocolBuffers.ProtoGen.Test.dll" /> |
||||
|
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtocolBuffers\bin\NET35\Release\Google.ProtocolBuffers.dll" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\NET35\Release\Google.ProtocolBuffers.Serialization.dll" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtoGen\bin\NET35\Release\ProtoGen.exe" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtoGen\bin\NET35\Release\ProtoGen.exe.config" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtoMunge\bin\NET35\Release\ProtoMunge.exe" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtoDump\bin\NET35\Release\ProtoDump.exe" /> |
||||
<ToolsOutputItem Include="$(SourceDirectory)\ProtoBench\bin\NET35\Release\ProtoBench.exe" /> |
||||
<ToolsOutputItem Include="$(LibDirectory)\protoc.exe" /> |
||||
<ToolsOutputItem Include="$(LibDirectory)\protoc-license.txt" /> |
||||
</ItemGroup> |
||||
<!-- Temporary Directories --> |
||||
<ItemGroup> |
||||
<TempBuildFolder Include="$(BuildTempDirectory)" /> |
||||
<TempBuildFolder Include="$(BuildOutputDirectory)" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\AddressBook\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\AddressBook\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoBench\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoBench\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers.Serialization\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers.Test\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffers.Test\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffersLite.Test\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtocolBuffersLite.Test\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoDump\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoDump\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoGen\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoGen\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoGen.Test\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoGen.Test\bin" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoMunge\obj" /> |
||||
<TempBuildFolder Include="$(SourceDirectory)\ProtoMunge\bin" /> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,248 +0,0 @@ |
||||
#!/usr/bin/env python |
||||
# |
||||
# Copyright 2006, 2007 Google Inc. All Rights Reserved. |
||||
# Author: danderson@google.com (David Anderson) |
||||
# |
||||
# Script for uploading files to a Google Code project. |
||||
# |
||||
# This is intended to be both a useful script for people who want to |
||||
# streamline project uploads and a reference implementation for |
||||
# uploading files to Google Code projects. |
||||
# |
||||
# To upload a file to Google Code, you need to provide a path to the |
||||
# file on your local machine, a small summary of what the file is, a |
||||
# project name, and a valid account that is a member or owner of that |
||||
# project. You can optionally provide a list of labels that apply to |
||||
# the file. The file will be uploaded under the same name that it has |
||||
# in your local filesystem (that is, the "basename" or last path |
||||
# component). Run the script with '--help' to get the exact syntax |
||||
# and available options. |
||||
# |
||||
# Note that the upload script requests that you enter your |
||||
# googlecode.com password. This is NOT your Gmail account password! |
||||
# This is the password you use on googlecode.com for committing to |
||||
# Subversion and uploading files. You can find your password by going |
||||
# to http://code.google.com/hosting/settings when logged in with your |
||||
# Gmail account. If you have already committed to your project's |
||||
# Subversion repository, the script will automatically retrieve your |
||||
# credentials from there (unless disabled, see the output of '--help' |
||||
# for details). |
||||
# |
||||
# If you are looking at this script as a reference for implementing |
||||
# your own Google Code file uploader, then you should take a look at |
||||
# the upload() function, which is the meat of the uploader. You |
||||
# basically need to build a multipart/form-data POST request with the |
||||
# right fields and send it to https://PROJECT.googlecode.com/files . |
||||
# Authenticate the request using HTTP Basic authentication, as is |
||||
# shown below. |
||||
# |
||||
# Licensed under the terms of the Apache Software License 2.0: |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Questions, comments, feature requests and patches are most welcome. |
||||
# Please direct all of these to the Google Code users group: |
||||
# http://groups.google.com/group/google-code-hosting |
||||
|
||||
"""Google Code file uploader script. |
||||
""" |
||||
|
||||
__author__ = 'danderson@google.com (David Anderson)' |
||||
|
||||
import httplib |
||||
import os.path |
||||
import optparse |
||||
import getpass |
||||
import base64 |
||||
import sys |
||||
|
||||
|
||||
def upload(file, project_name, user_name, password, summary, labels=None): |
||||
"""Upload a file to a Google Code project's file server. |
||||
|
||||
Args: |
||||
file: The local path to the file. |
||||
project_name: The name of your project on Google Code. |
||||
user_name: Your Google account name. |
||||
password: The googlecode.com password for your account. |
||||
Note that this is NOT your global Google Account password! |
||||
summary: A small description for the file. |
||||
labels: an optional list of label strings with which to tag the file. |
||||
|
||||
Returns: a tuple: |
||||
http_status: 201 if the upload succeeded, something else if an |
||||
error occured. |
||||
http_reason: The human-readable string associated with http_status |
||||
file_url: If the upload succeeded, the URL of the file on Google |
||||
Code, None otherwise. |
||||
""" |
||||
# The login is the user part of user@gmail.com. If the login provided |
||||
# is in the full user@domain form, strip it down. |
||||
if user_name.endswith('@gmail.com'): |
||||
user_name = user_name[:user_name.index('@gmail.com')] |
||||
|
||||
form_fields = [('summary', summary)] |
||||
if labels is not None: |
||||
form_fields.extend([('label', l.strip()) for l in labels]) |
||||
|
||||
content_type, body = encode_upload_request(form_fields, file) |
||||
|
||||
upload_host = '%s.googlecode.com' % project_name |
||||
upload_uri = '/files' |
||||
auth_token = base64.b64encode('%s:%s'% (user_name, password)) |
||||
headers = { |
||||
'Authorization': 'Basic %s' % auth_token, |
||||
'User-Agent': 'Googlecode.com uploader v0.9.4', |
||||
'Content-Type': content_type, |
||||
} |
||||
|
||||
server = httplib.HTTPSConnection(upload_host) |
||||
server.request('POST', upload_uri, body, headers) |
||||
resp = server.getresponse() |
||||
server.close() |
||||
|
||||
if resp.status == 201: |
||||
location = resp.getheader('Location', None) |
||||
else: |
||||
location = None |
||||
return resp.status, resp.reason, location |
||||
|
||||
|
||||
def encode_upload_request(fields, file_path): |
||||
"""Encode the given fields and file into a multipart form body. |
||||
|
||||
fields is a sequence of (name, value) pairs. file is the path of |
||||
the file to upload. The file will be uploaded to Google Code with |
||||
the same file name. |
||||
|
||||
Returns: (content_type, body) ready for httplib.HTTP instance |
||||
""" |
||||
BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla' |
||||
CRLF = '\r\n' |
||||
|
||||
body = [] |
||||
|
||||
# Add the metadata about the upload first |
||||
for key, value in fields: |
||||
body.extend( |
||||
['--' + BOUNDARY, |
||||
'Content-Disposition: form-data; name="%s"' % key, |
||||
'', |
||||
value, |
||||
]) |
||||
|
||||
# Now add the file itself |
||||
file_name = os.path.basename(file_path) |
||||
f = open(file_path, 'rb') |
||||
file_content = f.read() |
||||
f.close() |
||||
|
||||
body.extend( |
||||
['--' + BOUNDARY, |
||||
'Content-Disposition: form-data; name="filename"; filename="%s"' |
||||
% file_name, |
||||
# The upload server determines the mime-type, no need to set it. |
||||
'Content-Type: application/octet-stream', |
||||
'', |
||||
file_content, |
||||
]) |
||||
|
||||
# Finalize the form body |
||||
body.extend(['--' + BOUNDARY + '--', '']) |
||||
|
||||
return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body) |
||||
|
||||
|
||||
def upload_find_auth(file_path, project_name, summary, labels=None, |
||||
user_name=None, password=None, tries=3): |
||||
"""Find credentials and upload a file to a Google Code project's file server. |
||||
|
||||
file_path, project_name, summary, and labels are passed as-is to upload. |
||||
|
||||
Args: |
||||
file_path: The local path to the file. |
||||
project_name: The name of your project on Google Code. |
||||
summary: A small description for the file. |
||||
labels: an optional list of label strings with which to tag the file. |
||||
config_dir: Path to Subversion configuration directory, 'none', or None. |
||||
user_name: Your Google account name. |
||||
tries: How many attempts to make. |
||||
""" |
||||
|
||||
while tries > 0: |
||||
if user_name is None: |
||||
# Read username if not specified or loaded from svn config, or on |
||||
# subsequent tries. |
||||
sys.stdout.write('Please enter your googlecode.com username: ') |
||||
sys.stdout.flush() |
||||
user_name = sys.stdin.readline().rstrip() |
||||
if password is None: |
||||
# Read password if not loaded from svn config, or on subsequent tries. |
||||
print 'Please enter your googlecode.com password.' |
||||
print '** Note that this is NOT your Gmail account password! **' |
||||
print 'It is the password you use to access Subversion repositories,' |
||||
print 'and can be found here: http://code.google.com/hosting/settings' |
||||
password = getpass.getpass() |
||||
|
||||
status, reason, url = upload(file_path, project_name, user_name, password, |
||||
summary, labels) |
||||
# Returns 403 Forbidden instead of 401 Unauthorized for bad |
||||
# credentials as of 2007-07-17. |
||||
if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: |
||||
# Rest for another try. |
||||
user_name = password = None |
||||
tries = tries - 1 |
||||
else: |
||||
# We're done. |
||||
break |
||||
|
||||
return status, reason, url |
||||
|
||||
|
||||
def main(): |
||||
parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' |
||||
'-p PROJECT [options] FILE') |
||||
parser.add_option('-s', '--summary', dest='summary', |
||||
help='Short description of the file') |
||||
parser.add_option('-p', '--project', dest='project', |
||||
help='Google Code project name') |
||||
parser.add_option('-u', '--user', dest='user', |
||||
help='Your Google Code username') |
||||
parser.add_option('-w', '--password', dest='password', |
||||
help='Your Google Code password') |
||||
parser.add_option('-l', '--labels', dest='labels', |
||||
help='An optional list of comma-separated labels to attach ' |
||||
'to the file') |
||||
|
||||
options, args = parser.parse_args() |
||||
|
||||
if not options.summary: |
||||
parser.error('File summary is missing.') |
||||
elif not options.project: |
||||
parser.error('Project name is missing.') |
||||
elif len(args) < 1: |
||||
parser.error('File to upload not provided.') |
||||
elif len(args) > 1: |
||||
parser.error('Only one file may be specified.') |
||||
|
||||
file_path = args[0] |
||||
|
||||
if options.labels: |
||||
labels = options.labels.split(',') |
||||
else: |
||||
labels = None |
||||
|
||||
status, reason, url = upload_find_auth(file_path, options.project, |
||||
options.summary, labels, |
||||
options.user, options.password) |
||||
if url: |
||||
print 'The file was uploaded successfully.' |
||||
print 'URL: %s' % url |
||||
return 0 |
||||
else: |
||||
print 'An error occurred. Your file was not uploaded.' |
||||
print 'Google Code upload server said: %s (%s)' % (reason, status) |
||||
return 1 |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
sys.exit(main()) |
@ -1,79 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- original location: https://hg01.codeplex.com/nuget/raw-file/tip/src/Core/Authoring/nuspec.xsd --> |
||||
<xs:schema id="nuspec" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
<xs:element name="package"> |
||||
<xs:complexType> |
||||
<xs:sequence> |
||||
<xs:element name="metadata" maxOccurs="1" minOccurs="1"> |
||||
<xs:complexType> |
||||
<xs:all> |
||||
<xs:element name="id" maxOccurs="1" minOccurs="1" type="xs:string" /> |
||||
<xs:element name="version" maxOccurs="1" minOccurs="1" type="xs:string" /> |
||||
<xs:element name="title" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="authors" maxOccurs="1" minOccurs="1" type="xs:string" /> |
||||
<xs:element name="owners" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="licenseUrl" maxOccurs="1" minOccurs="0" type="xs:anyURI" /> |
||||
<xs:element name="projectUrl" maxOccurs="1" minOccurs="0" type="xs:anyURI" /> |
||||
<xs:element name="iconUrl" maxOccurs="1" minOccurs="0" type="xs:anyURI" /> |
||||
<xs:element name="requireLicenseAcceptance" maxOccurs="1" minOccurs="0" type="xs:boolean" /> |
||||
<xs:element name="description" maxOccurs="1" minOccurs="1" type="xs:string" /> |
||||
<xs:element name="summary" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="releaseNotes" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="copyright" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="language" maxOccurs="1" minOccurs="0" type="xs:string" default="en-US" /> |
||||
<xs:element name="tags" maxOccurs="1" minOccurs="0" type="xs:string" /> |
||||
<xs:element name="dependencies" maxOccurs="1" minOccurs="0"> |
||||
<xs:complexType> |
||||
<xs:sequence> |
||||
<xs:element name="dependency" minOccurs="0" maxOccurs="unbounded"> |
||||
<xs:complexType> |
||||
<xs:attribute name="id" type="xs:string" use="required" /> |
||||
<xs:attribute name="version" type="xs:string" use="optional" /> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
<xs:element name="frameworkAssemblies" maxOccurs="1" minOccurs="0"> |
||||
<xs:complexType> |
||||
<xs:sequence> |
||||
<xs:element name="frameworkAssembly" minOccurs="0" maxOccurs="unbounded"> |
||||
<xs:complexType> |
||||
<xs:attribute name="assemblyName" type="xs:string" use="required" /> |
||||
<xs:attribute name="targetFramework" type="xs:string" use="optional" /> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
<xs:element name="references" maxOccurs="1" minOccurs="0"> |
||||
<xs:complexType> |
||||
<xs:sequence> |
||||
<xs:element name="reference" minOccurs="0" maxOccurs="unbounded"> |
||||
<xs:complexType> |
||||
<xs:attribute name="file" type="xs:string" use="required" /> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:all> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
<xs:element name="files" minOccurs="0" maxOccurs="1" nillable="true"> |
||||
<xs:complexType> |
||||
<xs:sequence> |
||||
<xs:element name="file" minOccurs="0" maxOccurs="unbounded"> |
||||
<xs:complexType> |
||||
<xs:attribute name="src" use="required" type="xs:string" /> |
||||
<xs:attribute name="target" use="optional" type="xs:string" /> |
||||
<xs:attribute name="exclude" use="optional" type="xs:string" /> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:schema> |
@ -1,186 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Publish" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
||||
<!-- build targets --> |
||||
<Target Name="Clean" DependsOnTargets="_Clean" /> |
||||
<Target Name="Build" DependsOnTargets="_Clean;_Prerequisites;_StampVersion;_GenerateSource;_Build" /> |
||||
<Target Name="Label" DependsOnTargets="_HgLabel" /> |
||||
<Target Name="Package" DependsOnTargets="_HgPack;_NugetPack" /> |
||||
<Target Name="Prepare" DependsOnTargets="Clean;Build;Label;Package" /> |
||||
<Target Name="PushAll" DependsOnTargets="_HgPush;_NugetPush" /> |
||||
<Target Name="Publish" DependsOnTargets="Prepare;PushAll" /> |
||||
|
||||
<PropertyGroup> |
||||
<ProjectName>Protocol Buffers</ProjectName> |
||||
<VersionMajor>2</VersionMajor> |
||||
<VersionMinor>4</VersionMinor> |
||||
<VersionBuild>1</VersionBuild> |
||||
<VersionRevision></VersionRevision> |
||||
<VersionLabel></VersionLabel> |
||||
|
||||
<PackagePrefix>protobuf-csharp-port-</PackagePrefix> |
||||
<PublishDebug>false</PublishDebug> |
||||
|
||||
<GoogleUsername></GoogleUsername> |
||||
<GooglePassword></GooglePassword> |
||||
|
||||
<!--Directory Paths--> |
||||
<ProjectDirectory>$(MSBuildProjectDirectory)\..</ProjectDirectory> |
||||
<BuildTempDirectory>$(ProjectDirectory)\build_temp</BuildTempDirectory> |
||||
<BuildOutputDirectory>$(ProjectDirectory)\build_output</BuildOutputDirectory> |
||||
<SourceDirectory>$(ProjectDirectory)\src</SourceDirectory> |
||||
<LibDirectory>$(ProjectDirectory)\lib</LibDirectory> |
||||
|
||||
<!-- File Paths --> |
||||
<SigningKey>$(ProjectDirectory)\release-key\Google.ProtocolBuffers.snk</SigningKey> |
||||
|
||||
<!--Tool Paths--> |
||||
<HgTool>hg.exe</HgTool> |
||||
<Python>C:\Python25\python.exe</Python> |
||||
<SnTool>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A@InstallationFolder)Bin\sn.exe</SnTool> |
||||
<StampVer>$(LibDirectory)\StampVersion.exe</StampVer> |
||||
<ZipExePath>$(LibDirectory)\7-Zip 9.20\7za.exe</ZipExePath> |
||||
<NuGet>$(LibDirectory)\NuGet.exe</NuGet> |
||||
<ProtogenExePath>$(BuildOutputDirectory)\tools\protogen.exe</ProtogenExePath> |
||||
</PropertyGroup> |
||||
|
||||
<!-- Import user settings --> |
||||
<Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')" /> |
||||
|
||||
<!-- Files --> |
||||
<ItemGroup> |
||||
</ItemGroup> |
||||
|
||||
<!-- Tasks --> |
||||
|
||||
<Target Name="_Prerequisites" DependsOnTargets="_CheckEnvironment;_ReadVersion" /> |
||||
|
||||
<Target Name="_Clean"> |
||||
<MSBuild Properties="Configuration=Debug;" Targets="Clean" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MSBuild Properties="Configuration=Release;" Targets="Clean" Projects="$(MSBuildProjectDirectory)\target.csproj" /> |
||||
<MakeDir Directories="$(BuildTempDirectory)" /> |
||||
<MakeDir Directories="$(BuildOutputDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_WriteUserConfig"> |
||||
<ItemGroup> |
||||
<Lines Include="<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>" /> |
||||
<Lines Include=" <PropertyGroup>"/> |
||||
<Lines Include=" <GoogleUsername> (Enter your google-code user/password here) </GoogleUsername>"/> |
||||
<Lines Include=" <GooglePassword></GooglePassword>"/> |
||||
<Lines Include=" </PropertyGroup>" /> |
||||
<Lines Include="</Project>" /> |
||||
</ItemGroup> |
||||
<WriteLinesToFile File="$(MSBuildProjectFullPath).user" Lines="@(Lines)" Overwrite="true" Condition="!Exists('$(MSBuildProjectFullPath).user')" /> |
||||
<Exec Command="Notepad.exe $(MSBuildProjectFullPath).user" /> |
||||
</Target> |
||||
|
||||
<Target Name="_CheckEnvironment"> |
||||
<!-- Require google credentials --> |
||||
<CallTarget Targets="_WriteUserConfig" Condition=" '$(GooglePassword)' == '' " /> |
||||
<Error Text="Restart after you verify your credentials in $(MSBuildProjectFullPath).user" Condition=" '$(GooglePassword)' == '' " /> |
||||
<!-- Require Win7.0A SDK to verify strong-name --> |
||||
<Error Text="Unable to locate Win7SDK Tools: $(SnTool)" Condition="!Exists($(SnTool))" /> |
||||
<!-- Require Python 2.5 installed --> |
||||
<!-- Error Text="Unable to locate Python 2.5: $(Python)" Condition="!Exists($(Python))" / --> |
||||
<!-- Require production signing key --> |
||||
<Exec Command="$(HgTool) clone https://bitbucket.org/rknapp/protobuf-csharp-port-keyfile $(ProjectDirectory)\release-key" Condition="!Exists('$(SigningKey)')" /> |
||||
<Error Text="Unable to locate release signing key: $(SigningKey)" Condition="!Exists($(SigningKey))" /> |
||||
</Target> |
||||
|
||||
<Target Name="_ReadVersion" Condition=" '$(VersionLabel)' == '' "> |
||||
<Exec Command="$(HgTool) log -l 1 --template "{rev}" > "$(BuildTempDirectory)\revision.txt""></Exec> |
||||
<ReadLinesFromFile File="$(BuildTempDirectory)\revision.txt"> |
||||
<Output TaskParameter="Lines" PropertyName="VersionRevision"/> |
||||
</ReadLinesFromFile> |
||||
|
||||
<PropertyGroup> |
||||
<VersionLabel>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</VersionLabel> |
||||
</PropertyGroup> |
||||
|
||||
<Message Text="Building version $(VersionLabel)" Importance="high" /> |
||||
</Target> |
||||
|
||||
<Target Name="_StampVersion" DependsOnTargets="_Prerequisites"> |
||||
<Exec Command="$(StampVer) /major:$(VersionMajor) /minor:$(VersionMinor) /build:$(VersionBuild) /revision:$(VersionRevision)" WorkingDirectory="$(SourceDirectory)" /> |
||||
<Exec Command="FIND "$(VersionLabel)" ProtocolBuffers\Properties\AssemblyInfo.cs" WorkingDirectory="$(SourceDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_GenerateSource" DependsOnTargets="_Prerequisites"> |
||||
<MSBuild Properties="Configuration=Release;AssemblyOriginatorKeyFile=$(SigningKey)" Targets="GenerateProjects;BuildTools;GenerateSource" Projects="$(MSBuildProjectDirectory)\build.csproj" /> |
||||
<Exec Command=""$(SnTool)" -T "$(ProtogenExePath)" > signkey.txt" WorkingDirectory="$(BuildTempDirectory)" /> |
||||
<!-- Make sure we are signing with the correct key --> |
||||
<Exec Command="FIND "55f7125234beb589" signkey.txt" WorkingDirectory="$(BuildTempDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_Build" DependsOnTargets="_Prerequisites"> |
||||
<!-- Release Build --> |
||||
<MSBuild Properties="Configuration=Release;AssemblyOriginatorKeyFile=$(SigningKey)" Targets="_CompileAll" Projects="$(MSBuildProjectDirectory)\build.csproj" /> |
||||
<MSBuild Properties="Configuration=Release;AssemblyOriginatorKeyFile=$(SigningKey);PackageName=$(PackagePrefix)$(VersionLabel)-release" Targets="GeneratePackage" Projects="$(MSBuildProjectDirectory)\build.csproj" /> |
||||
<!-- Debug Build --> |
||||
<MSBuild Condition=" '$(PublishDebug)' == 'true' " Properties="Configuration=Debug;AssemblyOriginatorKeyFile=$(SigningKey)" Targets="_CompileAll" Projects="$(MSBuildProjectDirectory)\build.csproj" /> |
||||
<MSBuild Condition=" '$(PublishDebug)' == 'true' " Properties="Configuration=Debug;AssemblyOriginatorKeyFile=$(SigningKey);PackageName=$(PackagePrefix)$(VersionLabel)-full" Targets="GeneratePackage" Projects="$(MSBuildProjectDirectory)\build.csproj" /> |
||||
</Target> |
||||
|
||||
<Target Name="_HgPack" DependsOnTargets="_Prerequisites"> |
||||
<Exec Command="$(HgTool) archive $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-source.zip" WorkingDirectory="$(ProjectDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_HgLabel" DependsOnTargets="_Prerequisites"> |
||||
<Exec Command="$(HgTool) commit -m "version $(VersionLabel)"" WorkingDirectory="$(ProjectDirectory)" /> |
||||
<Exec Command="$(HgTool) tag $(VersionLabel)" WorkingDirectory="$(ProjectDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_HgPush" DependsOnTargets="_Prerequisites"> |
||||
<Exec Command="$(HgTool) push" WorkingDirectory="$(ProjectDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_PkgPush" DependsOnTargets="_Prerequisites"> |
||||
<PropertyGroup> |
||||
<UploadPackage>$(Python) "$(MSBuildProjectDirectory)\googlecode_upload.py" --project protobuf-csharp-port --user "$(GoogleUsername)" --password "$(GooglePassword)"</UploadPackage> |
||||
|
||||
<SourcePackage>$(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-source.zip</SourcePackage> |
||||
<ReleasePackageBin>$(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-release-binaries.zip</ReleasePackageBin> |
||||
<ReleasePackageSyb>$(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-release-symbols.zip</ReleasePackageSyb> |
||||
<DebugPackageBin>$(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-full-binaries.zip</DebugPackageBin> |
||||
<DebugPackageSyb>$(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-full-symbols.zip</DebugPackageSyb> |
||||
</PropertyGroup> |
||||
|
||||
<Error Condition="!Exists('$(SourcePackage)')" Text="File not found: $(SourcePackage)" /> |
||||
<Error Condition="!Exists('$(ReleasePackageBin)')" Text="File not found: $(ReleasePackageBin)" /> |
||||
<Error Condition="!Exists('$(ReleasePackageSyb)')" Text="File not found: $(ReleasePackageSyb)" /> |
||||
<Error Condition="'$(PublishDebug)' == 'true' And !Exists('$(DebugPackageBin)')" Text="File not found: $(DebugPackageBin)" /> |
||||
<Error Condition="'$(PublishDebug)' == 'true' And !Exists('$(DebugPackageSyb)')" Text="File not found: $(DebugPackageSyb)" /> |
||||
|
||||
<Exec WorkingDirectory="$(ProjectDirectory)" |
||||
Command="$(UploadPackage) --labels Type-Source,Featured --summary "Version $(VersionLabel) source" $(SourcePackage)" /> |
||||
|
||||
<Exec WorkingDirectory="$(ProjectDirectory)" |
||||
Command="$(UploadPackage) --labels Type-Executable,Featured --summary "Version $(VersionLabel) release binaries only" $(ReleasePackageBin)" /> |
||||
<Exec WorkingDirectory="$(ProjectDirectory)" |
||||
Command="$(UploadPackage) --labels Type-Executable,Featured --summary "Version $(VersionLabel) release binaries and symbols" $(ReleasePackageSyb)" /> |
||||
|
||||
<Exec WorkingDirectory="$(ProjectDirectory)" Condition=" '$(PublishDebug)' == 'true' " |
||||
Command="$(UploadPackage) --labels Type-Executable,Featured --summary "Version $(VersionLabel) all binaries" $(DebugPackageBin)" /> |
||||
<Exec WorkingDirectory="$(ProjectDirectory)" Condition=" '$(PublishDebug)' == 'true' " |
||||
Command="$(UploadPackage) --labels Type-Executable,Featured --summary "Version $(VersionLabel) all binaries and symbols" $(DebugPackageSyb)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_NugetPack" DependsOnTargets="_Prerequisites"> |
||||
<Exec WorkingDirectory="$(MSBuildProjectDirectory)" |
||||
Command="$(NuGet) update -self" /> |
||||
<Exec WorkingDirectory="$(MSBuildProjectDirectory)" |
||||
Command="$(NuGet) pack Google.ProtocolBuffers.nuspec -Symbols -Version $(VersionLabel) -NoPackageAnalysis -OutputDirectory $(BuildTempDirectory)" /> |
||||
<Exec WorkingDirectory="$(MSBuildProjectDirectory)" |
||||
Command="$(NuGet) pack Google.ProtocolBuffersLite.nuspec -Symbols -Version $(VersionLabel) -NoPackageAnalysis -OutputDirectory $(BuildTempDirectory)" /> |
||||
</Target> |
||||
|
||||
<Target Name="_NugetPush" DependsOnTargets="_Prerequisites"> |
||||
<Exec WorkingDirectory="$(BuildTempDirectory)" Command="$(NuGet) push Google.ProtocolBuffers.$(VersionLabel).nupkg" ContinueOnError="true" /> |
||||
<Exec WorkingDirectory="$(BuildTempDirectory)" Command="$(NuGet) push Google.ProtocolBuffersLite.$(VersionLabel).nupkg" ContinueOnError="true" /> |
||||
|
||||
<Exec WorkingDirectory="$(BuildTempDirectory)" Command="$(NuGet) push Google.ProtocolBuffers.$(VersionLabel).symbols.nupkg" ContinueOnError="true" /> |
||||
<Exec WorkingDirectory="$(BuildTempDirectory)" Command="$(NuGet) push Google.ProtocolBuffersLite.$(VersionLabel).symbols.nupkg" ContinueOnError="true" /> |
||||
</Target> |
||||
|
||||
</Project> |
@ -1,167 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
High-level Targets |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="Clean" DependsOnTargets="_Clean" /> |
||||
<Target Name="Build" DependsOnTargets="_Compile;_Test" /> |
||||
<Target Name="Test" DependsOnTargets="_Test" /> |
||||
<Target Name="Rebuild" DependsOnTargets="Clean;Build" /> |
||||
<Target Name="Publish" DependsOnTargets="Clean;Build;_Publish" /> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Properties |
||||
*********************************************************************************************** --> |
||||
|
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">Any CPU</Platform> |
||||
<TargetVersion Condition=" '$(TargetVersion)' == '' ">NET20</TargetVersion> |
||||
<BuildParams></BuildParams> |
||||
|
||||
<!--Directory Paths--> |
||||
<ProjectDirectory>$(MSBuildProjectDirectory)\..</ProjectDirectory> |
||||
<SourceDirectory>$(ProjectDirectory)\src</SourceDirectory> |
||||
<LibDirectory>$(ProjectDirectory)\lib</LibDirectory> |
||||
|
||||
<!--File Paths--> |
||||
<BuildTempDirectory>$(ProjectDirectory)\build_temp\$(Configuration)\$(TargetVersion)</BuildTempDirectory> |
||||
<BuildOutputDirectory>$(ProjectDirectory)\build_output\$(Configuration)\$(TargetVersion)</BuildOutputDirectory> |
||||
<SolutionFile>$(SourceDirectory)\ProtocolBuffersLibrary.$(TargetVersion).sln</SolutionFile> |
||||
|
||||
<!--Tool Paths--> |
||||
<NUnitExePath>$(LibDirectory)\NUnit\tools\nunit-console.exe</NUnitExePath> |
||||
<StatLightExePath>$(LibDirectory)\StatLight\tools\StatLight.exe</StatLightExePath> |
||||
</PropertyGroup> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Target Versions |
||||
*********************************************************************************************** --> |
||||
|
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'NET20' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>NUNIT</TestFramework> |
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'NET35' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>NUNIT</TestFramework> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'NET40' "> |
||||
<BuildTools>4.0</BuildTools> |
||||
<TestFramework>NUNIT</TestFramework> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'CF20' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>NONE</TestFramework> |
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'CF35' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>NONE</TestFramework> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'SL20' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>SILVERLIGHT</TestFramework> |
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'SL30' "> |
||||
<BuildTools>3.5</BuildTools> |
||||
<TestFramework>SILVERLIGHT</TestFramework> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'SL40' "> |
||||
<BuildTools>4.0</BuildTools> |
||||
<TestFramework>SILVERLIGHT</TestFramework> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(TargetVersion)' == 'PL40' "> |
||||
<BuildTools>4.0</BuildTools> |
||||
<TestFramework>SILVERLIGHT</TestFramework> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<BuildOutputDirectory>$(ProjectDirectory)\build_output\$(Configuration)\portable-net40+sl4+sl5+wp7+wp8+win8</BuildOutputDirectory> |
||||
</PropertyGroup> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
File Groups |
||||
*********************************************************************************************** --> |
||||
|
||||
<ItemGroup> |
||||
<WorkingDirectories Include="$(BuildTempDirectory)" /> |
||||
<WorkingDirectories Include="$(BuildOutputDirectory)" /> |
||||
|
||||
<TestContainer Include="$(SourceDirectory)\ProtocolBuffers.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.Test.dll" /> |
||||
<TestContainer Include="$(SourceDirectory)\ProtocolBuffersLite.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.Test.dll" /> |
||||
<TestContainer Include="$(SourceDirectory)\ProtocolBuffersLite.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersMixedLite.Test.dll" /> |
||||
|
||||
<StatLightTestContainer Include="$(SourceDirectory)\ProtocolBuffers.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.Test.xap" /> |
||||
<StatLightTestContainer Include="$(SourceDirectory)\ProtocolBuffersLite.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.Test.xap" /> |
||||
<StatLightTestContainer Include="$(SourceDirectory)\ProtocolBuffersLite.Test\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersMixedLite.Test.xap" /> |
||||
|
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.dll" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.pdb" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.xml" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.dll" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.pdb" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.xml" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.Serialization.dll" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.Serialization.pdb" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffers.Serialization.xml" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.Serialization.dll" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.Serialization.pdb" /> |
||||
<PublishItem Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(TargetVersion)\$(Configuration)\Google.ProtocolBuffersLite.Serialization.xml" /> |
||||
</ItemGroup> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Build |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_Configured"> |
||||
<Message Text="Building $(TargetVersion) for configuration $(Configuration), platform $(Platform)" Importance="normal" /> |
||||
<Error Text="Unknown or missing value for TargetVersion=[value]" Condition=" '$(BuildTools)' == '' " /> |
||||
</Target> |
||||
|
||||
<Target Name="_Clean" DependsOnTargets="_Configured"> |
||||
<RemoveDir Directories="@(WorkingDirectories)" Condition="Exists(%(WorkingDirectories.Identity))" /> |
||||
<MSBuild Targets="Clean" Projects="$(SolutionFile)" ToolsVersion="$(BuildTools)" |
||||
Properties="Configuration=$(Configuration);Platform=$(Platform);" |
||||
/> |
||||
</Target> |
||||
|
||||
<Target Name="_Compile" DependsOnTargets="_Configured"> |
||||
<MSBuild Targets="Build" Projects="$(SolutionFile)" ToolsVersion="$(BuildTools)" |
||||
Properties="Configuration=$(Configuration);Platform=$(Platform);$(BuildParams)" |
||||
/> |
||||
</Target> |
||||
|
||||
<Target Name="_Publish" DependsOnTargets="_Configured"> |
||||
<MakeDir Directories="$(BuildOutputDirectory)" /> |
||||
<Copy SourceFiles="@(PublishItem)" DestinationFolder="$(BuildOutputDirectory)" /> |
||||
</Target> |
||||
|
||||
<!-- ********************************************************************************************** |
||||
Targets For Test |
||||
*********************************************************************************************** --> |
||||
|
||||
<Target Name="_Test" DependsOnTargets="_Configured"> |
||||
<MakeDir Directories="$(BuildTempDirectory)" /> |
||||
<CallTarget Targets="_RunNunit" Condition=" '$(TestFramework)'=='NUNIT' " /> |
||||
<CallTarget Targets="_RunStatLight" Condition=" '$(TestFramework)'=='SILVERLIGHT' " /> |
||||
</Target> |
||||
|
||||
<Target Name="_RunNunit"> |
||||
<Copy SourceFiles="$(LibDirectory)\NUnit-config\nunit-console.$(TargetFrameworkVersion).config" DestinationFiles="$(NUnitExePath).config" /> |
||||
<Exec Command=""$(NUnitExePath)" /nologo /noshadow "%(TestContainer.Identity)" /xml:"$(BuildTempDirectory)\%(TestContainer.Filename).xml"" /> |
||||
</Target> |
||||
|
||||
<Target Name="_RunStatLight"> |
||||
<Exec |
||||
Command=""$(StatLightExePath)" -x %(StatLightTestContainer.Identity) --ReportOutputFileType=NUnit --ReportOutputFile=$(BuildTempDirectory)\%(StatLightTestContainer.Filename).xml" /> |
||||
</Target> |
||||
|
||||
</Project> |
@ -0,0 +1,13 @@ |
||||
@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 |
||||
|
||||
goto :EOF |
||||
|
||||
:error |
||||
echo Failed! |
||||
exit /b %errorlevel% |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@ |
||||
Contents |
||||
-------- |
||||
|
||||
- Google.Protobuf.public.snk: |
||||
Public key to verify strong name of Google.Protobuf assemblies. |
@ -1,13 +0,0 @@ |
||||
@ECHO OFF |
||||
IF EXIST "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\sn.exe" GOTO FOUND |
||||
goto USEPATH |
||||
|
||||
:FOUND |
||||
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\sn.exe" -k %~dp0\Google.ProtocolBuffers.snk |
||||
GOTO EXIT |
||||
|
||||
:USEPATH |
||||
sn.exe -k %~dp0\Google.ProtocolBuffers.snk |
||||
GOTO EXIT |
||||
|
||||
:EXIT |
@ -1,71 +0,0 @@ |
||||
syntax = "proto2"; |
||||
|
||||
package protobuf_unittest_extra; |
||||
|
||||
option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
option optimize_for = CODE_SIZE; |
||||
option java_package = "com.google.protobuf"; |
||||
|
||||
message TestInteropPerson { |
||||
required string name = 1; |
||||
required int32 id = 2; |
||||
optional string email = 3; |
||||
repeated int32 codes = 10 [packed=true]; |
||||
|
||||
enum PhoneType { |
||||
MOBILE = 0; |
||||
HOME = 1; |
||||
WORK = 2; |
||||
} |
||||
|
||||
message PhoneNumber { |
||||
required string number = 1; |
||||
optional PhoneType type = 2 [default = HOME]; |
||||
} |
||||
|
||||
repeated PhoneNumber phone = 4; |
||||
|
||||
repeated group Addresses = 5 { |
||||
required string address = 1; |
||||
optional string address2 = 2; |
||||
required string city = 3; |
||||
required string state = 4; |
||||
required fixed32 zip = 5; |
||||
} |
||||
|
||||
extensions 100 to 199; |
||||
} |
||||
|
||||
message TestInteropEmployeeId { |
||||
required string number = 1; |
||||
} |
||||
|
||||
extend TestInteropPerson { |
||||
// Note: changed from required to optional, as required fields are not |
||||
// permitted in extensions. (The fact that this was allowed in protogen |
||||
// before was almost certainly a bug.) |
||||
optional TestInteropEmployeeId employee_id = 126; |
||||
} |
||||
|
||||
message TestMissingFieldsA { |
||||
required string name = 1; |
||||
required int32 id = 2; |
||||
optional string email = 3; |
||||
|
||||
message SubA { |
||||
required int32 count = 5; |
||||
repeated string values = 6; |
||||
} |
||||
optional SubA testA = 11; |
||||
} |
||||
|
||||
message TestMissingFieldsB { |
||||
required string name = 1; |
||||
required int32 id = 2; |
||||
optional string website = 4; |
||||
|
||||
message SubB { |
||||
repeated string values = 7; |
||||
} |
||||
optional SubB testB = 12; |
||||
} |
@ -1,115 +0,0 @@ |
||||
syntax = "proto2"; |
||||
|
||||
package protobuf_unittest_extra; |
||||
|
||||
option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
option optimize_for = LITE_RUNTIME; |
||||
option java_package = "com.google.protobuf"; |
||||
|
||||
message TestRequiredLite { |
||||
required int32 d = 1; |
||||
required ExtraEnum en = 2 [default = DEFAULT]; |
||||
} |
||||
|
||||
enum ExtraEnum { |
||||
DEFAULT = 10; |
||||
EXLITE_FOO = 7; |
||||
EXLITE_BAR = 8; |
||||
EXLITE_BAZ = 9; |
||||
} |
||||
|
||||
message TestInteropPersonLite { |
||||
required string name = 1; |
||||
required int32 id = 2; |
||||
optional string email = 3; |
||||
repeated int32 codes = 10 [packed=true]; |
||||
|
||||
enum PhoneType { |
||||
MOBILE = 0; |
||||
HOME = 1; |
||||
WORK = 2; |
||||
} |
||||
|
||||
message PhoneNumber { |
||||
required string number = 1; |
||||
optional PhoneType type = 2 [default = HOME]; |
||||
} |
||||
|
||||
repeated PhoneNumber phone = 4; |
||||
|
||||
repeated group Addresses = 5 { |
||||
required string address = 1; |
||||
optional string address2 = 2; |
||||
required string city = 3; |
||||
required string state = 4; |
||||
required fixed32 zip = 5; |
||||
} |
||||
|
||||
extensions 100 to 199; |
||||
} |
||||
|
||||
message TestInteropEmployeeIdLite { |
||||
required string number = 1; |
||||
} |
||||
|
||||
extend TestInteropPersonLite { |
||||
// Note: changed from required to optional, as required fields are not |
||||
// permitted in extensions. (The fact that this was allowed in protogen |
||||
// before was almost certainly a bug.) |
||||
optional TestInteropEmployeeIdLite employee_id_lite = 126; |
||||
} |
||||
|
||||
/* Removed from unittest_lite.proto and added back here */ |
||||
|
||||
message TestUnpackedExtensionsLite { |
||||
extensions 1 to max; |
||||
} |
||||
|
||||
message TestUnpackedTypesLite { |
||||
repeated int32 unpacked_int32 = 90; |
||||
repeated int64 unpacked_int64 = 91; |
||||
repeated uint32 unpacked_uint32 = 92; |
||||
repeated uint64 unpacked_uint64 = 93; |
||||
repeated sint32 unpacked_sint32 = 94; |
||||
repeated sint64 unpacked_sint64 = 95; |
||||
repeated fixed32 unpacked_fixed32 = 96; |
||||
repeated fixed64 unpacked_fixed64 = 97; |
||||
repeated sfixed32 unpacked_sfixed32 = 98; |
||||
repeated sfixed64 unpacked_sfixed64 = 99; |
||||
repeated float unpacked_float = 100; |
||||
repeated double unpacked_double = 101; |
||||
repeated bool unpacked_bool = 102; |
||||
repeated UnpackedTypesForeignEnumLite unpacked_enum = 103; |
||||
} |
||||
|
||||
extend TestUnpackedExtensionsLite { |
||||
repeated int32 unpacked_int32_extension_lite = 90; |
||||
repeated int64 unpacked_int64_extension_lite = 91; |
||||
repeated uint32 unpacked_uint32_extension_lite = 92; |
||||
repeated uint64 unpacked_uint64_extension_lite = 93; |
||||
repeated sint32 unpacked_sint32_extension_lite = 94; |
||||
repeated sint64 unpacked_sint64_extension_lite = 95; |
||||
repeated fixed32 unpacked_fixed32_extension_lite = 96; |
||||
repeated fixed64 unpacked_fixed64_extension_lite = 97; |
||||
repeated sfixed32 unpacked_sfixed32_extension_lite = 98; |
||||
repeated sfixed64 unpacked_sfixed64_extension_lite = 99; |
||||
repeated float unpacked_float_extension_lite = 100; |
||||
repeated double unpacked_double_extension_lite = 101; |
||||
repeated bool unpacked_bool_extension_lite = 102; |
||||
repeated UnpackedTypesForeignEnumLite unpacked_enum_extension_lite = 103; |
||||
} |
||||
|
||||
enum UnpackedTypesForeignEnumLite { |
||||
FOREIGN_LITE_FOO = 4; |
||||
FOREIGN_LITE_BAR = 5; |
||||
FOREIGN_LITE_BAZ = 6; |
||||
} |
||||
|
||||
message BucketOfBytes { |
||||
optional bytes value = 1; |
||||
|
||||
} |
||||
message BucketOfBytesEx { |
||||
optional bytes value = 1; |
||||
optional bytes value2 = 255; |
||||
} |
@ -1,53 +0,0 @@ |
||||
syntax = "proto2"; |
||||
|
||||
option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
|
||||
package protobuf_unittest_extra; |
||||
|
||||
option optimize_for = SPEED; |
||||
|
||||
enum EnumOptions { |
||||
ONE = 0; |
||||
TWO = 1; |
||||
THREE = 2; |
||||
} |
||||
|
||||
message TestXmlChild { |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
message TestXmlNoFields { |
||||
} |
||||
|
||||
message TestXmlRescursive { |
||||
optional TestXmlRescursive child = 1; |
||||
} |
||||
|
||||
message TestXmlMessage { |
||||
|
||||
optional int64 number = 6; |
||||
repeated int32 numbers = 2; |
||||
optional string text = 3; |
||||
repeated string textlines = 700; |
||||
optional bool valid = 5; |
||||
|
||||
optional TestXmlChild child = 1; |
||||
repeated group Children = 401 { |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
extensions 100 to 199; |
||||
} |
||||
|
||||
message TestXmlExtension { |
||||
required int32 number = 1; |
||||
} |
||||
|
||||
extend TestXmlMessage { |
||||
optional EnumOptions extension_enum = 101; |
||||
optional string extension_text = 102; |
||||
repeated int32 extension_number = 103 [packed = true]; |
||||
optional TestXmlExtension extension_message = 199; |
||||
} |
@ -1,141 +0,0 @@ |
||||
syntax = "proto2"; |
||||
|
||||
// These proto descriptors have at one time been reported as an issue or defect. |
||||
// They are kept here to replicate the issue, and continue to verify the fix. |
||||
|
||||
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified |
||||
option csharp_namespace = "UnitTest.Issues.TestProtos"; |
||||
|
||||
package unittest_issues; |
||||
option optimize_for = SPEED; |
||||
|
||||
// The following is a representative set of features |
||||
/* |
||||
enum EnumOptions { |
||||
ONE = 0; |
||||
TWO = 1; |
||||
THREE = 2; |
||||
} |
||||
|
||||
message TestBasicChild |
||||
{ |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
message TestBasicNoFields { |
||||
} |
||||
|
||||
message TestBasicRescursive { |
||||
optional TestBasicRescursive child = 1; |
||||
} |
||||
|
||||
message TestBasicMessage { |
||||
|
||||
optional int64 number = 6; |
||||
repeated int32 numbers = 2; |
||||
optional string text = 3; |
||||
repeated string textlines = 700; |
||||
optional bool valid = 5; |
||||
|
||||
optional TestBasicChild child = 1; |
||||
repeated group Children = 401 |
||||
{ |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
extensions 100 to 199; |
||||
} |
||||
|
||||
message TestBasicExtension { |
||||
required int32 number = 1; |
||||
} |
||||
|
||||
extend TestBasicMessage { |
||||
optional EnumOptions extension_enum = 101; |
||||
optional string extension_text = 102; |
||||
repeated int32 extension_number = 103 [packed = true]; |
||||
optional TestBasicExtension extension_message = 199; |
||||
} |
||||
|
||||
// Issue for non-qualified type reference in new services generation |
||||
option (google.protobuf.csharp_file_options).service_generator_type = IRPCDISPATCH; |
||||
|
||||
service TestGenericService { |
||||
rpc Foo(TestBasicNoFields) returns (TestBasicMessage); |
||||
rpc Bar(TestBasicNoFields) returns (TestBasicMessage); |
||||
} |
||||
*/ |
||||
|
||||
// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 |
||||
// New issue 309: https://github.com/google/protobuf/issues/309 |
||||
|
||||
// message A { |
||||
// optional int32 _A = 1; |
||||
// } |
||||
|
||||
// message B { |
||||
// optional int32 B_ = 1; |
||||
// } |
||||
|
||||
//message AB { |
||||
// optional int32 a_b = 1; |
||||
//} |
||||
|
||||
// Similar issue with numeric names |
||||
// Java code failed too, so probably best for this to be a restriction. |
||||
// See https://github.com/google/protobuf/issues/308 |
||||
// message NumberField { |
||||
// optional int32 _01 = 1; |
||||
// } |
||||
|
||||
// Issue 28: Circular message dependencies result in null defaults for DefaultInstance |
||||
|
||||
message MyMessageAReferenceB { |
||||
required MyMessageBReferenceA value = 1; |
||||
} |
||||
|
||||
message MyMessageBReferenceA { |
||||
required MyMessageAReferenceB value = 1; |
||||
} |
||||
|
||||
// issue 19 - negative enum values |
||||
|
||||
enum NegativeEnum { |
||||
FiveBelow = -5; |
||||
MinusOne = -1; |
||||
Zero = 0; |
||||
} |
||||
|
||||
message NegativeEnumMessage { |
||||
optional NegativeEnum value = 1; |
||||
repeated NegativeEnum values = 2; |
||||
repeated NegativeEnum packed_values = 3 [packed=true]; |
||||
} |
||||
|
||||
// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21 |
||||
// Decorate fields with [deprecated=true] as [System.Obsolete] |
||||
|
||||
message DeprecatedChild { |
||||
} |
||||
|
||||
enum DeprecatedEnum { |
||||
one = 1; |
||||
} |
||||
|
||||
message DeprecatedFieldsMessage { |
||||
optional int32 PrimitiveValue = 1 [deprecated = true]; |
||||
repeated int32 PrimitiveArray = 2 [deprecated = true]; |
||||
|
||||
optional DeprecatedChild MessageValue = 3 [deprecated = true]; |
||||
repeated DeprecatedChild MessageArray = 4 [deprecated = true]; |
||||
|
||||
optional DeprecatedEnum EnumValue = 5 [deprecated = true]; |
||||
repeated DeprecatedEnum EnumArray = 6 [deprecated = true]; |
||||
} |
||||
|
||||
// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 |
||||
message ItemField { |
||||
optional int32 item = 1; |
||||
} |
@ -0,0 +1,119 @@ |
||||
syntax = "proto3"; |
||||
|
||||
// These proto descriptors have at one time been reported as an issue or defect. |
||||
// They are kept here to replicate the issue, and continue to verify the fix. |
||||
|
||||
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified |
||||
option csharp_namespace = "UnitTest.Issues.TestProtos"; |
||||
|
||||
package unittest_issues; |
||||
option optimize_for = SPEED; |
||||
|
||||
// Issue 307: when generating doubly-nested types, any references |
||||
// should be of the form A.Types.B.Types.C. |
||||
message Issue307 { |
||||
message NestedOnce { |
||||
message NestedTwice { |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 |
||||
// New issue 309: https://github.com/google/protobuf/issues/309 |
||||
|
||||
// message A { |
||||
// optional int32 _A = 1; |
||||
// } |
||||
|
||||
// message B { |
||||
// optional int32 B_ = 1; |
||||
// } |
||||
|
||||
//message AB { |
||||
// optional int32 a_b = 1; |
||||
//} |
||||
|
||||
// Similar issue with numeric names |
||||
// Java code failed too, so probably best for this to be a restriction. |
||||
// See https://github.com/google/protobuf/issues/308 |
||||
// message NumberField { |
||||
// optional int32 _01 = 1; |
||||
// } |
||||
|
||||
// issue 19 - negative enum values |
||||
|
||||
enum NegativeEnum { |
||||
NEGATIVE_ENUM_ZERO = 0; |
||||
FiveBelow = -5; |
||||
MinusOne = -1; |
||||
} |
||||
|
||||
message NegativeEnumMessage { |
||||
NegativeEnum value = 1; |
||||
repeated NegativeEnum values = 2 [packed = false]; |
||||
repeated NegativeEnum packed_values = 3 [packed=true]; |
||||
} |
||||
|
||||
// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21 |
||||
// Decorate fields with [deprecated=true] as [System.Obsolete] |
||||
|
||||
message DeprecatedChild { |
||||
} |
||||
|
||||
enum DeprecatedEnum { |
||||
DEPRECATED_ZERO = 0; |
||||
one = 1; |
||||
} |
||||
|
||||
message DeprecatedFieldsMessage { |
||||
int32 PrimitiveValue = 1 [deprecated = true]; |
||||
repeated int32 PrimitiveArray = 2 [deprecated = true]; |
||||
|
||||
DeprecatedChild MessageValue = 3 [deprecated = true]; |
||||
repeated DeprecatedChild MessageArray = 4 [deprecated = true]; |
||||
|
||||
DeprecatedEnum EnumValue = 5 [deprecated = true]; |
||||
repeated DeprecatedEnum EnumArray = 6 [deprecated = true]; |
||||
} |
||||
|
||||
// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 |
||||
message ItemField { |
||||
int32 item = 1; |
||||
} |
||||
|
||||
message ReservedNames { |
||||
// Force a nested type called Types |
||||
message SomeNestedType { |
||||
} |
||||
|
||||
int32 types = 1; |
||||
int32 descriptor = 2; |
||||
} |
||||
|
||||
message TestJsonFieldOrdering { |
||||
// These fields are deliberately not declared in numeric |
||||
// order, and the oneof fields aren't contiguous either. |
||||
// This allows for reasonably robust tests of JSON output |
||||
// ordering. |
||||
// TestFieldOrderings in unittest_proto3.proto is similar, |
||||
// but doesn't include oneofs. |
||||
// TODO: Consider adding oneofs to TestFieldOrderings, although |
||||
// that will require fixing other tests in multiple platforms. |
||||
// Alternatively, consider just adding this to |
||||
// unittest_proto3.proto if multiple platforms want it. |
||||
|
||||
int32 plain_int32 = 4; |
||||
|
||||
oneof o1 { |
||||
string o1_string = 2; |
||||
int32 o1_int32 = 5; |
||||
} |
||||
|
||||
string plain_string = 1; |
||||
|
||||
oneof o2 { |
||||
int32 o2_int32 = 6; |
||||
string o2_string = 3; |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,3 @@ |
||||
<?xml version="1.0"?> |
||||
<configuration> |
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> |
||||
|
@ -1,3 +1,3 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<configuration> |
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> |
@ -0,0 +1,20 @@ |
||||
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,286 +1,255 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 Google Inc. All rights reserved. |
||||
// http://github.com/jskeet/dotnet-protobufs/ |
||||
// Original C++/Java/Python code: |
||||
// http://code.google.com/p/protobuf/ |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
#endregion |
||||
|
||||
using Google.ProtocolBuffers.Descriptors; |
||||
using Google.ProtocolBuffers.TestProtos; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Google.ProtocolBuffers |
||||
{ |
||||
/// <summary> |
||||
/// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the |
||||
/// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...) |
||||
/// </summary> |
||||
public class DescriptorsTest |
||||
{ |
||||
[Test] |
||||
public void FileDescriptor() |
||||
{ |
||||
FileDescriptor file = Unittest.Descriptor; |
||||
|
||||
Assert.AreEqual("google/protobuf/unittest.proto", file.Name); |
||||
Assert.AreEqual("protobuf_unittest", file.Package); |
||||
|
||||
Assert.AreEqual("UnittestProto", file.Options.JavaOuterClassname); |
||||
Assert.AreEqual("google/protobuf/unittest.proto", file.Proto.Name); |
||||
|
||||
// unittest.proto doesn't have any public imports, but unittest_import.proto does. |
||||
Assert.AreEqual(0, file.PublicDependencies.Count); |
||||
Assert.AreEqual(1, UnittestImport.Descriptor.PublicDependencies.Count); |
||||
Assert.AreEqual(UnittestImportPublic.Descriptor, UnittestImport.Descriptor.PublicDependencies[0]); |
||||
|
||||
Assert.AreEqual(1, file.Dependencies.Count); |
||||
Assert.AreEqual(UnittestImport.Descriptor, file.Dependencies[0]); |
||||
|
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
Assert.AreEqual(messageType, file.MessageTypes[0]); |
||||
Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes")); |
||||
Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType")); |
||||
Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes")); |
||||
for (int i = 0; i < file.MessageTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, file.MessageTypes[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum")); |
||||
Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType")); |
||||
Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum")); |
||||
Assert.AreEqual(1, UnittestImport.Descriptor.EnumTypes.Count); |
||||
Assert.AreEqual("ImportEnum", UnittestImport.Descriptor.EnumTypes[0].Name); |
||||
for (int i = 0; i < file.EnumTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, file.EnumTypes[i].Index); |
||||
} |
||||
|
||||
FieldDescriptor extension = Unittest.OptionalInt32Extension.Descriptor; |
||||
Assert.AreEqual(extension, file.Extensions[0]); |
||||
Assert.AreEqual(extension, file.FindTypeByName<FieldDescriptor>("optional_int32_extension")); |
||||
Assert.Null(file.FindTypeByName<FieldDescriptor>("no_such_ext")); |
||||
Assert.Null(file.FindTypeByName<FieldDescriptor>("protobuf_unittest.optional_int32_extension")); |
||||
Assert.AreEqual(0, UnittestImport.Descriptor.Extensions.Count); |
||||
for (int i = 0; i < file.Extensions.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, file.Extensions[i].Index); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void MessageDescriptor() |
||||
{ |
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; |
||||
|
||||
Assert.AreEqual("TestAllTypes", messageType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); |
||||
Assert.AreEqual(Unittest.Descriptor, messageType.File); |
||||
Assert.Null(messageType.ContainingType); |
||||
Assert.AreEqual(DescriptorProtos.MessageOptions.DefaultInstance, messageType.Options); |
||||
Assert.AreEqual("TestAllTypes", messageType.Proto.Name); |
||||
|
||||
Assert.AreEqual("NestedMessage", nestedType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); |
||||
Assert.AreEqual(Unittest.Descriptor, nestedType.File); |
||||
Assert.AreEqual(messageType, nestedType.ContainingType); |
||||
|
||||
FieldDescriptor field = messageType.Fields[0]; |
||||
Assert.AreEqual("optional_int32", field.Name); |
||||
Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("optional_int32")); |
||||
Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field")); |
||||
Assert.AreEqual(field, messageType.FindFieldByNumber(1)); |
||||
Assert.Null(messageType.FindFieldByNumber(571283)); |
||||
for (int i = 0; i < messageType.Fields.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, messageType.Fields[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(nestedType, messageType.NestedTypes[0]); |
||||
Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage")); |
||||
Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType")); |
||||
for (int i = 0; i < messageType.NestedTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, messageType.NestedTypes[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum")); |
||||
Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType")); |
||||
for (int i = 0; i < messageType.EnumTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, messageType.EnumTypes[i].Index); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FieldDescriptor() |
||||
{ |
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("optional_int32"); |
||||
FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("optional_nested_enum"); |
||||
FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("optional_foreign_message"); |
||||
FieldDescriptor cordField = messageType.FindDescriptor<FieldDescriptor>("optional_cord"); |
||||
FieldDescriptor extension = Unittest.OptionalInt32Extension.Descriptor; |
||||
FieldDescriptor nestedExtension = TestRequired.Single.Descriptor; |
||||
|
||||
Assert.AreEqual("optional_int32", primitiveField.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.optional_int32", |
||||
primitiveField.FullName); |
||||
Assert.AreEqual(1, primitiveField.FieldNumber); |
||||
Assert.AreEqual(messageType, primitiveField.ContainingType); |
||||
Assert.AreEqual(Unittest.Descriptor, primitiveField.File); |
||||
Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); |
||||
Assert.AreEqual(MappedType.Int32, primitiveField.MappedType); |
||||
Assert.AreEqual(DescriptorProtos.FieldOptions.DefaultInstance, primitiveField.Options); |
||||
Assert.IsFalse(primitiveField.IsExtension); |
||||
Assert.AreEqual("optional_int32", primitiveField.Proto.Name); |
||||
|
||||
Assert.AreEqual("optional_nested_enum", enumField.Name); |
||||
Assert.AreEqual(FieldType.Enum, enumField.FieldType); |
||||
Assert.AreEqual(MappedType.Enum, enumField.MappedType); |
||||
// Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); |
||||
|
||||
Assert.AreEqual("optional_foreign_message", messageField.Name); |
||||
Assert.AreEqual(FieldType.Message, messageField.FieldType); |
||||
Assert.AreEqual(MappedType.Message, messageField.MappedType); |
||||
Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); |
||||
|
||||
Assert.AreEqual("optional_cord", cordField.Name); |
||||
Assert.AreEqual(FieldType.String, cordField.FieldType); |
||||
Assert.AreEqual(MappedType.String, cordField.MappedType); |
||||
Assert.AreEqual(DescriptorProtos.FieldOptions.Types.CType.CORD, cordField.Options.Ctype); |
||||
|
||||
Assert.AreEqual("optional_int32_extension", extension.Name); |
||||
Assert.AreEqual("protobuf_unittest.optional_int32_extension", extension.FullName); |
||||
Assert.AreEqual(1, extension.FieldNumber); |
||||
Assert.AreEqual(TestAllExtensions.Descriptor, extension.ContainingType); |
||||
Assert.AreEqual(Unittest.Descriptor, extension.File); |
||||
Assert.AreEqual(FieldType.Int32, extension.FieldType); |
||||
Assert.AreEqual(MappedType.Int32, extension.MappedType); |
||||
Assert.AreEqual(DescriptorProtos.FieldOptions.DefaultInstance, |
||||
extension.Options); |
||||
Assert.IsTrue(extension.IsExtension); |
||||
Assert.AreEqual(null, extension.ExtensionScope); |
||||
Assert.AreEqual("optional_int32_extension", extension.Proto.Name); |
||||
|
||||
Assert.AreEqual("single", nestedExtension.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestRequired.single", |
||||
nestedExtension.FullName); |
||||
Assert.AreEqual(TestRequired.Descriptor, |
||||
nestedExtension.ExtensionScope); |
||||
} |
||||
|
||||
[Test] |
||||
public void FieldDescriptorLabel() |
||||
{ |
||||
FieldDescriptor requiredField = |
||||
TestRequired.Descriptor.FindDescriptor<FieldDescriptor>("a"); |
||||
FieldDescriptor optionalField = |
||||
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("optional_int32"); |
||||
FieldDescriptor repeatedField = |
||||
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32"); |
||||
|
||||
Assert.IsTrue(requiredField.IsRequired); |
||||
Assert.IsFalse(requiredField.IsRepeated); |
||||
Assert.IsFalse(optionalField.IsRequired); |
||||
Assert.IsFalse(optionalField.IsRepeated); |
||||
Assert.IsFalse(repeatedField.IsRequired); |
||||
Assert.IsTrue(repeatedField.IsRepeated); |
||||
} |
||||
[Test] |
||||
public void FieldDescriptorDefault() |
||||
{ |
||||
MessageDescriptor d = TestAllTypes.Descriptor; |
||||
Assert.IsFalse(d.FindDescriptor<FieldDescriptor>("optional_int32").HasDefaultValue); |
||||
Assert.AreEqual(0, d.FindDescriptor<FieldDescriptor>("optional_int32").DefaultValue); |
||||
Assert.IsTrue(d.FindDescriptor<FieldDescriptor>("default_int32").HasDefaultValue); |
||||
Assert.AreEqual(41, d.FindDescriptor<FieldDescriptor>("default_int32").DefaultValue); |
||||
|
||||
d = TestExtremeDefaultValues.Descriptor; |
||||
Assert.AreEqual(TestExtremeDefaultValues.DefaultInstance.EscapedBytes, |
||||
d.FindDescriptor<FieldDescriptor>("escaped_bytes").DefaultValue); |
||||
|
||||
Assert.AreEqual(uint.MaxValue, d.FindDescriptor<FieldDescriptor>("large_uint32").DefaultValue); |
||||
Assert.AreEqual(ulong.MaxValue, d.FindDescriptor<FieldDescriptor>("large_uint64").DefaultValue); |
||||
} |
||||
[Test] |
||||
public void EnumDescriptor() |
||||
{ |
||||
// Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor |
||||
EnumDescriptor enumType = Unittest.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum"); |
||||
EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum"); |
||||
|
||||
Assert.AreEqual("ForeignEnum", enumType.Name); |
||||
Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); |
||||
Assert.AreEqual(Unittest.Descriptor, enumType.File); |
||||
Assert.Null(enumType.ContainingType); |
||||
Assert.AreEqual(DescriptorProtos.EnumOptions.DefaultInstance, |
||||
enumType.Options); |
||||
|
||||
Assert.AreEqual("NestedEnum", nestedType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", |
||||
nestedType.FullName); |
||||
Assert.AreEqual(Unittest.Descriptor, nestedType.File); |
||||
Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); |
||||
|
||||
EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); |
||||
Assert.AreEqual(value, enumType.Values[0]); |
||||
Assert.AreEqual("FOREIGN_FOO", value.Name); |
||||
Assert.AreEqual(4, value.Number); |
||||
Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number); |
||||
Assert.AreEqual(value, enumType.FindValueByNumber(4)); |
||||
Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE")); |
||||
for (int i = 0; i < enumType.Values.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, enumType.Values[i].Index); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void CustomOptions() |
||||
{ |
||||
MessageDescriptor descriptor = TestMessageWithCustomOptions.Descriptor; |
||||
Assert.IsTrue(descriptor.Options.HasExtension(UnittestCustomOptions.MessageOpt1)); |
||||
Assert.AreEqual(-56, descriptor.Options.GetExtension(UnittestCustomOptions.MessageOpt1)); |
||||
|
||||
|
||||
FieldDescriptor field = descriptor.FindFieldByName("field1"); |
||||
Assert.NotNull(field); |
||||
|
||||
Assert.IsTrue(field.Options.HasExtension(UnittestCustomOptions.FieldOpt1)); |
||||
Assert.AreEqual(8765432109uL, field.Options.GetExtension(UnittestCustomOptions.FieldOpt1)); |
||||
|
||||
} |
||||
} |
||||
} |
||||
#region Copyright notice and license |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 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.Linq; |
||||
using Google.Protobuf.TestProtos; |
||||
using NUnit.Framework; |
||||
using UnitTest.Issues.TestProtos; |
||||
|
||||
namespace Google.Protobuf.Reflection |
||||
{ |
||||
/// <summary> |
||||
/// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the |
||||
/// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...) |
||||
/// </summary> |
||||
public class DescriptorsTest |
||||
{ |
||||
[Test] |
||||
public void FileDescriptor() |
||||
{ |
||||
FileDescriptor file = UnittestProto3.Descriptor; |
||||
|
||||
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); |
||||
Assert.AreEqual("protobuf_unittest", file.Package); |
||||
|
||||
Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); |
||||
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); |
||||
|
||||
// unittest.proto doesn't have any public imports, but unittest_import.proto does. |
||||
Assert.AreEqual(0, file.PublicDependencies.Count); |
||||
Assert.AreEqual(1, UnittestImportProto3.Descriptor.PublicDependencies.Count); |
||||
Assert.AreEqual(UnittestImportPublicProto3.Descriptor, UnittestImportProto3.Descriptor.PublicDependencies[0]); |
||||
|
||||
Assert.AreEqual(1, file.Dependencies.Count); |
||||
Assert.AreEqual(UnittestImportProto3.Descriptor, file.Dependencies[0]); |
||||
|
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
Assert.AreSame(typeof(TestAllTypes), messageType.GeneratedType); |
||||
Assert.AreEqual(messageType, file.MessageTypes[0]); |
||||
Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes")); |
||||
Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType")); |
||||
Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes")); |
||||
for (int i = 0; i < file.MessageTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, file.MessageTypes[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum")); |
||||
Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType")); |
||||
Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum")); |
||||
Assert.AreEqual(1, UnittestImportProto3.Descriptor.EnumTypes.Count); |
||||
Assert.AreEqual("ImportEnum", UnittestImportProto3.Descriptor.EnumTypes[0].Name); |
||||
for (int i = 0; i < file.EnumTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, file.EnumTypes[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(10, file.SerializedData[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void MessageDescriptor() |
||||
{ |
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; |
||||
|
||||
Assert.AreEqual("TestAllTypes", messageType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); |
||||
Assert.AreEqual(UnittestProto3.Descriptor, messageType.File); |
||||
Assert.IsNull(messageType.ContainingType); |
||||
Assert.IsNull(messageType.Proto.Options); |
||||
|
||||
Assert.AreEqual("TestAllTypes", messageType.Name); |
||||
|
||||
Assert.AreEqual("NestedMessage", nestedType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); |
||||
Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); |
||||
Assert.AreEqual(messageType, nestedType.ContainingType); |
||||
|
||||
FieldDescriptor field = messageType.Fields.InDeclarationOrder()[0]; |
||||
Assert.AreEqual("single_int32", field.Name); |
||||
Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("single_int32")); |
||||
Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field")); |
||||
Assert.AreEqual(field, messageType.FindFieldByNumber(1)); |
||||
Assert.Null(messageType.FindFieldByNumber(571283)); |
||||
var fieldsInDeclarationOrder = messageType.Fields.InDeclarationOrder(); |
||||
for (int i = 0; i < fieldsInDeclarationOrder.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, fieldsInDeclarationOrder[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(nestedType, messageType.NestedTypes[0]); |
||||
Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage")); |
||||
Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType")); |
||||
for (int i = 0; i < messageType.NestedTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, messageType.NestedTypes[i].Index); |
||||
} |
||||
|
||||
Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum")); |
||||
Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType")); |
||||
for (int i = 0; i < messageType.EnumTypes.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, messageType.EnumTypes[i].Index); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FieldDescriptor() |
||||
{ |
||||
MessageDescriptor messageType = TestAllTypes.Descriptor; |
||||
FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("single_int32"); |
||||
FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("single_nested_enum"); |
||||
FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message"); |
||||
|
||||
Assert.AreEqual("single_int32", primitiveField.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", |
||||
primitiveField.FullName); |
||||
Assert.AreEqual(1, primitiveField.FieldNumber); |
||||
Assert.AreEqual(messageType, primitiveField.ContainingType); |
||||
Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); |
||||
Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); |
||||
Assert.IsNull(primitiveField.Proto.Options); |
||||
|
||||
Assert.AreEqual("single_nested_enum", enumField.Name); |
||||
Assert.AreEqual(FieldType.Enum, enumField.FieldType); |
||||
// Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); |
||||
|
||||
Assert.AreEqual("single_foreign_message", messageField.Name); |
||||
Assert.AreEqual(FieldType.Message, messageField.FieldType); |
||||
Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); |
||||
} |
||||
|
||||
[Test] |
||||
public void FieldDescriptorLabel() |
||||
{ |
||||
FieldDescriptor singleField = |
||||
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("single_int32"); |
||||
FieldDescriptor repeatedField = |
||||
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32"); |
||||
|
||||
Assert.IsFalse(singleField.IsRepeated); |
||||
Assert.IsTrue(repeatedField.IsRepeated); |
||||
} |
||||
|
||||
[Test] |
||||
public void EnumDescriptor() |
||||
{ |
||||
// Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor |
||||
EnumDescriptor enumType = UnittestProto3.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum"); |
||||
EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum"); |
||||
|
||||
Assert.AreEqual("ForeignEnum", enumType.Name); |
||||
Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); |
||||
Assert.AreEqual(UnittestProto3.Descriptor, enumType.File); |
||||
Assert.Null(enumType.ContainingType); |
||||
Assert.Null(enumType.Proto.Options); |
||||
|
||||
Assert.AreEqual("NestedEnum", nestedType.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", |
||||
nestedType.FullName); |
||||
Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); |
||||
Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); |
||||
|
||||
EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); |
||||
Assert.AreEqual(value, enumType.Values[1]); |
||||
Assert.AreEqual("FOREIGN_FOO", value.Name); |
||||
Assert.AreEqual(4, value.Number); |
||||
Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number); |
||||
Assert.AreEqual(value, enumType.FindValueByNumber(4)); |
||||
Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE")); |
||||
for (int i = 0; i < enumType.Values.Count; i++) |
||||
{ |
||||
Assert.AreEqual(i, enumType.Values[i].Index); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void OneofDescriptor() |
||||
{ |
||||
OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field"); |
||||
Assert.AreEqual("oneof_field", descriptor.Name); |
||||
Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); |
||||
|
||||
var expectedFields = new[] { |
||||
TestAllTypes.OneofBytesFieldNumber, |
||||
TestAllTypes.OneofNestedMessageFieldNumber, |
||||
TestAllTypes.OneofStringFieldNumber, |
||||
TestAllTypes.OneofUint32FieldNumber } |
||||
.Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber)) |
||||
.ToList(); |
||||
foreach (var field in expectedFields) |
||||
{ |
||||
Assert.AreSame(descriptor, field.ContainingOneof); |
||||
} |
||||
|
||||
CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields); |
||||
} |
||||
|
||||
[Test] |
||||
public void ConstructionWithoutGeneratedCodeInfo() |
||||
{ |
||||
var data = UnittestIssues.Descriptor.Proto.ToByteArray(); |
||||
var newDescriptor = Google.Protobuf.Reflection.FileDescriptor.InternalBuildGeneratedFileFrom(data, new Reflection.FileDescriptor[] { }, null); |
||||
|
||||
// We should still be able to get at a field... |
||||
var messageDescriptor = newDescriptor.FindTypeByName<MessageDescriptor>("ItemField"); |
||||
var fieldDescriptor = messageDescriptor.FindFieldByName("item"); |
||||
// But there shouldn't be an accessor (or a generated type for the message) |
||||
Assert.IsNull(fieldDescriptor.Accessor); |
||||
Assert.IsNull(messageDescriptor.GeneratedType); |
||||
} |
||||
|
||||
// From TestFieldOrdering: |
||||
// string my_string = 11; |
||||
// int64 my_int = 1; |
||||
// float my_float = 101; |
||||
// NestedMessage single_nested_message = 200; |
||||
[Test] |
||||
public void FieldListOrderings() |
||||
{ |
||||
var fields = TestFieldOrderings.Descriptor.Fields; |
||||
Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber)); |
||||
Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
#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 |
||||
|
||||
namespace Google.Protobuf |
||||
{ |
||||
// Just a sample enum with positive and negative values to be used in tests. |
||||
internal enum SampleEnum |
||||
{ |
||||
NegativeValue = -2, |
||||
None = 0, |
||||
PositiveValue = 3 |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,162 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: google/protobuf/unittest_import_proto3.proto |
||||
#pragma warning disable 1591, 0612, 3021 |
||||
#region Designer generated code |
||||
|
||||
using pb = global::Google.Protobuf; |
||||
using pbc = global::Google.Protobuf.Collections; |
||||
using pbr = global::Google.Protobuf.Reflection; |
||||
using scg = global::System.Collections.Generic; |
||||
namespace Google.Protobuf.TestProtos { |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public static partial class UnittestImportProto3 { |
||||
|
||||
#region Descriptor |
||||
public static pbr::FileDescriptor Descriptor { |
||||
get { return descriptor; } |
||||
} |
||||
private static pbr::FileDescriptor descriptor; |
||||
|
||||
static UnittestImportProto3() { |
||||
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||
string.Concat( |
||||
"Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90", |
||||
"bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0GjNnb29nbGUvcHJvdG9idWYv", |
||||
"dW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90bzMucHJvdG8iGgoNSW1wb3J0", |
||||
"TWVzc2FnZRIJCgFkGAEgASgFKlkKCkltcG9ydEVudW0SGwoXSU1QT1JUX0VO", |
||||
"VU1fVU5TUEVDSUZJRUQQABIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JB", |
||||
"UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl", |
||||
"c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv", |
||||
"Mw==")); |
||||
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, |
||||
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor, }, |
||||
new pbr::GeneratedCodeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, new pbr::GeneratedCodeInfo[] { |
||||
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.ImportMessage), new[]{ "D" }, null, null, null) |
||||
})); |
||||
} |
||||
#endregion |
||||
|
||||
} |
||||
#region Enums |
||||
public enum ImportEnum { |
||||
IMPORT_ENUM_UNSPECIFIED = 0, |
||||
IMPORT_FOO = 7, |
||||
IMPORT_BAR = 8, |
||||
IMPORT_BAZ = 9, |
||||
} |
||||
|
||||
#endregion |
||||
|
||||
#region Messages |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class ImportMessage : pb::IMessage<ImportMessage> { |
||||
private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage()); |
||||
public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } } |
||||
|
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor.MessageTypes[0]; } |
||||
} |
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
public ImportMessage() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
public ImportMessage(ImportMessage other) : this() { |
||||
d_ = other.d_; |
||||
} |
||||
|
||||
public ImportMessage Clone() { |
||||
return new ImportMessage(this); |
||||
} |
||||
|
||||
public const int DFieldNumber = 1; |
||||
private int d_; |
||||
public int D { |
||||
get { return d_; } |
||||
set { |
||||
d_ = value; |
||||
} |
||||
} |
||||
|
||||
public override bool Equals(object other) { |
||||
return Equals(other as ImportMessage); |
||||
} |
||||
|
||||
public bool Equals(ImportMessage other) { |
||||
if (ReferenceEquals(other, null)) { |
||||
return false; |
||||
} |
||||
if (ReferenceEquals(other, this)) { |
||||
return true; |
||||
} |
||||
if (D != other.D) return false; |
||||
return true; |
||||
} |
||||
|
||||
public override int GetHashCode() { |
||||
int hash = 1; |
||||
if (D != 0) hash ^= D.GetHashCode(); |
||||
return hash; |
||||
} |
||||
|
||||
public override string ToString() { |
||||
return pb::JsonFormatter.Default.Format(this); |
||||
} |
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) { |
||||
if (D != 0) { |
||||
output.WriteRawTag(8); |
||||
output.WriteInt32(D); |
||||
} |
||||
} |
||||
|
||||
public int CalculateSize() { |
||||
int size = 0; |
||||
if (D != 0) { |
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(D); |
||||
} |
||||
return size; |
||||
} |
||||
|
||||
public void MergeFrom(ImportMessage other) { |
||||
if (other == null) { |
||||
return; |
||||
} |
||||
if (other.D != 0) { |
||||
D = other.D; |
||||
} |
||||
} |
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) { |
||||
uint tag; |
||||
while (input.ReadTag(out tag)) { |
||||
switch(tag) { |
||||
case 0: |
||||
throw pb::InvalidProtocolBufferException.InvalidTag(); |
||||
default: |
||||
if (pb::WireFormat.IsEndGroupTag(tag)) { |
||||
return; |
||||
} |
||||
break; |
||||
case 8: { |
||||
D = input.ReadInt32(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
#endregion |
||||
|
||||
} |
||||
|
||||
#endregion Designer generated code |
@ -0,0 +1,148 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: google/protobuf/unittest_import_public_proto3.proto |
||||
#pragma warning disable 1591, 0612, 3021 |
||||
#region Designer generated code |
||||
|
||||
using pb = global::Google.Protobuf; |
||||
using pbc = global::Google.Protobuf.Collections; |
||||
using pbr = global::Google.Protobuf.Reflection; |
||||
using scg = global::System.Collections.Generic; |
||||
namespace Google.Protobuf.TestProtos { |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public static partial class UnittestImportPublicProto3 { |
||||
|
||||
#region Descriptor |
||||
public static pbr::FileDescriptor Descriptor { |
||||
get { return descriptor; } |
||||
} |
||||
private static pbr::FileDescriptor descriptor; |
||||
|
||||
static UnittestImportPublicProto3() { |
||||
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||
string.Concat( |
||||
"CjNnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90", |
||||
"bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ", |
||||
"bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1", |
||||
"Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); |
||||
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, |
||||
new pbr::FileDescriptor[] { }, |
||||
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { |
||||
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), new[]{ "E" }, null, null, null) |
||||
})); |
||||
} |
||||
#endregion |
||||
|
||||
} |
||||
#region Messages |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> { |
||||
private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage()); |
||||
public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } } |
||||
|
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor.MessageTypes[0]; } |
||||
} |
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
public PublicImportMessage() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
public PublicImportMessage(PublicImportMessage other) : this() { |
||||
e_ = other.e_; |
||||
} |
||||
|
||||
public PublicImportMessage Clone() { |
||||
return new PublicImportMessage(this); |
||||
} |
||||
|
||||
public const int EFieldNumber = 1; |
||||
private int e_; |
||||
public int E { |
||||
get { return e_; } |
||||
set { |
||||
e_ = value; |
||||
} |
||||
} |
||||
|
||||
public override bool Equals(object other) { |
||||
return Equals(other as PublicImportMessage); |
||||
} |
||||
|
||||
public bool Equals(PublicImportMessage other) { |
||||
if (ReferenceEquals(other, null)) { |
||||
return false; |
||||
} |
||||
if (ReferenceEquals(other, this)) { |
||||
return true; |
||||
} |
||||
if (E != other.E) return false; |
||||
return true; |
||||
} |
||||
|
||||
public override int GetHashCode() { |
||||
int hash = 1; |
||||
if (E != 0) hash ^= E.GetHashCode(); |
||||
return hash; |
||||
} |
||||
|
||||
public override string ToString() { |
||||
return pb::JsonFormatter.Default.Format(this); |
||||
} |
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) { |
||||
if (E != 0) { |
||||
output.WriteRawTag(8); |
||||
output.WriteInt32(E); |
||||
} |
||||
} |
||||
|
||||
public int CalculateSize() { |
||||
int size = 0; |
||||
if (E != 0) { |
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(E); |
||||
} |
||||
return size; |
||||
} |
||||
|
||||
public void MergeFrom(PublicImportMessage other) { |
||||
if (other == null) { |
||||
return; |
||||
} |
||||
if (other.E != 0) { |
||||
E = other.E; |
||||
} |
||||
} |
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) { |
||||
uint tag; |
||||
while (input.ReadTag(out tag)) { |
||||
switch(tag) { |
||||
case 0: |
||||
throw pb::InvalidProtocolBufferException.InvalidTag(); |
||||
default: |
||||
if (pb::WireFormat.IsEndGroupTag(tag)) { |
||||
return; |
||||
} |
||||
break; |
||||
case 8: { |
||||
E = input.ReadInt32(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
#endregion |
||||
|
||||
} |
||||
|
||||
#endregion Designer generated code |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@ |
||||
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||
# Visual Studio 2013 |
||||
VisualStudioVersion = 12.0.31101.0 |
||||
MinimumVisualStudioVersion = 10.0.40219.1 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{6908BDCE-D925-43F3-94AC-A531E6DF2591}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{DD01ED24-3750-4567-9A23-1DB676A15610}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{A31F5FB2-4FF3-432A-B35B-5CD203606311}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}" |
||||
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 |
||||
EndGlobalSection |
||||
GlobalSection(SolutionProperties) = preSolution |
||||
HideSolutionNode = FALSE |
||||
EndGlobalSection |
||||
EndGlobal |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,304 @@ |
||||
#region Copyright notice and license |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 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; |
||||
|
||||
namespace Google.Protobuf |
||||
{ |
||||
// This part of CodedOutputStream provides all the static entry points that are used |
||||
// by generated code and internally to compute the size of messages prior to being |
||||
// written to an instance of CodedOutputStream. |
||||
public sealed partial class CodedOutputStream |
||||
{ |
||||
private const int LittleEndian64Size = 8; |
||||
private const int LittleEndian32Size = 4; |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// double field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeDoubleSize(double value) |
||||
{ |
||||
return LittleEndian64Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// float field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeFloatSize(float value) |
||||
{ |
||||
return LittleEndian32Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// uint64 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeUInt64Size(ulong value) |
||||
{ |
||||
return ComputeRawVarint64Size(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// int64 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeInt64Size(long value) |
||||
{ |
||||
return ComputeRawVarint64Size((ulong) value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// int32 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeInt32Size(int value) |
||||
{ |
||||
if (value >= 0) |
||||
{ |
||||
return ComputeRawVarint32Size((uint) value); |
||||
} |
||||
else |
||||
{ |
||||
// Must sign-extend. |
||||
return 10; |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// fixed64 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeFixed64Size(ulong value) |
||||
{ |
||||
return LittleEndian64Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// fixed32 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeFixed32Size(uint value) |
||||
{ |
||||
return LittleEndian32Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// bool field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeBoolSize(bool value) |
||||
{ |
||||
return 1; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// string field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeStringSize(String value) |
||||
{ |
||||
int byteArraySize = Utf8Encoding.GetByteCount(value); |
||||
return ComputeLengthSize(byteArraySize) + byteArraySize; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// group field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeGroupSize(IMessage value) |
||||
{ |
||||
return value.CalculateSize(); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// embedded message field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeMessageSize(IMessage value) |
||||
{ |
||||
int size = value.CalculateSize(); |
||||
return ComputeLengthSize(size) + size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// bytes field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeBytesSize(ByteString value) |
||||
{ |
||||
return ComputeLengthSize(value.Length) + value.Length; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// uint32 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeUInt32Size(uint value) |
||||
{ |
||||
return ComputeRawVarint32Size(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a |
||||
/// enum field, including the tag. The caller is responsible for |
||||
/// converting the enum value to its numeric value. |
||||
/// </summary> |
||||
public static int ComputeEnumSize(int value) |
||||
{ |
||||
// Currently just a pass-through, but it's nice to separate it logically. |
||||
return ComputeInt32Size(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// sfixed32 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeSFixed32Size(int value) |
||||
{ |
||||
return LittleEndian32Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// sfixed64 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeSFixed64Size(long value) |
||||
{ |
||||
return LittleEndian64Size; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// sint32 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeSInt32Size(int value) |
||||
{ |
||||
return ComputeRawVarint32Size(EncodeZigZag32(value)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode an |
||||
/// sint64 field, including the tag. |
||||
/// </summary> |
||||
public static int ComputeSInt64Size(long value) |
||||
{ |
||||
return ComputeRawVarint64Size(EncodeZigZag64(value)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a length, |
||||
/// as written by <see cref="WriteLength"/>. |
||||
/// </summary> |
||||
public static int ComputeLengthSize(int length) |
||||
{ |
||||
return ComputeRawVarint32Size((uint) length); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a varint. |
||||
/// </summary> |
||||
public static int ComputeRawVarint32Size(uint value) |
||||
{ |
||||
if ((value & (0xffffffff << 7)) == 0) |
||||
{ |
||||
return 1; |
||||
} |
||||
if ((value & (0xffffffff << 14)) == 0) |
||||
{ |
||||
return 2; |
||||
} |
||||
if ((value & (0xffffffff << 21)) == 0) |
||||
{ |
||||
return 3; |
||||
} |
||||
if ((value & (0xffffffff << 28)) == 0) |
||||
{ |
||||
return 4; |
||||
} |
||||
return 5; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a varint. |
||||
/// </summary> |
||||
public static int ComputeRawVarint64Size(ulong value) |
||||
{ |
||||
if ((value & (0xffffffffffffffffL << 7)) == 0) |
||||
{ |
||||
return 1; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 14)) == 0) |
||||
{ |
||||
return 2; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 21)) == 0) |
||||
{ |
||||
return 3; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 28)) == 0) |
||||
{ |
||||
return 4; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 35)) == 0) |
||||
{ |
||||
return 5; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 42)) == 0) |
||||
{ |
||||
return 6; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 49)) == 0) |
||||
{ |
||||
return 7; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 56)) == 0) |
||||
{ |
||||
return 8; |
||||
} |
||||
if ((value & (0xffffffffffffffffL << 63)) == 0) |
||||
{ |
||||
return 9; |
||||
} |
||||
return 10; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Computes the number of bytes that would be needed to encode a tag. |
||||
/// </summary> |
||||
public static int ComputeTagSize(int fieldNumber) |
||||
{ |
||||
return ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,695 @@ |
||||
#region Copyright notice and license |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 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; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace Google.Protobuf |
||||
{ |
||||
/// <summary> |
||||
/// Encodes and writes protocol message fields. |
||||
/// </summary> |
||||
/// <remarks> |
||||
/// This class contains two kinds of methods: methods that write specific |
||||
/// protocol message constructs and field types (e.g. WriteTag and |
||||
/// WriteInt32) and methods that write low-level values (e.g. |
||||
/// WriteRawVarint32 and WriteRawBytes). If you are writing encoded protocol |
||||
/// messages, you should use the former methods, but if you are writing some |
||||
/// other format of your own design, use the latter. The names of the former |
||||
/// methods are taken from the protocol buffer type names, not .NET types. |
||||
/// (Hence WriteFloat instead of WriteSingle, and WriteBool instead of WriteBoolean.) |
||||
/// </remarks> |
||||
public sealed partial class CodedOutputStream |
||||
{ |
||||
// "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.) |
||||
internal static readonly Encoding Utf8Encoding = Encoding.UTF8; |
||||
|
||||
/// <summary> |
||||
/// The buffer size used by CreateInstance(Stream). |
||||
/// </summary> |
||||
public static readonly int DefaultBufferSize = 4096; |
||||
|
||||
private readonly byte[] buffer; |
||||
private readonly int limit; |
||||
private int position; |
||||
private readonly Stream output; |
||||
|
||||
#region Construction |
||||
/// <summary> |
||||
/// Creates a new CodedOutputStream that writes directly to the given |
||||
/// byte array. If more bytes are written than fit in the array, |
||||
/// OutOfSpaceException will be thrown. |
||||
/// </summary> |
||||
public CodedOutputStream(byte[] flatArray) : this(flatArray, 0, flatArray.Length) |
||||
{ |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Creates a new CodedOutputStream that writes directly to the given |
||||
/// byte array slice. If more bytes are written than fit in the array, |
||||
/// OutOfSpaceException will be thrown. |
||||
/// </summary> |
||||
private CodedOutputStream(byte[] buffer, int offset, int length) |
||||
{ |
||||
this.output = null; |
||||
this.buffer = buffer; |
||||
this.position = offset; |
||||
this.limit = offset + length; |
||||
} |
||||
|
||||
private CodedOutputStream(Stream output, byte[] buffer) |
||||
{ |
||||
this.output = output; |
||||
this.buffer = buffer; |
||||
this.position = 0; |
||||
this.limit = buffer.Length; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Creates a new CodedOutputStream which write to the given stream. |
||||
/// </summary> |
||||
public CodedOutputStream(Stream output) : this(output, DefaultBufferSize) |
||||
{ |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Creates a new CodedOutputStream which write to the given stream and uses |
||||
/// the specified buffer size. |
||||
/// </summary> |
||||
public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize]) |
||||
{ |
||||
} |
||||
#endregion |
||||
|
||||
/// <summary> |
||||
/// Returns the current position in the stream, or the position in the output buffer |
||||
/// </summary> |
||||
public long Position |
||||
{ |
||||
get |
||||
{ |
||||
if (output != null) |
||||
{ |
||||
return output.Position + position; |
||||
} |
||||
return position; |
||||
} |
||||
} |
||||
|
||||
#region Writing of values (not including tags) |
||||
|
||||
/// <summary> |
||||
/// Writes a double field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteDouble(double value) |
||||
{ |
||||
WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a float field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteFloat(float value) |
||||
{ |
||||
byte[] rawBytes = BitConverter.GetBytes(value); |
||||
if (!BitConverter.IsLittleEndian) |
||||
{ |
||||
ByteArray.Reverse(rawBytes); |
||||
} |
||||
|
||||
if (limit - position >= 4) |
||||
{ |
||||
buffer[position++] = rawBytes[0]; |
||||
buffer[position++] = rawBytes[1]; |
||||
buffer[position++] = rawBytes[2]; |
||||
buffer[position++] = rawBytes[3]; |
||||
} |
||||
else |
||||
{ |
||||
WriteRawBytes(rawBytes, 0, 4); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a uint64 field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteUInt64(ulong value) |
||||
{ |
||||
WriteRawVarint64(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an int64 field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteInt64(long value) |
||||
{ |
||||
WriteRawVarint64((ulong) value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an int32 field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteInt32(int value) |
||||
{ |
||||
if (value >= 0) |
||||
{ |
||||
WriteRawVarint32((uint) value); |
||||
} |
||||
else |
||||
{ |
||||
// Must sign-extend. |
||||
WriteRawVarint64((ulong) value); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a fixed64 field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteFixed64(ulong value) |
||||
{ |
||||
WriteRawLittleEndian64(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a fixed32 field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteFixed32(uint value) |
||||
{ |
||||
WriteRawLittleEndian32(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a bool field value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteBool(bool value) |
||||
{ |
||||
WriteRawByte(value ? (byte) 1 : (byte) 0); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a string field value, without a tag, to the stream. |
||||
/// The data is length-prefixed. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteString(string value) |
||||
{ |
||||
// Optimise the case where we have enough space to write |
||||
// the string directly to the buffer, which should be common. |
||||
int length = Utf8Encoding.GetByteCount(value); |
||||
WriteLength(length); |
||||
if (limit - position >= length) |
||||
{ |
||||
if (length == value.Length) // Must be all ASCII... |
||||
{ |
||||
for (int i = 0; i < length; i++) |
||||
{ |
||||
buffer[position + i] = (byte)value[i]; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position); |
||||
} |
||||
position += length; |
||||
} |
||||
else |
||||
{ |
||||
byte[] bytes = Utf8Encoding.GetBytes(value); |
||||
WriteRawBytes(bytes); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a message, without a tag, to the stream. |
||||
/// The data is length-prefixed. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteMessage(IMessage value) |
||||
{ |
||||
WriteLength(value.CalculateSize()); |
||||
value.WriteTo(this); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Write a byte string, without a tag, to the stream. |
||||
/// The data is length-prefixed. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteBytes(ByteString value) |
||||
{ |
||||
WriteLength(value.Length); |
||||
value.WriteRawBytesTo(this); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a uint32 value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteUInt32(uint value) |
||||
{ |
||||
WriteRawVarint32(value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an enum value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteEnum(int value) |
||||
{ |
||||
WriteInt32(value); |
||||
} |
||||
|
||||
public void WriteSFixed32(int value) |
||||
{ |
||||
WriteRawLittleEndian32((uint) value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an sfixed64 value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteSFixed64(long value) |
||||
{ |
||||
WriteRawLittleEndian64((ulong) value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an sint32 value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteSInt32(int value) |
||||
{ |
||||
WriteRawVarint32(EncodeZigZag32(value)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an sint64 value, without a tag, to the stream. |
||||
/// </summary> |
||||
/// <param name="value">The value to write</param> |
||||
public void WriteSInt64(long value) |
||||
{ |
||||
WriteRawVarint64(EncodeZigZag64(value)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes a length (in bytes) for length-delimited data. |
||||
/// </summary> |
||||
/// <remarks> |
||||
/// This method simply writes a rawint, but exists for clarity in calling code. |
||||
/// </remarks> |
||||
/// <param name="length">Length value, in bytes.</param> |
||||
public void WriteLength(int length) |
||||
{ |
||||
WriteRawVarint32((uint) length); |
||||
} |
||||
|
||||
#endregion |
||||
|
||||
#region Raw tag writing |
||||
/// <summary> |
||||
/// Encodes and writes a tag. |
||||
/// </summary> |
||||
/// <param name="fieldNumber">The number of the field to write the tag for</param> |
||||
/// <param name="type">The wire format type of the tag to write</param> |
||||
public void WriteTag(int fieldNumber, WireFormat.WireType type) |
||||
{ |
||||
WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes an already-encoded tag. |
||||
/// </summary> |
||||
/// <param name="tag">The encoded tag</param> |
||||
public void WriteTag(uint tag) |
||||
{ |
||||
WriteRawVarint32(tag); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes the given single-byte tag directly to the stream. |
||||
/// </summary> |
||||
/// <param name="b1">The encoded tag</param> |
||||
public void WriteRawTag(byte b1) |
||||
{ |
||||
WriteRawByte(b1); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes the given two-byte tag directly to the stream. |
||||
/// </summary> |
||||
/// <param name="b1">The first byte of the encoded tag</param> |
||||
/// <param name="b2">The second byte of the encoded tag</param> |
||||
public void WriteRawTag(byte b1, byte b2) |
||||
{ |
||||
WriteRawByte(b1); |
||||
WriteRawByte(b2); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes the given three-byte tag directly to the stream. |
||||
/// </summary> |
||||
/// <param name="b1">The first byte of the encoded tag</param> |
||||
/// <param name="b2">The second byte of the encoded tag</param> |
||||
/// <param name="b3">The third byte of the encoded tag</param> |
||||
public void WriteRawTag(byte b1, byte b2, byte b3) |
||||
{ |
||||
WriteRawByte(b1); |
||||
WriteRawByte(b2); |
||||
WriteRawByte(b3); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes the given four-byte tag directly to the stream. |
||||
/// </summary> |
||||
/// <param name="b1">The first byte of the encoded tag</param> |
||||
/// <param name="b2">The second byte of the encoded tag</param> |
||||
/// <param name="b3">The third byte of the encoded tag</param> |
||||
/// <param name="b4">The fourth byte of the encoded tag</param> |
||||
public void WriteRawTag(byte b1, byte b2, byte b3, byte b4) |
||||
{ |
||||
WriteRawByte(b1); |
||||
WriteRawByte(b2); |
||||
WriteRawByte(b3); |
||||
WriteRawByte(b4); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes the given five-byte tag directly to the stream. |
||||
/// </summary> |
||||
/// <param name="b1">The first byte of the encoded tag</param> |
||||
/// <param name="b2">The second byte of the encoded tag</param> |
||||
/// <param name="b3">The third byte of the encoded tag</param> |
||||
/// <param name="b4">The fourth byte of the encoded tag</param> |
||||
/// <param name="b5">The fifth byte of the encoded tag</param> |
||||
public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5) |
||||
{ |
||||
WriteRawByte(b1); |
||||
WriteRawByte(b2); |
||||
WriteRawByte(b3); |
||||
WriteRawByte(b4); |
||||
WriteRawByte(b5); |
||||
} |
||||
#endregion |
||||
|
||||
#region Underlying writing primitives |
||||
/// <summary> |
||||
/// Writes a 32 bit value as a varint. The fast route is taken when |
||||
/// there's enough buffer space left to whizz through without checking |
||||
/// for each byte; otherwise, we resort to calling WriteRawByte each time. |
||||
/// </summary> |
||||
internal void WriteRawVarint32(uint value) |
||||
{ |
||||
// Optimize for the common case of a single byte value |
||||
if (value < 128 && position < limit) |
||||
{ |
||||
buffer[position++] = (byte)value; |
||||
return; |
||||
} |
||||
|
||||
while (value > 127 && position < limit) |
||||
{ |
||||
buffer[position++] = (byte) ((value & 0x7F) | 0x80); |
||||
value >>= 7; |
||||
} |
||||
while (value > 127) |
||||
{ |
||||
WriteRawByte((byte) ((value & 0x7F) | 0x80)); |
||||
value >>= 7; |
||||
} |
||||
if (position < limit) |
||||
{ |
||||
buffer[position++] = (byte) value; |
||||
} |
||||
else |
||||
{ |
||||
WriteRawByte((byte) value); |
||||
} |
||||
} |
||||
|
||||
internal void WriteRawVarint64(ulong value) |
||||
{ |
||||
while (value > 127 && position < limit) |
||||
{ |
||||
buffer[position++] = (byte) ((value & 0x7F) | 0x80); |
||||
value >>= 7; |
||||
} |
||||
while (value > 127) |
||||
{ |
||||
WriteRawByte((byte) ((value & 0x7F) | 0x80)); |
||||
value >>= 7; |
||||
} |
||||
if (position < limit) |
||||
{ |
||||
buffer[position++] = (byte) value; |
||||
} |
||||
else |
||||
{ |
||||
WriteRawByte((byte) value); |
||||
} |
||||
} |
||||
|
||||
internal void WriteRawLittleEndian32(uint value) |
||||
{ |
||||
if (position + 4 > limit) |
||||
{ |
||||
WriteRawByte((byte) value); |
||||
WriteRawByte((byte) (value >> 8)); |
||||
WriteRawByte((byte) (value >> 16)); |
||||
WriteRawByte((byte) (value >> 24)); |
||||
} |
||||
else |
||||
{ |
||||
buffer[position++] = ((byte) value); |
||||
buffer[position++] = ((byte) (value >> 8)); |
||||
buffer[position++] = ((byte) (value >> 16)); |
||||
buffer[position++] = ((byte) (value >> 24)); |
||||
} |
||||
} |
||||
|
||||
internal void WriteRawLittleEndian64(ulong value) |
||||
{ |
||||
if (position + 8 > limit) |
||||
{ |
||||
WriteRawByte((byte) value); |
||||
WriteRawByte((byte) (value >> 8)); |
||||
WriteRawByte((byte) (value >> 16)); |
||||
WriteRawByte((byte) (value >> 24)); |
||||
WriteRawByte((byte) (value >> 32)); |
||||
WriteRawByte((byte) (value >> 40)); |
||||
WriteRawByte((byte) (value >> 48)); |
||||
WriteRawByte((byte) (value >> 56)); |
||||
} |
||||
else |
||||
{ |
||||
buffer[position++] = ((byte) value); |
||||
buffer[position++] = ((byte) (value >> 8)); |
||||
buffer[position++] = ((byte) (value >> 16)); |
||||
buffer[position++] = ((byte) (value >> 24)); |
||||
buffer[position++] = ((byte) (value >> 32)); |
||||
buffer[position++] = ((byte) (value >> 40)); |
||||
buffer[position++] = ((byte) (value >> 48)); |
||||
buffer[position++] = ((byte) (value >> 56)); |
||||
} |
||||
} |
||||
|
||||
internal void WriteRawByte(byte value) |
||||
{ |
||||
if (position == limit) |
||||
{ |
||||
RefreshBuffer(); |
||||
} |
||||
|
||||
buffer[position++] = value; |
||||
} |
||||
|
||||
internal void WriteRawByte(uint value) |
||||
{ |
||||
WriteRawByte((byte) value); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes out an array of bytes. |
||||
/// </summary> |
||||
internal void WriteRawBytes(byte[] value) |
||||
{ |
||||
WriteRawBytes(value, 0, value.Length); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Writes out part of an array of bytes. |
||||
/// </summary> |
||||
internal void WriteRawBytes(byte[] value, int offset, int length) |
||||
{ |
||||
if (limit - position >= length) |
||||
{ |
||||
ByteArray.Copy(value, offset, buffer, position, length); |
||||
// We have room in the current buffer. |
||||
position += length; |
||||
} |
||||
else |
||||
{ |
||||
// Write extends past current buffer. Fill the rest of this buffer and |
||||
// flush. |
||||
int bytesWritten = limit - position; |
||||
ByteArray.Copy(value, offset, buffer, position, bytesWritten); |
||||
offset += bytesWritten; |
||||
length -= bytesWritten; |
||||
position = limit; |
||||
RefreshBuffer(); |
||||
|
||||
// Now deal with the rest. |
||||
// Since we have an output stream, this is our buffer |
||||
// and buffer offset == 0 |
||||
if (length <= limit) |
||||
{ |
||||
// Fits in new buffer. |
||||
ByteArray.Copy(value, offset, buffer, 0, length); |
||||
position = length; |
||||
} |
||||
else |
||||
{ |
||||
// Write is very big. Let's do it all at once. |
||||
output.Write(value, offset, length); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endregion |
||||
|
||||
/// <summary> |
||||
/// Encode a 32-bit value with ZigZag encoding. |
||||
/// </summary> |
||||
/// <remarks> |
||||
/// ZigZag encodes signed integers into values that can be efficiently |
||||
/// encoded with varint. (Otherwise, negative values must be |
||||
/// sign-extended to 64 bits to be varint encoded, thus always taking |
||||
/// 10 bytes on the wire.) |
||||
/// </remarks> |
||||
internal static uint EncodeZigZag32(int n) |
||||
{ |
||||
// Note: the right-shift must be arithmetic |
||||
return (uint) ((n << 1) ^ (n >> 31)); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Encode a 64-bit value with ZigZag encoding. |
||||
/// </summary> |
||||
/// <remarks> |
||||
/// ZigZag encodes signed integers into values that can be efficiently |
||||
/// encoded with varint. (Otherwise, negative values must be |
||||
/// sign-extended to 64 bits to be varint encoded, thus always taking |
||||
/// 10 bytes on the wire.) |
||||
/// </remarks> |
||||
internal static ulong EncodeZigZag64(long n) |
||||
{ |
||||
return (ulong) ((n << 1) ^ (n >> 63)); |
||||
} |
||||
|
||||
private void RefreshBuffer() |
||||
{ |
||||
if (output == null) |
||||
{ |
||||
// We're writing to a single buffer. |
||||
throw new OutOfSpaceException(); |
||||
} |
||||
|
||||
// Since we have an output stream, this is our buffer |
||||
// and buffer offset == 0 |
||||
output.Write(buffer, 0, position); |
||||
position = 0; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Indicates that a CodedOutputStream wrapping a flat byte array |
||||
/// ran out of space. |
||||
/// </summary> |
||||
public sealed class OutOfSpaceException : IOException |
||||
{ |
||||
internal OutOfSpaceException() |
||||
: base("CodedOutputStream was writing to a flat byte array and ran out of space.") |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public void Flush() |
||||
{ |
||||
if (output != null) |
||||
{ |
||||
RefreshBuffer(); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Verifies that SpaceLeft returns zero. It's common to create a byte array |
||||
/// that is exactly big enough to hold a message, then write to it with |
||||
/// a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that |
||||
/// the message was actually as big as expected, which can help bugs. |
||||
/// </summary> |
||||
public void CheckNoSpaceLeft() |
||||
{ |
||||
if (SpaceLeft != 0) |
||||
{ |
||||
throw new InvalidOperationException("Did not write as much data as expected."); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// If writing to a flat array, returns the space left in the array. Otherwise, |
||||
/// throws an InvalidOperationException. |
||||
/// </summary> |
||||
public int SpaceLeft |
||||
{ |
||||
get |
||||
{ |
||||
if (output == null) |
||||
{ |
||||
return limit - position; |
||||
} |
||||
else |
||||
{ |
||||
throw new InvalidOperationException( |
||||
"SpaceLeft can only be called on CodedOutputStreams that are " + |
||||
"writing to a flat array."); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
<?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-alpha4</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> |
||||
</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="**\*.cs" target="src" /> |
||||
<file src="..\..\..\cmake\Release\protoc.exe" target="tools" /> |
||||
<file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\api.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\duration.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\empty.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\field_mask.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\source_context.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\struct.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\timestamp.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\type.proto" target="tools\google\protobuf" /> |
||||
<file src="..\..\..\src\google\protobuf\wrappers.proto" target="tools\google\protobuf" /> |
||||
</files> |
||||
</package> |
@ -0,0 +1,110 @@ |
||||
#region Copyright notice and license |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 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; |
||||
using Google.Protobuf.Reflection; |
||||
|
||||
namespace Google.Protobuf |
||||
{ |
||||
|
||||
// TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage? |
||||
// TODO(jonskeet): Split these interfaces into separate files when we're happy with them. |
||||
|
||||
/// <summary> |
||||
/// Interface for a Protocol Buffers message, supporting |
||||
/// basic operations required for serialization. |
||||
/// </summary> |
||||
public interface IMessage |
||||
{ |
||||
/// <summary> |
||||
/// Merges the data from the specified coded input stream with the current message. |
||||
/// </summary> |
||||
/// <remarks>See the user guide for precise merge semantics.</remarks> |
||||
/// <param name="input"></param> |
||||
void MergeFrom(CodedInputStream input); |
||||
|
||||
/// <summary> |
||||
/// Writes the data to the given coded output stream. |
||||
/// </summary> |
||||
/// <param name="output">Coded output stream to write the data to. Must not be null.</param> |
||||
void WriteTo(CodedOutputStream output); |
||||
|
||||
/// <summary> |
||||
/// Calculates the size of this message in Protocol Buffer wire format, in bytes. |
||||
/// </summary> |
||||
/// <returns>The number of bytes required to write this message |
||||
/// to a coded output stream.</returns> |
||||
int CalculateSize(); |
||||
|
||||
/// <summary> |
||||
/// Descriptor for this message. All instances are expected to return the same descriptor, |
||||
/// and for generated types this will be an explicitly-implemented member, returning the |
||||
/// same value as the static property declared on the type. |
||||
/// </summary> |
||||
MessageDescriptor Descriptor { get; } |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Generic interface for a Protocol Buffers message, |
||||
/// where the type parameter is expected to be the same type as |
||||
/// the implementation class. |
||||
/// </summary> |
||||
/// <typeparam name="T">The message type.</typeparam> |
||||
public interface IMessage<T> : IMessage, IEquatable<T>, IDeepCloneable<T> where T : IMessage<T> |
||||
{ |
||||
/// <summary> |
||||
/// Merges the given message into this one. |
||||
/// </summary> |
||||
/// <remarks>See the user guide for precise merge semantics.</remarks> |
||||
/// <param name="message">The message to merge with this one. Must not be null.</param> |
||||
void MergeFrom(T message); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Generic interface for a deeply cloneable type. |
||||
/// <summary> |
||||
/// <remarks> |
||||
/// All generated messages implement this interface, but so do some non-message types. |
||||
/// Additionally, due to the type constraint on <c>T</c> in <see cref="IMessage{T}"/>, |
||||
/// it is simpler to keep this as a separate interface. |
||||
/// </para> |
||||
/// </remarks> |
||||
/// <typeparam name="T">The type itself, returned by the <see cref="Clone"/> method.</typeparam> |
||||
public interface IDeepCloneable<T> |
||||
{ |
||||
/// <summary> |
||||
/// Creates a deep clone of this object. |
||||
/// </summary> |
||||
/// <returns>A deep clone of this object.</returns> |
||||
T Clone(); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue