Merge pull request #373 from jtattermusch/csharp_generate_proto
C# generate_proto.sh and buildall.sh scriptspull/379/head
commit
98de125a7c
19 changed files with 147 additions and 12118 deletions
@ -0,0 +1,22 @@ |
||||
#!/bin/bash |
||||
# Use mono to build solution and run all tests. |
||||
|
||||
# Adjust these to reflect the location of nunit-console in your system. |
||||
NUNIT_CONSOLE=nunit-console |
||||
|
||||
# The rest you can leave intact |
||||
CONFIG=Release |
||||
KEYFILE=../keys/Google.ProtocolBuffers.snk # TODO(jtattermusch): signing! |
||||
SRC=$(dirname $0)/src |
||||
|
||||
set -ex |
||||
|
||||
echo Building the solution. |
||||
xbuild /p:Configuration=$CONFIG $SRC/ProtocolBuffers.sln |
||||
|
||||
echo Running tests. |
||||
$NUNIT_CONSOLE $SRC/ProtocolBuffers.Test/bin/$CONFIG/Google.ProtocolBuffers.Test.dll |
||||
|
||||
$NUNIT_CONSOLE $SRC/ProtocolBuffersLite.Test/bin/$CONFIG/Google.ProtocolBuffersLite.Test.dll |
||||
|
||||
$NUNIT_CONSOLE $SRC/ProtocolBuffersLite.Test/bin/$CONFIG/Google.ProtocolBuffersMixedLite.Test.dll |
@ -0,0 +1,52 @@ |
||||
#!/bin/bash |
||||
# Generates C# source files from .proto files. |
||||
# You first need to make sure protoc has been built (see instructions on |
||||
# building protoc in root of this repository) |
||||
|
||||
set -ex |
||||
|
||||
# cd to repository root |
||||
cd $(dirname $0)/.. |
||||
|
||||
# protocol buffer compiler to use |
||||
PROTOC=src/protoc |
||||
|
||||
# Descriptor proto |
||||
#TODO(jtattermusch): generate descriptor.proto |
||||
|
||||
# ProtocolBuffers.Test protos |
||||
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ |
||||
src/google/protobuf/unittest.proto \ |
||||
src/google/protobuf/unittest_custom_options.proto \ |
||||
src/google/protobuf/unittest_drop_unknown_fields.proto \ |
||||
src/google/protobuf/unittest_enormous_descriptor.proto \ |
||||
src/google/protobuf/unittest_import.proto \ |
||||
src/google/protobuf/unittest_import_public.proto \ |
||||
src/google/protobuf/unittest_mset.proto \ |
||||
src/google/protobuf/unittest_optimize_for.proto \ |
||||
src/google/protobuf/unknown_enum_test.proto |
||||
|
||||
$PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ |
||||
csharp/protos/extest/unittest_extras_xmltest.proto \ |
||||
csharp/protos/extest/unittest_issues.proto |
||||
|
||||
$PROTOC -Icsharp --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ |
||||
csharp/protos/google/protobuf/field_presence_test.proto |
||||
|
||||
$PROTOC -Ibenchmarks --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ |
||||
benchmarks/google_size.proto \ |
||||
benchmarks/google_speed.proto |
||||
|
||||
# ProtocolBuffersLite.Test protos |
||||
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ |
||||
src/google/protobuf/unittest.proto \ |
||||
src/google/protobuf/unittest_import.proto \ |
||||
src/google/protobuf/unittest_import_lite.proto \ |
||||
src/google/protobuf/unittest_import_public.proto \ |
||||
src/google/protobuf/unittest_import_public_lite.proto \ |
||||
src/google/protobuf/unittest_lite.proto \ |
||||
src/google/protobuf/unittest_lite_imports_nonlite.proto |
||||
|
||||
$PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ |
||||
csharp/protos/extest/unittest_extras_full.proto \ |
||||
csharp/protos/extest/unittest_extras_lite.proto |
@ -1,37 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
# Adjust these to reflect the location of NUnit in your system, |
||||
# and how you want NUnit to run |
||||
NUNIT=~/protobuf/NUnit-2.5.0.9122/bin/net-2.0/nunit-console.exe |
||||
NUNIT_OPTIONS=-noshadow |
||||
|
||||
# The rest should be okay. |
||||
|
||||
SRC=../src |
||||
LIB=../lib |
||||
KEYFILE=../keys/Google.ProtocolBuffers.snk |
||||
|
||||
rm -rf bin |
||||
mkdir bin |
||||
|
||||
# Running the unit tests requires the dependencies are |
||||
# in the bin directory too |
||||
cp -f $LIB/{Rhino.Mocks.dll,nunit.framework.dll} bin |
||||
|
||||
echo Building main library |
||||
gmcs -target:library -out:bin/Google.ProtocolBuffers.dll `find $SRC/ProtocolBuffers -name '*.cs'` -keyfile:$KEYFILE |
||||
|
||||
echo Building main library tests |
||||
gmcs -target:library -out:bin/Google.ProtocolBuffers.Test.dll `find $SRC/ProtocolBuffers.Test -name '*.cs'` -keyfile:$KEYFILE -r:bin/Google.ProtocolBuffers.dll -r:$LIB/nunit.framework.dll -r:$LIB/Rhino.Mocks.dll |
||||
|
||||
echo Running main library tests |
||||
mono $NUNIT bin/Google.ProtocolBuffers.Test.dll $NUNIT_OPTIONS |
||||
|
||||
echo Building ProtoGen |
||||
gmcs -target:exe -out:bin/ProtoGen.exe `find $SRC/ProtoGen -name '*.cs'` -keyfile:$KEYFILE -r:bin/Google.ProtocolBuffers.dll |
||||
|
||||
echo Building ProtoGen tests |
||||
gmcs -target:library -out:bin/Google.ProtocolBuffers.ProtoGen.Test.dll `find $SRC/ProtoGen.Test -name '*.cs'` -keyfile:$KEYFILE -r:bin/Google.ProtocolBuffers.dll -r:$LIB/nunit.framework.dll -r:bin/ProtoGen.exe |
||||
|
||||
echo Running ProtoGen tests |
||||
mono $NUNIT bin/Google.ProtocolBuffers.ProtoGen.Test.dll $NUNIT_OPTIONS |
@ -1,29 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
echo Compiling protobufs |
||||
rm -rf tmp |
||||
mkdir tmp |
||||
PROTOS_DIR=../protos |
||||
|
||||
./protoc --proto_path=$PROTOS_DIR --descriptor_set_out=tmp/compiled.pb \ |
||||
$PROTOS_DIR/google/protobuf/descriptor.proto \ |
||||
$PROTOS_DIR/google/protobuf/csharp_options.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_csharp_options.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_custom_options.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_embed_optimize_for.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_import.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_mset.proto \ |
||||
$PROTOS_DIR/google/protobuf/unittest_optimize_for.proto \ |
||||
$PROTOS_DIR/tutorial/addressbook.proto |
||||
|
||||
cd tmp |
||||
echo Generating new source |
||||
mono ../bin/ProtoGen.exe compiled.pb |
||||
|
||||
echo Copying source into place |
||||
cp DescriptorProtoFile.cs CSharpOptions.cs ../../src/ProtocolBuffers/DescriptorProtos |
||||
cp UnitTest*.cs ../../src/ProtocolBuffers.Test/TestProtos |
||||
cp AddressBookProtos.cs ../../src/AddressBook |
||||
cd .. |
||||
rm -rf tmp |
@ -1,91 +0,0 @@ |
||||
Getting started with Protocol Buffers on Mono |
||||
--------------------------------------------- |
||||
|
||||
Prerequisites: |
||||
|
||||
o Mono 2.4 or higher. Earlier versions of Mono had too |
||||
many issues with the weird and wonderful generic type |
||||
relationships in Protocol Buffers. (Even Mono 2.4 *did* |
||||
have a few compile-time problems, but I've worked round them.) |
||||
|
||||
o Some sort of Linux/Unix system |
||||
You can try running with Bash on Windows via MINGW32 or |
||||
something similar, but you're on your own :) It's easier |
||||
to build and test everything with .NET if you're on |
||||
Windows. |
||||
|
||||
o The native Protocol Buffers build for your system. |
||||
Get it from http://code.google.com/p/protobuf/ |
||||
After building it, copy the executable protoc |
||||
file into this directory. |
||||
|
||||
o The NUnit binaries from http://nunit.org |
||||
I generally just download the latest version, which |
||||
may not be the one which goes with nunit.framework.dll |
||||
in ../lib, but I've never found this to be a problem. |
||||
|
||||
Building the code with current sources |
||||
-------------------------------------- |
||||
|
||||
1) Edit buildall.sh to tell it where to find nunit-console.exe |
||||
(and possibly change other options) |
||||
|
||||
2) Run buildall.sh from this directory. It should build the |
||||
main library code + tests and ProtoGen code + tests, running |
||||
each set of tests after building it. |
||||
|
||||
Note that currently one test is ignored in ServiceTest.cs. This |
||||
made the Mono VM blow up - I suspect it's some interaction with |
||||
Rhino which doesn't quite work on Mono 2.4. If you want to see a |
||||
truly nasty stack trace, just comment out the Ignore attribute in |
||||
ServiceTest.cs and rerun. |
||||
|
||||
The binaries will be produced in a bin directory under this one. The |
||||
build currently starts from scratch each time, cleaning out the bin |
||||
directory first. Once I've decided on a full NAnt or xbuild |
||||
strategy, I'll do something a little cleaner. |
||||
|
||||
Rebuilding sources for generated code |
||||
------------------------------------- |
||||
|
||||
1) Build the current code first. The bootstrapping issue is why |
||||
the generated source code is in the source repository :) See |
||||
the steps above. |
||||
|
||||
2) Run generatesource.sh from this directory. This will create a |
||||
temporary directory, compile the .proto files into a binary |
||||
format, then run ProtoGen to generate .cs files from the binary |
||||
format. It will copy these files to the right places in the tree, |
||||
and finally delete the temporary directory. |
||||
|
||||
3) Rebuild to test that your newly generated sources work. (Optionally |
||||
regenerate as well, and hash the generated files to check that |
||||
the new build generates the same code as the old build :) |
||||
|
||||
Running the code |
||||
---------------- |
||||
|
||||
Once you've built the binaries, you should be able to use them just |
||||
as if you'd built them with .NET. (And indeed, you should be able to |
||||
use binaries built with .NET as if you'd built them with Mono :) |
||||
|
||||
See the getting started guide for more information: |
||||
http://code.google.com/p/protobuf-csharp-port/wiki/GettingStarted |
||||
|
||||
FAQ (Frequently Anticipated Questions) |
||||
-------------------------------------- |
||||
|
||||
Q) This build process sucks! Why aren't you doing X, Y, Z? |
||||
A) My Mono skills are limited. My NAnt skills are limited. My |
||||
MSBuild/xbuild skils are limited. My shell script skills are |
||||
limited. Any help is *very* welcome! |
||||
|
||||
Q) Why doesn't it build ProtoBench etc? |
||||
A) This is a first initial "release" I'll add more bits to |
||||
the build script. I'll be interested to see the results |
||||
of benchmarking it on Mono :) |
||||
|
||||
Any further questions or suggestions? Please email skeet@pobox.com |
||||
or leave a request at |
||||
http://code.google.com/p/protobuf-csharp-port/issues/list |
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,684 +0,0 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: google/protobuf/unittest_preserve_unknown_enum2.proto |
||||
#pragma warning disable 1591, 0612, 3021 |
||||
#region Designer generated code |
||||
|
||||
using pb = global::Google.ProtocolBuffers; |
||||
using pbc = global::Google.ProtocolBuffers.Collections; |
||||
using pbd = global::Google.ProtocolBuffers.Descriptors; |
||||
using scg = global::System.Collections.Generic; |
||||
namespace Google.ProtocolBuffers.TestProtos { |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public static partial class UnittestPreserveUnknownEnum2 { |
||||
|
||||
#region Extension registration |
||||
public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { |
||||
} |
||||
#endregion |
||||
#region Static variables |
||||
internal static pbd::MessageDescriptor internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__Descriptor; |
||||
internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.TestProtos.MyMessage, global::Google.ProtocolBuffers.TestProtos.MyMessage.Builder> internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__FieldAccessorTable; |
||||
#endregion |
||||
#region Descriptor |
||||
public static pbd::FileDescriptor Descriptor { |
||||
get { return descriptor; } |
||||
} |
||||
private static pbd::FileDescriptor descriptor; |
||||
|
||||
static UnittestPreserveUnknownEnum2() { |
||||
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||
string.Concat( |
||||
"CjVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJlc2VydmVfdW5rbm93bl9l", |
||||
"bnVtMi5wcm90bxIlcHJvdG8yX3ByZXNlcnZlX3Vua25vd25fZW51bV91bml0", |
||||
"dGVzdCK4AwoJTXlNZXNzYWdlEjgKAWUYASABKA4yLS5wcm90bzJfcHJlc2Vy", |
||||
"dmVfdW5rbm93bl9lbnVtX3VuaXR0ZXN0Lk15RW51bRJBCgpyZXBlYXRlZF9l", |
||||
"GAIgAygOMi0ucHJvdG8yX3ByZXNlcnZlX3Vua25vd25fZW51bV91bml0dGVz", |
||||
"dC5NeUVudW0STAoRcmVwZWF0ZWRfcGFja2VkX2UYAyADKA4yLS5wcm90bzJf", |
||||
"cHJlc2VydmVfdW5rbm93bl9lbnVtX3VuaXR0ZXN0Lk15RW51bUICEAESUwoc", |
||||
"cmVwZWF0ZWRfcGFja2VkX3VuZXhwZWN0ZWRfZRgEIAMoDjItLnByb3RvMl9w", |
||||
"cmVzZXJ2ZV91bmtub3duX2VudW1fdW5pdHRlc3QuTXlFbnVtEkIKCW9uZW9m", |
||||
"X2VfMRgFIAEoDjItLnByb3RvMl9wcmVzZXJ2ZV91bmtub3duX2VudW1fdW5p", |
||||
"dHRlc3QuTXlFbnVtSAASQgoJb25lb2ZfZV8yGAYgASgOMi0ucHJvdG8yX3By", |
||||
"ZXNlcnZlX3Vua25vd25fZW51bV91bml0dGVzdC5NeUVudW1IAEIDCgFvKiMK", |
||||
"Bk15RW51bRIHCgNGT08QABIHCgNCQVIQARIHCgNCQVoQAkIkqgIhR29vZ2xl", |
||||
"LlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9z")); |
||||
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { |
||||
descriptor = root; |
||||
internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__Descriptor = Descriptor.MessageTypes[0]; |
||||
internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__FieldAccessorTable = |
||||
new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.TestProtos.MyMessage, global::Google.ProtocolBuffers.TestProtos.MyMessage.Builder>(internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__Descriptor, |
||||
new string[] { "E", "RepeatedE", "RepeatedPackedE", "RepeatedPackedUnexpectedE", "OneofE1", "OneofE2", }); |
||||
pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); |
||||
RegisterAllExtensions(registry); |
||||
return registry; |
||||
}; |
||||
pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, |
||||
new pbd::FileDescriptor[] { |
||||
}, assigner); |
||||
} |
||||
#endregion |
||||
|
||||
} |
||||
#region Enums |
||||
public enum MyEnum { |
||||
FOO = 0, |
||||
BAR = 1, |
||||
BAZ = 2, |
||||
} |
||||
|
||||
#endregion |
||||
|
||||
#region Messages |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class MyMessage : pb::GeneratedMessage<MyMessage, MyMessage.Builder> { |
||||
private MyMessage() { } |
||||
private static readonly MyMessage defaultInstance = new MyMessage().MakeReadOnly(); |
||||
private static readonly string[] _myMessageFieldNames = new string[] { "e", "oneof_e_1", "oneof_e_2", "repeated_e", "repeated_packed_e", "repeated_packed_unexpected_e" }; |
||||
private static readonly uint[] _myMessageFieldTags = new uint[] { 8, 40, 48, 16, 26, 32 }; |
||||
public static MyMessage DefaultInstance { |
||||
get { return defaultInstance; } |
||||
} |
||||
|
||||
public override MyMessage DefaultInstanceForType { |
||||
get { return DefaultInstance; } |
||||
} |
||||
|
||||
protected override MyMessage ThisMessage { |
||||
get { return this; } |
||||
} |
||||
|
||||
public static pbd::MessageDescriptor Descriptor { |
||||
get { return global::Google.ProtocolBuffers.TestProtos.UnittestPreserveUnknownEnum2.internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__Descriptor; } |
||||
} |
||||
|
||||
protected override pb::FieldAccess.FieldAccessorTable<MyMessage, MyMessage.Builder> InternalFieldAccessors { |
||||
get { return global::Google.ProtocolBuffers.TestProtos.UnittestPreserveUnknownEnum2.internal__static_proto2_preserve_unknown_enum_unittest_MyMessage__FieldAccessorTable; } |
||||
} |
||||
|
||||
public const int EFieldNumber = 1; |
||||
private bool hasE; |
||||
private global::Google.ProtocolBuffers.TestProtos.MyEnum e_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
public bool HasE { |
||||
get { return hasE; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum E { |
||||
get { return e_; } |
||||
} |
||||
|
||||
public const int RepeatedEFieldNumber = 2; |
||||
private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> repeatedE_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum>(); |
||||
public scg::IList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedEList { |
||||
get { return pbc::Lists.AsReadOnly(repeatedE_); } |
||||
} |
||||
public int RepeatedECount { |
||||
get { return repeatedE_.Count; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedE(int index) { |
||||
return repeatedE_[index]; |
||||
} |
||||
|
||||
public const int RepeatedPackedEFieldNumber = 3; |
||||
private int repeatedPackedEMemoizedSerializedSize; |
||||
private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> repeatedPackedE_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum>(); |
||||
public scg::IList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedPackedEList { |
||||
get { return pbc::Lists.AsReadOnly(repeatedPackedE_); } |
||||
} |
||||
public int RepeatedPackedECount { |
||||
get { return repeatedPackedE_.Count; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedPackedE(int index) { |
||||
return repeatedPackedE_[index]; |
||||
} |
||||
|
||||
public const int RepeatedPackedUnexpectedEFieldNumber = 4; |
||||
private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> repeatedPackedUnexpectedE_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum>(); |
||||
public scg::IList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedPackedUnexpectedEList { |
||||
get { return pbc::Lists.AsReadOnly(repeatedPackedUnexpectedE_); } |
||||
} |
||||
public int RepeatedPackedUnexpectedECount { |
||||
get { return repeatedPackedUnexpectedE_.Count; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedPackedUnexpectedE(int index) { |
||||
return repeatedPackedUnexpectedE_[index]; |
||||
} |
||||
|
||||
public const int OneofE1FieldNumber = 5; |
||||
private bool hasOneofE1; |
||||
private global::Google.ProtocolBuffers.TestProtos.MyEnum oneofE1_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
public bool HasOneofE1 { |
||||
get { return hasOneofE1; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum OneofE1 { |
||||
get { return oneofE1_; } |
||||
} |
||||
|
||||
public const int OneofE2FieldNumber = 6; |
||||
private bool hasOneofE2; |
||||
private global::Google.ProtocolBuffers.TestProtos.MyEnum oneofE2_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
public bool HasOneofE2 { |
||||
get { return hasOneofE2; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum OneofE2 { |
||||
get { return oneofE2_; } |
||||
} |
||||
|
||||
public override bool IsInitialized { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override void WriteTo(pb::ICodedOutputStream output) { |
||||
CalcSerializedSize(); |
||||
string[] field_names = _myMessageFieldNames; |
||||
if (hasE) { |
||||
output.WriteEnum(1, field_names[0], (int) E, E); |
||||
} |
||||
if (repeatedE_.Count > 0) { |
||||
output.WriteEnumArray(2, field_names[3], repeatedE_); |
||||
} |
||||
if (repeatedPackedE_.Count > 0) { |
||||
output.WritePackedEnumArray(3, field_names[4], repeatedPackedEMemoizedSerializedSize, repeatedPackedE_); |
||||
} |
||||
if (repeatedPackedUnexpectedE_.Count > 0) { |
||||
output.WriteEnumArray(4, field_names[5], repeatedPackedUnexpectedE_); |
||||
} |
||||
if (hasOneofE1) { |
||||
output.WriteEnum(5, field_names[1], (int) OneofE1, OneofE1); |
||||
} |
||||
if (hasOneofE2) { |
||||
output.WriteEnum(6, field_names[2], (int) OneofE2, OneofE2); |
||||
} |
||||
UnknownFields.WriteTo(output); |
||||
} |
||||
|
||||
private int memoizedSerializedSize = -1; |
||||
public override int SerializedSize { |
||||
get { |
||||
int size = memoizedSerializedSize; |
||||
if (size != -1) return size; |
||||
return CalcSerializedSize(); |
||||
} |
||||
} |
||||
|
||||
private int CalcSerializedSize() { |
||||
int size = memoizedSerializedSize; |
||||
if (size != -1) return size; |
||||
|
||||
size = 0; |
||||
if (hasE) { |
||||
size += pb::CodedOutputStream.ComputeEnumSize(1, (int) E); |
||||
} |
||||
{ |
||||
int dataSize = 0; |
||||
if (repeatedE_.Count > 0) { |
||||
foreach (global::Google.ProtocolBuffers.TestProtos.MyEnum element in repeatedE_) { |
||||
dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); |
||||
} |
||||
size += dataSize; |
||||
size += 1 * repeatedE_.Count; |
||||
} |
||||
} |
||||
{ |
||||
int dataSize = 0; |
||||
if (repeatedPackedE_.Count > 0) { |
||||
foreach (global::Google.ProtocolBuffers.TestProtos.MyEnum element in repeatedPackedE_) { |
||||
dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); |
||||
} |
||||
size += dataSize; |
||||
size += 1; |
||||
size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); |
||||
} |
||||
repeatedPackedEMemoizedSerializedSize = dataSize; |
||||
} |
||||
{ |
||||
int dataSize = 0; |
||||
if (repeatedPackedUnexpectedE_.Count > 0) { |
||||
foreach (global::Google.ProtocolBuffers.TestProtos.MyEnum element in repeatedPackedUnexpectedE_) { |
||||
dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); |
||||
} |
||||
size += dataSize; |
||||
size += 1 * repeatedPackedUnexpectedE_.Count; |
||||
} |
||||
} |
||||
if (hasOneofE1) { |
||||
size += pb::CodedOutputStream.ComputeEnumSize(5, (int) OneofE1); |
||||
} |
||||
if (hasOneofE2) { |
||||
size += pb::CodedOutputStream.ComputeEnumSize(6, (int) OneofE2); |
||||
} |
||||
size += UnknownFields.SerializedSize; |
||||
memoizedSerializedSize = size; |
||||
return size; |
||||
} |
||||
public static MyMessage ParseFrom(pb::ByteString data) { |
||||
return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { |
||||
return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(byte[] data) { |
||||
return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { |
||||
return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(global::System.IO.Stream input) { |
||||
return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { |
||||
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseDelimitedFrom(global::System.IO.Stream input) { |
||||
return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { |
||||
return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(pb::ICodedInputStream input) { |
||||
return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); |
||||
} |
||||
public static MyMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { |
||||
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); |
||||
} |
||||
private MyMessage MakeReadOnly() { |
||||
repeatedE_.MakeReadOnly(); |
||||
repeatedPackedE_.MakeReadOnly(); |
||||
repeatedPackedUnexpectedE_.MakeReadOnly(); |
||||
return this; |
||||
} |
||||
|
||||
public static Builder CreateBuilder() { return new Builder(); } |
||||
public override Builder ToBuilder() { return CreateBuilder(this); } |
||||
public override Builder CreateBuilderForType() { return new Builder(); } |
||||
public static Builder CreateBuilder(MyMessage prototype) { |
||||
return new Builder(prototype); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class Builder : pb::GeneratedBuilder<MyMessage, Builder> { |
||||
protected override Builder ThisBuilder { |
||||
get { return this; } |
||||
} |
||||
public Builder() { |
||||
result = DefaultInstance; |
||||
resultIsReadOnly = true; |
||||
} |
||||
internal Builder(MyMessage cloneFrom) { |
||||
result = cloneFrom; |
||||
resultIsReadOnly = true; |
||||
} |
||||
|
||||
private bool resultIsReadOnly; |
||||
private MyMessage result; |
||||
|
||||
private MyMessage PrepareBuilder() { |
||||
if (resultIsReadOnly) { |
||||
MyMessage original = result; |
||||
result = new MyMessage(); |
||||
resultIsReadOnly = false; |
||||
MergeFrom(original); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public override bool IsInitialized { |
||||
get { return result.IsInitialized; } |
||||
} |
||||
|
||||
protected override MyMessage MessageBeingBuilt { |
||||
get { return PrepareBuilder(); } |
||||
} |
||||
|
||||
public override Builder Clear() { |
||||
result = DefaultInstance; |
||||
resultIsReadOnly = true; |
||||
return this; |
||||
} |
||||
|
||||
public override Builder Clone() { |
||||
if (resultIsReadOnly) { |
||||
return new Builder(result); |
||||
} else { |
||||
return new Builder().MergeFrom(result); |
||||
} |
||||
} |
||||
|
||||
public override pbd::MessageDescriptor DescriptorForType { |
||||
get { return global::Google.ProtocolBuffers.TestProtos.MyMessage.Descriptor; } |
||||
} |
||||
|
||||
public override MyMessage DefaultInstanceForType { |
||||
get { return global::Google.ProtocolBuffers.TestProtos.MyMessage.DefaultInstance; } |
||||
} |
||||
|
||||
public override MyMessage BuildPartial() { |
||||
if (resultIsReadOnly) { |
||||
return result; |
||||
} |
||||
resultIsReadOnly = true; |
||||
return result.MakeReadOnly(); |
||||
} |
||||
|
||||
public override Builder MergeFrom(pb::IMessage other) { |
||||
if (other is MyMessage) { |
||||
return MergeFrom((MyMessage) other); |
||||
} else { |
||||
base.MergeFrom(other); |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public override Builder MergeFrom(MyMessage other) { |
||||
if (other == global::Google.ProtocolBuffers.TestProtos.MyMessage.DefaultInstance) return this; |
||||
PrepareBuilder(); |
||||
if (other.HasE) { |
||||
E = other.E; |
||||
} |
||||
if (other.repeatedE_.Count != 0) { |
||||
result.repeatedE_.Add(other.repeatedE_); |
||||
} |
||||
if (other.repeatedPackedE_.Count != 0) { |
||||
result.repeatedPackedE_.Add(other.repeatedPackedE_); |
||||
} |
||||
if (other.repeatedPackedUnexpectedE_.Count != 0) { |
||||
result.repeatedPackedUnexpectedE_.Add(other.repeatedPackedUnexpectedE_); |
||||
} |
||||
if (other.HasOneofE1) { |
||||
OneofE1 = other.OneofE1; |
||||
} |
||||
if (other.HasOneofE2) { |
||||
OneofE2 = other.OneofE2; |
||||
} |
||||
this.MergeUnknownFields(other.UnknownFields); |
||||
return this; |
||||
} |
||||
|
||||
public override Builder MergeFrom(pb::ICodedInputStream input) { |
||||
return MergeFrom(input, pb::ExtensionRegistry.Empty); |
||||
} |
||||
|
||||
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { |
||||
PrepareBuilder(); |
||||
pb::UnknownFieldSet.Builder unknownFields = null; |
||||
uint tag; |
||||
string field_name; |
||||
while (input.ReadTag(out tag, out field_name)) { |
||||
if(tag == 0 && field_name != null) { |
||||
int field_ordinal = global::System.Array.BinarySearch(_myMessageFieldNames, field_name, global::System.StringComparer.Ordinal); |
||||
if(field_ordinal >= 0) |
||||
tag = _myMessageFieldTags[field_ordinal]; |
||||
else { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); |
||||
continue; |
||||
} |
||||
} |
||||
switch (tag) { |
||||
case 0: { |
||||
throw pb::InvalidProtocolBufferException.InvalidTag(); |
||||
} |
||||
default: { |
||||
if (pb::WireFormat.IsEndGroupTag(tag)) { |
||||
if (unknownFields != null) { |
||||
this.UnknownFields = unknownFields.Build(); |
||||
} |
||||
return this; |
||||
} |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); |
||||
break; |
||||
} |
||||
case 8: { |
||||
object unknown; |
||||
if(input.ReadEnum(ref result.e_, out unknown)) { |
||||
result.hasE = true; |
||||
} else if(unknown is int) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
unknownFields.MergeVarintField(1, (ulong)(int)unknown); |
||||
} |
||||
break; |
||||
} |
||||
case 18: |
||||
case 16: { |
||||
scg::ICollection<object> unknownItems; |
||||
input.ReadEnumArray<global::Google.ProtocolBuffers.TestProtos.MyEnum>(tag, field_name, result.repeatedE_, out unknownItems); |
||||
if (unknownItems != null) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
foreach (object rawValue in unknownItems) |
||||
if (rawValue is int) |
||||
unknownFields.MergeVarintField(2, (ulong)(int)rawValue); |
||||
} |
||||
break; |
||||
} |
||||
case 26: |
||||
case 24: { |
||||
scg::ICollection<object> unknownItems; |
||||
input.ReadEnumArray<global::Google.ProtocolBuffers.TestProtos.MyEnum>(tag, field_name, result.repeatedPackedE_, out unknownItems); |
||||
if (unknownItems != null) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
foreach (object rawValue in unknownItems) |
||||
if (rawValue is int) |
||||
unknownFields.MergeVarintField(3, (ulong)(int)rawValue); |
||||
} |
||||
break; |
||||
} |
||||
case 34: |
||||
case 32: { |
||||
scg::ICollection<object> unknownItems; |
||||
input.ReadEnumArray<global::Google.ProtocolBuffers.TestProtos.MyEnum>(tag, field_name, result.repeatedPackedUnexpectedE_, out unknownItems); |
||||
if (unknownItems != null) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
foreach (object rawValue in unknownItems) |
||||
if (rawValue is int) |
||||
unknownFields.MergeVarintField(4, (ulong)(int)rawValue); |
||||
} |
||||
break; |
||||
} |
||||
case 40: { |
||||
object unknown; |
||||
if(input.ReadEnum(ref result.oneofE1_, out unknown)) { |
||||
result.hasOneofE1 = true; |
||||
} else if(unknown is int) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
unknownFields.MergeVarintField(5, (ulong)(int)unknown); |
||||
} |
||||
break; |
||||
} |
||||
case 48: { |
||||
object unknown; |
||||
if(input.ReadEnum(ref result.oneofE2_, out unknown)) { |
||||
result.hasOneofE2 = true; |
||||
} else if(unknown is int) { |
||||
if (unknownFields == null) { |
||||
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); |
||||
} |
||||
unknownFields.MergeVarintField(6, (ulong)(int)unknown); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (unknownFields != null) { |
||||
this.UnknownFields = unknownFields.Build(); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
|
||||
public bool HasE { |
||||
get { return result.hasE; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum E { |
||||
get { return result.E; } |
||||
set { SetE(value); } |
||||
} |
||||
public Builder SetE(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.hasE = true; |
||||
result.e_ = value; |
||||
return this; |
||||
} |
||||
public Builder ClearE() { |
||||
PrepareBuilder(); |
||||
result.hasE = false; |
||||
result.e_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
return this; |
||||
} |
||||
|
||||
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedEList { |
||||
get { return PrepareBuilder().repeatedE_; } |
||||
} |
||||
public int RepeatedECount { |
||||
get { return result.RepeatedECount; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedE(int index) { |
||||
return result.GetRepeatedE(index); |
||||
} |
||||
public Builder SetRepeatedE(int index, global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedE_[index] = value; |
||||
return this; |
||||
} |
||||
public Builder AddRepeatedE(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedE_.Add(value); |
||||
return this; |
||||
} |
||||
public Builder AddRangeRepeatedE(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.MyEnum> values) { |
||||
PrepareBuilder(); |
||||
result.repeatedE_.Add(values); |
||||
return this; |
||||
} |
||||
public Builder ClearRepeatedE() { |
||||
PrepareBuilder(); |
||||
result.repeatedE_.Clear(); |
||||
return this; |
||||
} |
||||
|
||||
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedPackedEList { |
||||
get { return PrepareBuilder().repeatedPackedE_; } |
||||
} |
||||
public int RepeatedPackedECount { |
||||
get { return result.RepeatedPackedECount; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedPackedE(int index) { |
||||
return result.GetRepeatedPackedE(index); |
||||
} |
||||
public Builder SetRepeatedPackedE(int index, global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedE_[index] = value; |
||||
return this; |
||||
} |
||||
public Builder AddRepeatedPackedE(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedE_.Add(value); |
||||
return this; |
||||
} |
||||
public Builder AddRangeRepeatedPackedE(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.MyEnum> values) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedE_.Add(values); |
||||
return this; |
||||
} |
||||
public Builder ClearRepeatedPackedE() { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedE_.Clear(); |
||||
return this; |
||||
} |
||||
|
||||
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.MyEnum> RepeatedPackedUnexpectedEList { |
||||
get { return PrepareBuilder().repeatedPackedUnexpectedE_; } |
||||
} |
||||
public int RepeatedPackedUnexpectedECount { |
||||
get { return result.RepeatedPackedUnexpectedECount; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum GetRepeatedPackedUnexpectedE(int index) { |
||||
return result.GetRepeatedPackedUnexpectedE(index); |
||||
} |
||||
public Builder SetRepeatedPackedUnexpectedE(int index, global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedUnexpectedE_[index] = value; |
||||
return this; |
||||
} |
||||
public Builder AddRepeatedPackedUnexpectedE(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedUnexpectedE_.Add(value); |
||||
return this; |
||||
} |
||||
public Builder AddRangeRepeatedPackedUnexpectedE(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.MyEnum> values) { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedUnexpectedE_.Add(values); |
||||
return this; |
||||
} |
||||
public Builder ClearRepeatedPackedUnexpectedE() { |
||||
PrepareBuilder(); |
||||
result.repeatedPackedUnexpectedE_.Clear(); |
||||
return this; |
||||
} |
||||
|
||||
public bool HasOneofE1 { |
||||
get { return result.hasOneofE1; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum OneofE1 { |
||||
get { return result.OneofE1; } |
||||
set { SetOneofE1(value); } |
||||
} |
||||
public Builder SetOneofE1(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.hasOneofE1 = true; |
||||
result.oneofE1_ = value; |
||||
return this; |
||||
} |
||||
public Builder ClearOneofE1() { |
||||
PrepareBuilder(); |
||||
result.hasOneofE1 = false; |
||||
result.oneofE1_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
return this; |
||||
} |
||||
|
||||
public bool HasOneofE2 { |
||||
get { return result.hasOneofE2; } |
||||
} |
||||
public global::Google.ProtocolBuffers.TestProtos.MyEnum OneofE2 { |
||||
get { return result.OneofE2; } |
||||
set { SetOneofE2(value); } |
||||
} |
||||
public Builder SetOneofE2(global::Google.ProtocolBuffers.TestProtos.MyEnum value) { |
||||
PrepareBuilder(); |
||||
result.hasOneofE2 = true; |
||||
result.oneofE2_ = value; |
||||
return this; |
||||
} |
||||
public Builder ClearOneofE2() { |
||||
PrepareBuilder(); |
||||
result.hasOneofE2 = false; |
||||
result.oneofE2_ = global::Google.ProtocolBuffers.TestProtos.MyEnum.FOO; |
||||
return this; |
||||
} |
||||
} |
||||
static MyMessage() { |
||||
object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestPreserveUnknownEnum2.Descriptor, null); |
||||
} |
||||
} |
||||
|
||||
#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
Loading…
Reference in new issue