Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
3c6e9328
Commit
3c6e9328
authored
Sep 09, 2011
by
csharptest
Committed by
rogerk
Sep 09, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed addition and testing of new add_serializable option.
parent
8f0dcf3d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
447 additions
and
22 deletions
+447
-22
unittest_extras_lite.proto
protos/extest/unittest_extras_lite.proto
+1
-0
unittest_extras_xmltest.proto
protos/extest/unittest_extras_xmltest.proto
+1
-0
csharp_options.proto
protos/google/protobuf/csharp_options.proto
+3
-0
MessageGenerator.cs
src/ProtoGen/MessageGenerator.cs
+8
-0
ProtocolBuffers.Test.csproj
src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
+1
-0
SerializableTest.cs
src/ProtocolBuffers.Test/SerializableTest.cs
+153
-0
UnitTestXmlSerializerTestProtoFile.cs
...ers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
+15
-3
AbstractBuilder.cs
src/ProtocolBuffers/AbstractBuilder.cs
+1
-1
AbstractBuilderLite.cs
src/ProtocolBuffers/AbstractBuilderLite.cs
+1
-1
AbstractMessage.cs
src/ProtocolBuffers/AbstractMessage.cs
+1
-1
AbstractMessageLite.cs
src/ProtocolBuffers/AbstractMessageLite.cs
+1
-1
CustomSerialization.cs
src/ProtocolBuffers/CustomSerialization.cs
+181
-0
CSharpOptions.cs
src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
+0
-0
DynamicMessage.cs
src/ProtocolBuffers/DynamicMessage.cs
+2
-2
ExtendableBuilder.cs
src/ProtocolBuffers/ExtendableBuilder.cs
+1
-1
ExtendableBuilderLite.cs
src/ProtocolBuffers/ExtendableBuilderLite.cs
+1
-1
ExtendableMessage.cs
src/ProtocolBuffers/ExtendableMessage.cs
+1
-1
ExtendableMessageLite.cs
src/ProtocolBuffers/ExtendableMessageLite.cs
+1
-1
GeneratedBuilder.cs
src/ProtocolBuffers/GeneratedBuilder.cs
+1
-1
GeneratedBuilderLite.cs
src/ProtocolBuffers/GeneratedBuilderLite.cs
+1
-1
GeneratedMessage.cs
src/ProtocolBuffers/GeneratedMessage.cs
+1
-1
GeneratedMessageLite.cs
src/ProtocolBuffers/GeneratedMessageLite.cs
+1
-1
IBuilderLite.cs
src/ProtocolBuffers/IBuilderLite.cs
+1
-1
IMessageLite.cs
src/ProtocolBuffers/IMessageLite.cs
+1
-1
ProtocolBuffers.csproj
src/ProtocolBuffers/ProtocolBuffers.csproj
+1
-0
ProtocolBuffersLite.csproj
src/ProtocolBuffers/ProtocolBuffersLite.csproj
+1
-0
UnknownFieldSet.cs
src/ProtocolBuffers/UnknownFieldSet.cs
+2
-2
ProtocolBuffers2008.sln
src/ProtocolBuffers2008.sln
+0
-1
ProtocolBuffersLite.Test.csproj
src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
+1
-0
SerializableLiteTest.cs
src/ProtocolBuffersLite.Test/SerializableLiteTest.cs
+53
-0
UnitTestExtrasLiteProtoFile.cs
...uffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
+10
-0
No files found.
protos/extest/unittest_extras_lite.proto
View file @
3c6e9328
...
...
@@ -3,6 +3,7 @@
import
"google/protobuf/csharp_options.proto"
;
option
(
google.protobuf.csharp_file_options
)
.
namespace
=
"Google.ProtocolBuffers.TestProtos"
;
option
(
google.protobuf.csharp_file_options
)
.
umbrella_classname
=
"UnitTestExtrasLiteProtoFile"
;
option
(
google.protobuf.csharp_file_options
)
.
add_serializable
=
true
;
package
protobuf_unittest_extra
;
...
...
protos/extest/unittest_extras_xmltest.proto
View file @
3c6e9328
import
"google/protobuf/csharp_options.proto"
;
option
(
google.protobuf.csharp_file_options
)
.
namespace
=
"Google.ProtocolBuffers.TestProtos"
;
option
(
google.protobuf.csharp_file_options
)
.
umbrella_classname
=
"UnitTestXmlSerializerTestProtoFile"
;
option
(
google.protobuf.csharp_file_options
)
.
add_serializable
=
true
;
package
protobuf_unittest_extra
;
...
...
protos/google/protobuf/csharp_options.proto
View file @
3c6e9328
...
...
@@ -39,6 +39,9 @@ message CSharpFileOptions {
// Generate attributes indicating non-CLS-compliance
optional
bool
cls_compliance
=
8
[
default
=
true
];
// Generate messages/builders with the [Serializable] attribute
optional
bool
add_serializable
=
9
[
default
=
false
];
// The extension that should be appended to the umbrella_classname when creating files.
optional
string
file_extension
=
221
[
default
=
".cs"
];
...
...
src/ProtoGen/MessageGenerator.cs
View file @
3c6e9328
...
...
@@ -168,6 +168,10 @@ namespace Google.ProtocolBuffers.ProtoGen
public
void
Generate
(
TextGenerator
writer
)
{
if
(
Descriptor
.
File
.
CSharpOptions
.
AddSerializable
)
{
writer
.
WriteLine
(
"[global::System.SerializableAttribute()]"
);
}
writer
.
WriteLine
(
"[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"
);
writer
.
WriteLine
(
"[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]"
);
writer
.
WriteLine
(
"[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{0}\", \"{1}\")]"
,
...
...
@@ -554,6 +558,10 @@ namespace Google.ProtocolBuffers.ProtoGen
writer
.
WriteLine
(
" return (Builder) new Builder().MergeFrom(prototype);"
);
writer
.
WriteLine
(
"}"
);
writer
.
WriteLine
();
if
(
Descriptor
.
File
.
CSharpOptions
.
AddSerializable
)
{
writer
.
WriteLine
(
"[global::System.SerializableAttribute()]"
);
}
writer
.
WriteLine
(
"[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"
);
writer
.
WriteLine
(
"[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]"
);
writer
.
WriteLine
(
"[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{0}\", \"{1}\")]"
,
...
...
src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
View file @
3c6e9328
...
...
@@ -105,6 +105,7 @@
<Compile
Include=
"NameHelpersTest.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"ReflectionTester.cs"
/>
<Compile
Include=
"SerializableTest.cs"
/>
<Compile
Include=
"ServiceTest.cs"
/>
<Compile
Include=
"TestProtos\UnitTestCSharpOptionsProtoFile.cs"
/>
<Compile
Include=
"TestProtos\UnitTestCustomOptionsProtoFile.cs"
/>
...
...
src/ProtocolBuffers.Test/SerializableTest.cs
0 → 100644
View file @
3c6e9328
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Runtime.Serialization
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Text
;
using
Google.ProtocolBuffers.TestProtos
;
using
NUnit.Framework
;
namespace
Google.ProtocolBuffers
{
[
TestFixture
]
public
class
SerializableTest
{
/// <summary>
/// Just keep it from even compiling if we these objects don't implement the expected interface.
/// </summary>
public
static
readonly
ISerializable
CompileTimeCheckSerializableMessage
=
TestXmlMessage
.
DefaultInstance
;
public
static
readonly
ISerializable
CompileTimeCheckSerializableBuilder
=
new
TestXmlMessage
.
Builder
();
[
Test
]
public
void
TestPlainMessage
()
{
TestXmlMessage
message
=
TestXmlMessage
.
CreateBuilder
()
.
SetValid
(
true
)
.
SetText
(
"text"
)
.
AddTextlines
(
"a"
)
.
AddTextlines
(
"b"
)
.
AddTextlines
(
"c"
)
.
SetNumber
(
0x1010101010
)
.
AddNumbers
(
1
)
.
AddNumbers
(
2
)
.
AddNumbers
(
3
)
.
SetChild
(
TestXmlChild
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
ONE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
1
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
TWO
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
2
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
THREE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
3
])))
.
Build
();
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
message
);
ms
.
Position
=
0
;
TestXmlMessage
copy
=
(
TestXmlMessage
)
new
BinaryFormatter
().
Deserialize
(
ms
);
Assert
.
AreEqual
(
message
,
copy
);
}
[
Test
]
public
void
TestMessageWithExtensions
()
{
TestXmlMessage
message
=
TestXmlMessage
.
CreateBuilder
()
.
SetValid
(
true
)
.
SetText
(
"text"
)
.
AddTextlines
(
"a"
)
.
AddTextlines
(
"b"
)
.
AddTextlines
(
"c"
)
.
SetNumber
(
0x1010101010
)
.
AddNumbers
(
1
)
.
AddNumbers
(
2
)
.
AddNumbers
(
3
)
.
SetChild
(
TestXmlChild
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
ONE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
1
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
TWO
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
2
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
THREE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
3
])))
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionText
,
" extension text value ! "
)
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionMessage
,
new
TestXmlExtension
.
Builder
().
SetNumber
(
42
).
Build
())
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
100
)
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
101
)
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
102
)
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionEnum
,
EnumOptions
.
ONE
)
.
Build
();
ExtensionRegistry
registry
=
ExtensionRegistry
.
CreateInstance
();
UnitTestXmlSerializerTestProtoFile
.
RegisterAllExtensions
(
registry
);
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
message
);
ms
.
Position
=
0
;
//you need to provide the extension registry as context to the serializer
BinaryFormatter
bff
=
new
BinaryFormatter
(
null
,
new
StreamingContext
(
StreamingContextStates
.
All
,
registry
));
TestXmlMessage
copy
=
(
TestXmlMessage
)
bff
.
Deserialize
(
ms
);
// And all extensions will be defined.
Assert
.
AreEqual
(
message
,
copy
);
}
[
Test
]
public
void
TestPlainBuilder
()
{
TestXmlMessage
.
Builder
builder
=
TestXmlMessage
.
CreateBuilder
()
.
SetValid
(
true
)
.
SetText
(
"text"
)
.
AddTextlines
(
"a"
)
.
AddTextlines
(
"b"
)
.
AddTextlines
(
"c"
)
.
SetNumber
(
0x1010101010
)
.
AddNumbers
(
1
)
.
AddNumbers
(
2
)
.
AddNumbers
(
3
)
.
SetChild
(
TestXmlChild
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
ONE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
1
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
TWO
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
2
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
THREE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
3
])))
;
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
builder
);
ms
.
Position
=
0
;
TestXmlMessage
.
Builder
copy
=
(
TestXmlMessage
.
Builder
)
new
BinaryFormatter
().
Deserialize
(
ms
);
Assert
.
AreEqual
(
builder
.
Build
(),
copy
.
Build
());
}
[
Test
]
public
void
TestBuilderWithExtensions
()
{
TestXmlMessage
.
Builder
builder
=
TestXmlMessage
.
CreateBuilder
()
.
SetValid
(
true
)
.
SetText
(
"text"
)
.
AddTextlines
(
"a"
)
.
AddTextlines
(
"b"
)
.
AddTextlines
(
"c"
)
.
SetNumber
(
0x1010101010
)
.
AddNumbers
(
1
)
.
AddNumbers
(
2
)
.
AddNumbers
(
3
)
.
SetChild
(
TestXmlChild
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
ONE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
1
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
TWO
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
2
])))
.
AddChildren
(
TestXmlMessage
.
Types
.
Children
.
CreateBuilder
().
AddOptions
(
EnumOptions
.
THREE
).
SetBinary
(
ByteString
.
CopyFrom
(
new
byte
[
3
])))
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionText
,
" extension text value ! "
)
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionMessage
,
new
TestXmlExtension
.
Builder
().
SetNumber
(
42
).
Build
())
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
100
)
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
101
)
.
AddExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionNumber
,
102
)
.
SetExtension
(
UnitTestXmlSerializerTestProtoFile
.
ExtensionEnum
,
EnumOptions
.
ONE
)
;
ExtensionRegistry
registry
=
ExtensionRegistry
.
CreateInstance
();
UnitTestXmlSerializerTestProtoFile
.
RegisterAllExtensions
(
registry
);
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
builder
);
ms
.
Position
=
0
;
//you need to provide the extension registry as context to the serializer
BinaryFormatter
bff
=
new
BinaryFormatter
(
null
,
new
StreamingContext
(
StreamingContextStates
.
All
,
registry
));
TestXmlMessage
.
Builder
copy
=
(
TestXmlMessage
.
Builder
)
bff
.
Deserialize
(
ms
);
// And all extensions will be defined.
Assert
.
AreEqual
(
builder
.
Build
(),
copy
.
Build
());
}
}
}
src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
View file @
3c6e9328
...
...
@@ -76,9 +76,9 @@ namespace Google.ProtocolBuffers.TestProtos {
"dGVuc2lvbl9udW1iZXISJy5wcm90b2J1Zl91bml0dGVzdF9leHRyYS5UZXN0"
+
"WG1sTWVzc2FnZRhnIAMoBUICEAE6bgoRZXh0ZW5zaW9uX21lc3NhZ2USJy5w"
+
"cm90b2J1Zl91bml0dGVzdF9leHRyYS5UZXN0WG1sTWVzc2FnZRjHASABKAsy"
+
"KS5wcm90b2J1Zl91bml0dGVzdF9leHRyYS5UZXN0WG1sRXh0ZW5zaW9uQk
x
I"
+
"AcI+
Rw
ohR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9zEiJVbml0"
+
"VGVzdFhtbFNlcmlhbGl6ZXJUZXN0UHJvdG9GaWxl"
);
"KS5wcm90b2J1Zl91bml0dGVzdF9leHRyYS5UZXN0WG1sRXh0ZW5zaW9uQk
5
I"
+
"AcI+
SQ
ohR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9zEiJVbml0"
+
"VGVzdFhtbFNlcmlhbGl6ZXJUZXN0UHJvdG9GaWxl
SAE=
"
);
pbd
::
FileDescriptor
.
InternalDescriptorAssigner
assigner
=
delegate
(
pbd
::
FileDescriptor
root
)
{
descriptor
=
root
;
internal__static_protobuf_unittest_extra_TestXmlChild__Descriptor
=
Descriptor
.
MessageTypes
[
0
];
...
...
@@ -134,6 +134,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#
endregion
#
region
Messages
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -264,6 +265,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -443,6 +445,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -532,6 +535,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -641,6 +645,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -746,6 +751,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -903,6 +909,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -935,6 +942,7 @@ namespace Google.ProtocolBuffers.TestProtos {
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
public
static
class
Types
{
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1065,6 +1073,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1441,6 +1450,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1792,6 +1802,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1898,6 +1909,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
src/ProtocolBuffers/AbstractBuilder.cs
View file @
3c6e9328
...
...
@@ -44,7 +44,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Implementation of the non-generic IMessage interface as far as possible.
/// </summary>
public
abstract
class
AbstractBuilder
<
TMessage
,
TBuilder
>
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>,
public
abstract
partial
class
AbstractBuilder
<
TMessage
,
TBuilder
>
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>,
IBuilder
<
TMessage
,
TBuilder
>
where
TMessage
:
AbstractMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
AbstractBuilder
<
TMessage
,
TBuilder
>
...
...
src/ProtocolBuffers/AbstractBuilderLite.cs
View file @
3c6e9328
...
...
@@ -42,7 +42,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Implementation of the non-generic IMessage interface as far as possible.
/// </summary>
public
abstract
class
AbstractBuilderLite
<
TMessage
,
TBuilder
>
:
IBuilderLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
AbstractBuilderLite
<
TMessage
,
TBuilder
>
:
IBuilderLite
<
TMessage
,
TBuilder
>
where
TMessage
:
AbstractMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/AbstractMessage.cs
View file @
3c6e9328
...
...
@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Implementation of the non-generic IMessage interface as far as possible.
/// </summary>
public
abstract
class
AbstractMessage
<
TMessage
,
TBuilder
>
:
AbstractMessageLite
<
TMessage
,
TBuilder
>,
public
abstract
partial
class
AbstractMessage
<
TMessage
,
TBuilder
>
:
AbstractMessageLite
<
TMessage
,
TBuilder
>,
IMessage
<
TMessage
,
TBuilder
>
where
TMessage
:
AbstractMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
AbstractBuilder
<
TMessage
,
TBuilder
>
...
...
src/ProtocolBuffers/AbstractMessageLite.cs
View file @
3c6e9328
...
...
@@ -41,7 +41,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Implementation of the non-generic IMessage interface as far as possible.
/// </summary>
public
abstract
class
AbstractMessageLite
<
TMessage
,
TBuilder
>
:
IMessageLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
AbstractMessageLite
<
TMessage
,
TBuilder
>
:
IMessageLite
<
TMessage
,
TBuilder
>
where
TMessage
:
AbstractMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/CustomSerialization.cs
0 → 100644
View file @
3c6e9328
#
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
System
;
using
System.Runtime.Serialization
;
/*
* This entire source file is not supported on the Silverlight platform
*/
#if !SILVERLIGHT2
namespace
Google.ProtocolBuffers
{
/*
* Specialized handing of *all* message types. Messages are serialized into a byte[] and stored
* into the SerializationInfo, they are then reconstituded by an IObjectReference class after
* deserialization. IDeserializationCallback is supported on both the Builder and Message.
*/
[
Serializable
]
partial
class
AbstractMessageLite
<
TMessage
,
TBuilder
>
:
ISerializable
{
void
ISerializable
.
GetObjectData
(
SerializationInfo
info
,
StreamingContext
context
)
{
info
.
SetType
(
typeof
(
SerializationSurrogate
));
info
.
AddValue
(
"message"
,
ToByteArray
());
info
.
AddValue
(
"initialized"
,
IsInitialized
);
}
[
Serializable
]
private
sealed
class
SerializationSurrogate
:
IObjectReference
,
ISerializable
{
static
readonly
TBuilder
TemplateInstance
=
(
TBuilder
)
Activator
.
CreateInstance
(
typeof
(
TBuilder
));
private
readonly
byte
[]
_message
;
private
readonly
bool
_initialized
;
private
SerializationSurrogate
(
SerializationInfo
info
,
StreamingContext
context
)
{
_message
=
(
byte
[])
info
.
GetValue
(
"message"
,
typeof
(
byte
[]));
_initialized
=
info
.
GetBoolean
(
"initialized"
);
}
Object
IObjectReference
.
GetRealObject
(
StreamingContext
context
)
{
ExtensionRegistry
registry
=
context
.
Context
as
ExtensionRegistry
;
TBuilder
builder
=
TemplateInstance
.
DefaultInstanceForType
.
CreateBuilderForType
();
builder
.
MergeFrom
(
_message
,
registry
??
ExtensionRegistry
.
Empty
);
if
(
builder
is
IDeserializationCallback
)
((
IDeserializationCallback
)
builder
).
OnDeserialization
(
context
);
TMessage
message
=
_initialized
?
builder
.
Build
()
:
builder
.
BuildPartial
();
if
(
message
is
IDeserializationCallback
)
((
IDeserializationCallback
)
message
).
OnDeserialization
(
context
);
return
message
;
}
void
ISerializable
.
GetObjectData
(
SerializationInfo
info
,
StreamingContext
context
)
{
info
.
AddValue
(
"message"
,
_message
);
}
}
}
[
Serializable
]
partial
class
AbstractBuilderLite
<
TMessage
,
TBuilder
>
:
ISerializable
{
void
ISerializable
.
GetObjectData
(
SerializationInfo
info
,
StreamingContext
context
)
{
info
.
SetType
(
typeof
(
SerializationSurrogate
));
info
.
AddValue
(
"message"
,
Clone
().
BuildPartial
().
ToByteArray
());
}
[
Serializable
]
private
sealed
class
SerializationSurrogate
:
IObjectReference
,
ISerializable
{
static
readonly
TBuilder
TemplateInstance
=
(
TBuilder
)
Activator
.
CreateInstance
(
typeof
(
TBuilder
));
private
readonly
byte
[]
_message
;
private
SerializationSurrogate
(
SerializationInfo
info
,
StreamingContext
context
)
{
_message
=
(
byte
[])
info
.
GetValue
(
"message"
,
typeof
(
byte
[]));
}
Object
IObjectReference
.
GetRealObject
(
StreamingContext
context
)
{
ExtensionRegistry
registry
=
context
.
Context
as
ExtensionRegistry
;
TBuilder
builder
=
TemplateInstance
.
DefaultInstanceForType
.
CreateBuilderForType
();
builder
.
MergeFrom
(
_message
,
registry
??
ExtensionRegistry
.
Empty
);
if
(
builder
is
IDeserializationCallback
)
((
IDeserializationCallback
)
builder
).
OnDeserialization
(
context
);
return
builder
;
}
void
ISerializable
.
GetObjectData
(
SerializationInfo
info
,
StreamingContext
context
)
{
info
.
AddValue
(
"message"
,
_message
);
}
}
}
/*
* Spread some attribute love around, keeping this all here so we don't use conditional compliation
* in every one of these classes. If we introduce a new platform that also does not support this
* we can control it all from this source file.
*/
[
Serializable
]
partial
class
GeneratedMessageLite
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
ExtendableMessageLite
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
AbstractMessage
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
GeneratedMessage
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
ExtendableMessage
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
ExtendableBuilderLite
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
AbstractBuilder
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
GeneratedBuilder
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
ExtendableBuilder
<
TMessage
,
TBuilder
>
{
}
[
Serializable
]
partial
class
DynamicMessage
{
[
Serializable
]
partial
class
Builder
{
}
}
}
#
endif
\ No newline at end of file
src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
View file @
3c6e9328
This diff is collapsed.
Click to expand it.
src/ProtocolBuffers/DynamicMessage.cs
View file @
3c6e9328
...
...
@@ -44,7 +44,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// An implementation of IMessage that can represent arbitrary types, given a MessageaDescriptor.
/// </summary>
public
sealed
class
DynamicMessage
:
AbstractMessage
<
DynamicMessage
,
DynamicMessage
.
Builder
>
public
sealed
partial
class
DynamicMessage
:
AbstractMessage
<
DynamicMessage
,
DynamicMessage
.
Builder
>
{
private
readonly
MessageDescriptor
type
;
private
readonly
FieldSet
fields
;
...
...
@@ -308,7 +308,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Builder for dynamic messages. Instances are created with DynamicMessage.CreateBuilder.
/// </summary>
public
sealed
class
Builder
:
AbstractBuilder
<
DynamicMessage
,
Builder
>
public
sealed
partial
class
Builder
:
AbstractBuilder
<
DynamicMessage
,
Builder
>
{
private
readonly
MessageDescriptor
type
;
private
FieldSet
fields
;
...
...
src/ProtocolBuffers/ExtendableBuilder.cs
View file @
3c6e9328
...
...
@@ -40,7 +40,7 @@ using Google.ProtocolBuffers.Descriptors;
namespace
Google.ProtocolBuffers
{
public
abstract
class
ExtendableBuilder
<
TMessage
,
TBuilder
>
:
GeneratedBuilder
<
TMessage
,
TBuilder
>
public
abstract
partial
class
ExtendableBuilder
<
TMessage
,
TBuilder
>
:
GeneratedBuilder
<
TMessage
,
TBuilder
>
where
TMessage
:
ExtendableMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilder
<
TMessage
,
TBuilder
>,
new
()
{
...
...
src/ProtocolBuffers/ExtendableBuilderLite.cs
View file @
3c6e9328
...
...
@@ -40,7 +40,7 @@ using Google.ProtocolBuffers.Descriptors;
namespace
Google.ProtocolBuffers
{
public
abstract
class
ExtendableBuilderLite
<
TMessage
,
TBuilder
>
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
ExtendableBuilderLite
<
TMessage
,
TBuilder
>
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
where
TMessage
:
ExtendableMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/ExtendableMessage.cs
View file @
3c6e9328
...
...
@@ -41,7 +41,7 @@ using Google.ProtocolBuffers.Descriptors;
namespace
Google.ProtocolBuffers
{
public
abstract
class
ExtendableMessage
<
TMessage
,
TBuilder
>
:
GeneratedMessage
<
TMessage
,
TBuilder
>
public
abstract
partial
class
ExtendableMessage
<
TMessage
,
TBuilder
>
:
GeneratedMessage
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilder
<
TMessage
,
TBuilder
>,
new
()
{
...
...
src/ProtocolBuffers/ExtendableMessageLite.cs
View file @
3c6e9328
...
...
@@ -42,7 +42,7 @@ using Google.ProtocolBuffers.Collections;
namespace
Google.ProtocolBuffers
{
public
abstract
class
ExtendableMessageLite
<
TMessage
,
TBuilder
>
:
GeneratedMessageLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
ExtendableMessageLite
<
TMessage
,
TBuilder
>
:
GeneratedMessageLite
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/GeneratedBuilder.cs
View file @
3c6e9328
...
...
@@ -47,7 +47,7 @@ namespace Google.ProtocolBuffers
/// most of the IBuilder interface using reflection. Users can ignore this class
/// as an implementation detail.
/// </summary>
public
abstract
class
GeneratedBuilder
<
TMessage
,
TBuilder
>
:
AbstractBuilder
<
TMessage
,
TBuilder
>
public
abstract
partial
class
GeneratedBuilder
<
TMessage
,
TBuilder
>
:
AbstractBuilder
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilder
<
TMessage
,
TBuilder
>,
new
()
{
...
...
src/ProtocolBuffers/GeneratedBuilderLite.cs
View file @
3c6e9328
...
...
@@ -44,7 +44,7 @@ namespace Google.ProtocolBuffers
/// most of the IBuilder interface using reflection. Users can ignore this class
/// as an implementation detail.
/// </summary>
public
abstract
class
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
:
AbstractBuilderLite
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/GeneratedMessage.cs
View file @
3c6e9328
...
...
@@ -50,7 +50,7 @@ namespace Google.ProtocolBuffers
/// most of the IMessage interface using reflection. Users
/// can ignore this class as an implementation detail.
/// </summary>
public
abstract
class
GeneratedMessage
<
TMessage
,
TBuilder
>
:
AbstractMessage
<
TMessage
,
TBuilder
>
public
abstract
partial
class
GeneratedMessage
<
TMessage
,
TBuilder
>
:
AbstractMessage
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessage
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilder
<
TMessage
,
TBuilder
>,
new
()
{
...
...
src/ProtocolBuffers/GeneratedMessageLite.cs
View file @
3c6e9328
...
...
@@ -47,7 +47,7 @@ namespace Google.ProtocolBuffers
/// most of the IMessage interface using reflection. Users
/// can ignore this class as an implementation detail.
/// </summary>
public
abstract
class
GeneratedMessageLite
<
TMessage
,
TBuilder
>
:
AbstractMessageLite
<
TMessage
,
TBuilder
>
public
abstract
partial
class
GeneratedMessageLite
<
TMessage
,
TBuilder
>
:
AbstractMessageLite
<
TMessage
,
TBuilder
>
where
TMessage
:
GeneratedMessageLite
<
TMessage
,
TBuilder
>
where
TBuilder
:
GeneratedBuilderLite
<
TMessage
,
TBuilder
>
{
...
...
src/ProtocolBuffers/IBuilderLite.cs
View file @
3c6e9328
...
...
@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers
/// use explicit interface implemenation for the non-generic form. This mirrors
/// how IEnumerable and IEnumerable<T> work.
/// </summary>
public
interface
IBuilderLite
public
partial
interface
IBuilderLite
{
/// <summary>
/// Returns true iff all required fields in the message and all
...
...
src/ProtocolBuffers/IMessageLite.cs
View file @
3c6e9328
...
...
@@ -42,7 +42,7 @@ namespace Google.ProtocolBuffers
/// Non-generic interface used for all parts of the API which don't require
/// any type knowledge.
/// </summary>
public
interface
IMessageLite
public
partial
interface
IMessageLite
{
/// <summary>
/// Returns true iff all required fields in the message and all embedded
...
...
src/ProtocolBuffers/ProtocolBuffers.csproj
View file @
3c6e9328
...
...
@@ -105,6 +105,7 @@
<Compile
Include=
"Collections\IPopsicleList.cs"
/>
<Compile
Include=
"Collections\PopsicleList.cs"
/>
<Compile
Include=
"CodedOutputStream.ComputeSize.cs"
/>
<Compile
Include=
"CustomSerialization.cs"
/>
<Compile
Include=
"Delegates.cs"
/>
<Compile
Include=
"CodedInputStream.cs"
/>
<Compile
Include=
"CodedOutputStream.cs"
/>
...
...
src/ProtocolBuffers/ProtocolBuffersLite.csproj
View file @
3c6e9328
...
...
@@ -86,6 +86,7 @@
<Compile
Include=
"Collections\Lists.cs"
/>
<Compile
Include=
"Collections\PopsicleList.cs"
/>
<Compile
Include=
"Collections\ReadOnlyDictionary.cs"
/>
<Compile
Include=
"CustomSerialization.cs"
/>
<Compile
Include=
"Descriptors\FieldMappingAttribute.cs"
/>
<Compile
Include=
"Descriptors\FieldType.cs"
/>
<Compile
Include=
"Descriptors\MappedType.cs"
/>
...
...
src/ProtocolBuffers/UnknownFieldSet.cs
View file @
3c6e9328
...
...
@@ -53,7 +53,7 @@ namespace Google.ProtocolBuffers
///
/// Most users will never need to use this class directly.
/// </summary>
public
sealed
class
UnknownFieldSet
:
IMessageLite
public
sealed
partial
class
UnknownFieldSet
:
IMessageLite
{
private
static
readonly
UnknownFieldSet
defaultInstance
=
new
UnknownFieldSet
(
new
Dictionary
<
int
,
UnknownField
>());
...
...
@@ -314,7 +314,7 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Builder for UnknownFieldSets.
/// </summary>
public
sealed
class
Builder
:
IBuilderLite
public
sealed
partial
class
Builder
:
IBuilderLite
{
/// <summary>
/// Mapping from number to field. Note that by using a SortedList we ensure
...
...
src/ProtocolBuffers2008.sln
View file @
3c6e9328
...
...
@@ -23,7 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unittest", "unittest", "{C8
..\protos\extest\unittest_generic_services.proto = ..\protos\extest\unittest_generic_services.proto
..\protos\google\protobuf\unittest_import.proto = ..\protos\google\protobuf\unittest_import.proto
..\protos\google\protobuf\unittest_import_lite.proto = ..\protos\google\protobuf\unittest_import_lite.proto
..\protos\extest\unittest_issues.proto = ..\protos\extest\unittest_issues.proto
..\protos\google\protobuf\unittest_lite.proto = ..\protos\google\protobuf\unittest_lite.proto
..\protos\google\protobuf\unittest_lite_imports_nonlite.proto = ..\protos\google\protobuf\unittest_lite_imports_nonlite.proto
..\protos\google\protobuf\unittest_mset.proto = ..\protos\google\protobuf\unittest_mset.proto
...
...
src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
View file @
3c6e9328
...
...
@@ -61,6 +61,7 @@
<Compile
Include=
"ExtendableBuilderLiteTest.cs"
/>
<Compile
Include=
"ExtendableMessageLiteTest.cs"
/>
<Compile
Include=
"LiteTest.cs"
/>
<Compile
Include=
"SerializableLiteTest.cs"
/>
<Compile
Include=
"TestLiteByApi.cs"
/>
<Compile
Include=
"TestProtos\UnitTestExtrasLiteProtoFile.cs"
/>
<Compile
Include=
"TestProtos\UnitTestImportLiteProtoFile.cs"
/>
...
...
src/ProtocolBuffersLite.Test/SerializableLiteTest.cs
0 → 100644
View file @
3c6e9328
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Runtime.Serialization
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Text
;
using
Google.ProtocolBuffers.TestProtos
;
using
NUnit.Framework
;
namespace
Google.ProtocolBuffers
{
[
TestFixture
]
public
class
SerializableLiteTest
{
/// <summary>
/// Just keep it from even compiling if we these objects don't implement the expected interface.
/// </summary>
public
static
readonly
ISerializable
CompileTimeCheckSerializableMessage
=
TestRequiredLite
.
DefaultInstance
;
public
static
readonly
ISerializable
CompileTimeCheckSerializableBuilder
=
new
TestRequiredLite
.
Builder
();
[
Test
]
public
void
TestPlainMessage
()
{
TestRequiredLite
message
=
TestRequiredLite
.
CreateBuilder
()
.
SetD
(
42
)
.
BuildPartial
();
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
message
);
ms
.
Position
=
0
;
TestRequiredLite
copy
=
(
TestRequiredLite
)
new
BinaryFormatter
().
Deserialize
(
ms
);
Assert
.
AreEqual
(
message
,
copy
);
}
[
Test
]
public
void
TestPlainBuilder
()
{
TestRequiredLite
.
Builder
builder
=
TestRequiredLite
.
CreateBuilder
()
.
SetD
(
42
)
;
MemoryStream
ms
=
new
MemoryStream
();
new
BinaryFormatter
().
Serialize
(
ms
,
builder
);
ms
.
Position
=
0
;
TestRequiredLite
.
Builder
copy
=
(
TestRequiredLite
.
Builder
)
new
BinaryFormatter
().
Deserialize
(
ms
);
Assert
.
AreEqual
(
builder
.
BuildPartial
(),
copy
.
BuildPartial
());
}
}
}
src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
View file @
3c6e9328
...
...
@@ -55,6 +55,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#
endregion
#
region
Messages
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -190,6 +191,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -335,6 +337,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -367,6 +370,7 @@ namespace Google.ProtocolBuffers.TestProtos {
WORK
=
2
,
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -501,6 +505,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -647,6 +652,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -842,6 +848,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1293,6 +1300,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1589,6 +1597,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
@@ -1704,6 +1713,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return
(
Builder
)
new
Builder
().
MergeFrom
(
prototype
);
}
[
global
::
System
.
SerializableAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"ProtoGen"
,
"2.3.0.277"
)]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment