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
b49d3c78
Commit
b49d3c78
authored
Nov 03, 2009
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Compact Framework 3.5
parent
0aac0e4f
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
181 additions
and
31 deletions
+181
-31
CodedInputStream.cs
src/ProtocolBuffers/CodedInputStream.cs
+1
-1
CodedOutputStream.cs
src/ProtocolBuffers/CodedOutputStream.cs
+2
-3
ReflectionUtil.cs
src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
+4
-5
RepeatedMessageAccessor.cs
src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs
+1
-1
RepeatedPrimitiveAccessor.cs
src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
+7
-5
SingleMessageAccessor.cs
src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs
+1
-1
SinglePrimitiveAccessor.cs
src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs
+5
-3
FieldSet.cs
src/ProtocolBuffers/FieldSet.cs
+3
-3
GeneratedMessage.cs
src/ProtocolBuffers/GeneratedMessage.cs
+2
-2
MessageStreamIterator.cs
src/ProtocolBuffers/MessageStreamIterator.cs
+5
-2
AssemblyInfo.cs
src/ProtocolBuffers/Properties/AssemblyInfo.cs
+2
-0
ProtocolBuffers.csproj
src/ProtocolBuffers/ProtocolBuffers.csproj
+1
-1
ProtocolBuffersCF.csproj
src/ProtocolBuffers/ProtocolBuffersCF.csproj
+144
-0
SortedList.cs
src/ProtocolBuffers/SortedList.cs
+1
-1
UnknownFieldSet.cs
src/ProtocolBuffers/UnknownFieldSet.cs
+2
-3
No files found.
src/ProtocolBuffers/CodedInputStream.cs
View file @
b49d3c78
...
@@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers {
...
@@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers {
/// Read a double field from the stream.
/// Read a double field from the stream.
/// </summary>
/// </summary>
public
double
ReadDouble
()
{
public
double
ReadDouble
()
{
#if SILVERLIGHT2
#if SILVERLIGHT2
|| COMPACT_FRAMEWORK_35
byte
[]
bytes
=
ReadRawBytes
(
8
);
byte
[]
bytes
=
ReadRawBytes
(
8
);
return
BitConverter
.
ToDouble
(
bytes
,
0
);
return
BitConverter
.
ToDouble
(
bytes
,
0
);
#else
#else
...
...
src/ProtocolBuffers/CodedOutputStream.cs
View file @
b49d3c78
...
@@ -332,7 +332,7 @@ namespace Google.ProtocolBuffers {
...
@@ -332,7 +332,7 @@ namespace Google.ProtocolBuffers {
/// </summary>
/// </summary>
public
void
WriteDoubleNoTag
(
double
value
)
{
public
void
WriteDoubleNoTag
(
double
value
)
{
// TODO(jonskeet): Test this on different endiannesses
// TODO(jonskeet): Test this on different endiannesses
#if SILVERLIGHT2
#if SILVERLIGHT2
|| COMPACT_FRAMEWORK_35
byte
[]
bytes
=
BitConverter
.
GetBytes
(
value
);
byte
[]
bytes
=
BitConverter
.
GetBytes
(
value
);
WriteRawBytes
(
bytes
,
0
,
8
);
WriteRawBytes
(
bytes
,
0
,
8
);
#else
#else
...
@@ -1140,4 +1140,4 @@ namespace Google.ProtocolBuffers {
...
@@ -1140,4 +1140,4 @@ namespace Google.ProtocolBuffers {
}
}
}
}
}
}
}
}
\ No newline at end of file
src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
View file @
b49d3c78
...
@@ -64,13 +64,12 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -64,13 +64,12 @@ namespace Google.ProtocolBuffers.FieldAccess {
public
static
Func
<
TSource
,
object
>
CreateUpcastDelegateImpl
<
TSource
,
TResult
>(
MethodInfo
method
)
{
public
static
Func
<
TSource
,
object
>
CreateUpcastDelegateImpl
<
TSource
,
TResult
>(
MethodInfo
method
)
{
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method()
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method()
// we'll call getter(x).
// we'll call getter(x).
Func
<
TSource
,
TResult
>
getter
=
(
Func
<
TSource
,
TResult
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TSource
,
TResult
>),
method
);
Func
<
TSource
,
TResult
>
getter
=
(
Func
<
TSource
,
TResult
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TSource
,
TResult
>),
null
,
method
);
// Implicit upcast to object (within the delegate)
// Implicit upcast to object (within the delegate)
return
delegate
(
TSource
source
)
{
return
getter
(
source
);
};
return
delegate
(
TSource
source
)
{
return
getter
(
source
);
};
}
}
/// <summary>
/// <summary>
/// Creates a delegate which will execute the given method after casting the parameter
/// Creates a delegate which will execute the given method after casting the parameter
/// down from object to the required parameter type.
/// down from object to the required parameter type.
...
@@ -84,7 +83,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -84,7 +83,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
public
static
Action
<
TSource
,
object
>
CreateDowncastDelegateImpl
<
TSource
,
TParam
>(
MethodInfo
method
)
{
public
static
Action
<
TSource
,
object
>
CreateDowncastDelegateImpl
<
TSource
,
TParam
>(
MethodInfo
method
)
{
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
// call Method(x, y)
// call Method(x, y)
Action
<
TSource
,
TParam
>
call
=
(
Action
<
TSource
,
TParam
>)
Delegate
.
CreateDelegate
(
typeof
(
Action
<
TSource
,
TParam
>),
method
);
Action
<
TSource
,
TParam
>
call
=
(
Action
<
TSource
,
TParam
>)
Delegate
.
CreateDelegate
(
typeof
(
Action
<
TSource
,
TParam
>),
null
,
method
);
return
delegate
(
TSource
source
,
object
parameter
)
{
call
(
source
,
(
TParam
)
parameter
);
};
return
delegate
(
TSource
source
,
object
parameter
)
{
call
(
source
,
(
TParam
)
parameter
);
};
}
}
...
@@ -103,7 +102,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -103,7 +102,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
// Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll
// call Method(x, y)
// call Method(x, y)
Func
<
TSource
,
TParam
,
TReturn
>
call
=
(
Func
<
TSource
,
TParam
,
TReturn
>)
Func
<
TSource
,
TParam
,
TReturn
>
call
=
(
Func
<
TSource
,
TParam
,
TReturn
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TSource
,
TParam
,
TReturn
>),
method
);
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TSource
,
TParam
,
TReturn
>),
null
,
method
);
return
delegate
(
TSource
source
,
object
parameter
)
{
call
(
source
,
(
TParam
)
parameter
);
};
return
delegate
(
TSource
source
,
object
parameter
)
{
call
(
source
,
(
TParam
)
parameter
);
};
}
}
...
@@ -118,7 +117,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -118,7 +117,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
}
}
public
static
Func
<
IBuilder
>
CreateStaticUpcastDelegateImpl
<
T
>(
MethodInfo
method
)
{
public
static
Func
<
IBuilder
>
CreateStaticUpcastDelegateImpl
<
T
>(
MethodInfo
method
)
{
Func
<
T
>
call
=
(
Func
<
T
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
T
>),
method
);
Func
<
T
>
call
=
(
Func
<
T
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
T
>),
null
,
method
);
return
delegate
{
return
(
IBuilder
)
call
();
};
return
delegate
{
return
(
IBuilder
)
call
();
};
}
}
}
}
...
...
src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs
View file @
b49d3c78
...
@@ -52,7 +52,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -52,7 +52,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
private
readonly
Func
<
IBuilder
>
createBuilderDelegate
;
private
readonly
Func
<
IBuilder
>
createBuilderDelegate
;
internal
RepeatedMessageAccessor
(
string
name
)
:
base
(
name
)
{
internal
RepeatedMessageAccessor
(
string
name
)
:
base
(
name
)
{
MethodInfo
createBuilderMethod
=
ClrType
.
GetMethod
(
"CreateBuilder"
,
Type
.
EmptyTypes
);
MethodInfo
createBuilderMethod
=
ClrType
.
GetMethod
(
"CreateBuilder"
,
EmptyTypes
);
if
(
createBuilderMethod
==
null
)
{
if
(
createBuilderMethod
==
null
)
{
throw
new
ArgumentException
(
"No public static CreateBuilder method declared in "
+
ClrType
.
Name
);
throw
new
ArgumentException
(
"No public static CreateBuilder method declared in "
+
ClrType
.
Name
);
}
}
...
...
src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
View file @
b49d3c78
...
@@ -35,7 +35,7 @@ using System.Reflection;
...
@@ -35,7 +35,7 @@ using System.Reflection;
namespace
Google.ProtocolBuffers.FieldAccess
{
namespace
Google.ProtocolBuffers.FieldAccess
{
/// <summary>
/// <summary>
/// Accesor for a repeated field of type int, ByteString etc.
/// Acces
s
or for a repeated field of type int, ByteString etc.
/// </summary>
/// </summary>
internal
class
RepeatedPrimitiveAccessor
<
TMessage
,
TBuilder
>
:
IFieldAccessor
<
TMessage
,
TBuilder
>
internal
class
RepeatedPrimitiveAccessor
<
TMessage
,
TBuilder
>
:
IFieldAccessor
<
TMessage
,
TBuilder
>
where
TMessage
:
IMessage
<
TMessage
,
TBuilder
>
where
TMessage
:
IMessage
<
TMessage
,
TBuilder
>
...
@@ -49,7 +49,9 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -49,7 +49,9 @@ namespace Google.ProtocolBuffers.FieldAccess {
private
readonly
Func
<
TMessage
,
int
>
countDelegate
;
private
readonly
Func
<
TMessage
,
int
>
countDelegate
;
private
readonly
MethodInfo
getElementMethod
;
private
readonly
MethodInfo
getElementMethod
;
private
readonly
MethodInfo
setElementMethod
;
private
readonly
MethodInfo
setElementMethod
;
// Replacement for Type.EmptyTypes which apparently isn't available on the compact framework
internal
static
readonly
Type
[]
EmptyTypes
=
new
Type
[
0
];
/// <summary>
/// <summary>
/// The CLR type of the field (int, the enum type, ByteString, the message etc).
/// The CLR type of the field (int, the enum type, ByteString, the message etc).
...
@@ -64,7 +66,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -64,7 +66,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
PropertyInfo
messageProperty
=
typeof
(
TMessage
).
GetProperty
(
name
+
"List"
);
PropertyInfo
messageProperty
=
typeof
(
TMessage
).
GetProperty
(
name
+
"List"
);
PropertyInfo
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
+
"List"
);
PropertyInfo
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
+
"List"
);
PropertyInfo
countProperty
=
typeof
(
TMessage
).
GetProperty
(
name
+
"Count"
);
PropertyInfo
countProperty
=
typeof
(
TMessage
).
GetProperty
(
name
+
"Count"
);
MethodInfo
clearMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Clear"
+
name
,
Type
.
EmptyTypes
);
MethodInfo
clearMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Clear"
+
name
,
EmptyTypes
);
getElementMethod
=
typeof
(
TMessage
).
GetMethod
(
"Get"
+
name
,
new
Type
[]
{
typeof
(
int
)
});
getElementMethod
=
typeof
(
TMessage
).
GetMethod
(
"Get"
+
name
,
new
Type
[]
{
typeof
(
int
)
});
clrType
=
getElementMethod
.
ReturnType
;
clrType
=
getElementMethod
.
ReturnType
;
MethodInfo
addMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Add"
+
name
,
new
Type
[]
{
ClrType
});
MethodInfo
addMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Add"
+
name
,
new
Type
[]
{
ClrType
});
...
@@ -78,9 +80,9 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -78,9 +80,9 @@ namespace Google.ProtocolBuffers.FieldAccess {
||
setElementMethod
==
null
)
{
||
setElementMethod
==
null
)
{
throw
new
ArgumentException
(
"Not all required properties/methods available"
);
throw
new
ArgumentException
(
"Not all required properties/methods available"
);
}
}
clearDelegate
=
(
Func
<
TBuilder
,
IBuilder
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TBuilder
,
IBuilder
>),
clearMethod
);
clearDelegate
=
(
Func
<
TBuilder
,
IBuilder
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TBuilder
,
IBuilder
>),
null
,
clearMethod
);
countDelegate
=
(
Func
<
TMessage
,
int
>)
Delegate
.
CreateDelegate
countDelegate
=
(
Func
<
TMessage
,
int
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TMessage
,
int
>),
countProperty
.
GetGetMethod
());
(
typeof
(
Func
<
TMessage
,
int
>),
null
,
countProperty
.
GetGetMethod
());
getValueDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TMessage
>(
messageProperty
.
GetGetMethod
());
getValueDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TMessage
>(
messageProperty
.
GetGetMethod
());
addValueDelegate
=
ReflectionUtil
.
CreateDowncastDelegateIgnoringReturn
<
TBuilder
>(
addMethod
);
addValueDelegate
=
ReflectionUtil
.
CreateDowncastDelegateIgnoringReturn
<
TBuilder
>(
addMethod
);
getRepeatedWrapperDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TBuilder
>(
builderProperty
.
GetGetMethod
());
getRepeatedWrapperDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TBuilder
>(
builderProperty
.
GetGetMethod
());
...
...
src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs
View file @
b49d3c78
...
@@ -48,7 +48,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -48,7 +48,7 @@ namespace Google.ProtocolBuffers.FieldAccess {
private
readonly
Func
<
IBuilder
>
createBuilderDelegate
;
private
readonly
Func
<
IBuilder
>
createBuilderDelegate
;
internal
SingleMessageAccessor
(
string
name
)
:
base
(
name
)
{
internal
SingleMessageAccessor
(
string
name
)
:
base
(
name
)
{
MethodInfo
createBuilderMethod
=
ClrType
.
GetMethod
(
"CreateBuilder"
,
Type
.
EmptyTypes
);
MethodInfo
createBuilderMethod
=
ClrType
.
GetMethod
(
"CreateBuilder"
,
EmptyTypes
);
if
(
createBuilderMethod
==
null
)
{
if
(
createBuilderMethod
==
null
)
{
throw
new
ArgumentException
(
"No public static CreateBuilder method declared in "
+
ClrType
.
Name
);
throw
new
ArgumentException
(
"No public static CreateBuilder method declared in "
+
ClrType
.
Name
);
}
}
...
...
src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs
View file @
b49d3c78
...
@@ -46,6 +46,8 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -46,6 +46,8 @@ namespace Google.ProtocolBuffers.FieldAccess {
private
readonly
Func
<
TMessage
,
bool
>
hasDelegate
;
private
readonly
Func
<
TMessage
,
bool
>
hasDelegate
;
private
readonly
Func
<
TBuilder
,
IBuilder
>
clearDelegate
;
private
readonly
Func
<
TBuilder
,
IBuilder
>
clearDelegate
;
internal
static
readonly
Type
[]
EmptyTypes
=
new
Type
[
0
];
/// <summary>
/// <summary>
/// The CLR type of the field (int, the enum type, ByteString, the message etc).
/// The CLR type of the field (int, the enum type, ByteString, the message etc).
/// As declared by the property.
/// As declared by the property.
...
@@ -59,13 +61,13 @@ namespace Google.ProtocolBuffers.FieldAccess {
...
@@ -59,13 +61,13 @@ namespace Google.ProtocolBuffers.FieldAccess {
PropertyInfo
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
);
PropertyInfo
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
);
if
(
builderProperty
==
null
)
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
);
if
(
builderProperty
==
null
)
builderProperty
=
typeof
(
TBuilder
).
GetProperty
(
name
);
PropertyInfo
hasProperty
=
typeof
(
TMessage
).
GetProperty
(
"Has"
+
name
);
PropertyInfo
hasProperty
=
typeof
(
TMessage
).
GetProperty
(
"Has"
+
name
);
MethodInfo
clearMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Clear"
+
name
,
Type
.
EmptyTypes
);
MethodInfo
clearMethod
=
typeof
(
TBuilder
).
GetMethod
(
"Clear"
+
name
,
EmptyTypes
);
if
(
messageProperty
==
null
||
builderProperty
==
null
||
hasProperty
==
null
||
clearMethod
==
null
)
{
if
(
messageProperty
==
null
||
builderProperty
==
null
||
hasProperty
==
null
||
clearMethod
==
null
)
{
throw
new
ArgumentException
(
"Not all required properties/methods available"
);
throw
new
ArgumentException
(
"Not all required properties/methods available"
);
}
}
clrType
=
messageProperty
.
PropertyType
;
clrType
=
messageProperty
.
PropertyType
;
hasDelegate
=
(
Func
<
TMessage
,
bool
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TMessage
,
bool
>),
hasProperty
.
GetGetMethod
());
hasDelegate
=
(
Func
<
TMessage
,
bool
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TMessage
,
bool
>),
null
,
hasProperty
.
GetGetMethod
());
clearDelegate
=
(
Func
<
TBuilder
,
IBuilder
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TBuilder
,
IBuilder
>),
clearMethod
);
clearDelegate
=
(
Func
<
TBuilder
,
IBuilder
>)
Delegate
.
CreateDelegate
(
typeof
(
Func
<
TBuilder
,
IBuilder
>),
null
,
clearMethod
);
getValueDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TMessage
>(
messageProperty
.
GetGetMethod
());
getValueDelegate
=
ReflectionUtil
.
CreateUpcastDelegate
<
TMessage
>(
messageProperty
.
GetGetMethod
());
setValueDelegate
=
ReflectionUtil
.
CreateDowncastDelegate
<
TBuilder
>(
builderProperty
.
GetSetMethod
());
setValueDelegate
=
ReflectionUtil
.
CreateDowncastDelegate
<
TBuilder
>(
builderProperty
.
GetSetMethod
());
}
}
...
...
src/ProtocolBuffers/FieldSet.cs
View file @
b49d3c78
...
@@ -65,8 +65,8 @@ namespace Google.ProtocolBuffers {
...
@@ -65,8 +65,8 @@ namespace Google.ProtocolBuffers {
}
}
public
static
FieldSet
CreateInstance
()
{
public
static
FieldSet
CreateInstance
()
{
// Use Sorted
Dictionary
to keep fields in the canonical order
// Use Sorted
List
to keep fields in the canonical order
return
new
FieldSet
(
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>());
return
new
FieldSet
(
new
Sorted
List
<
FieldDescriptor
,
object
>());
}
}
/// <summary>
/// <summary>
...
@@ -85,7 +85,7 @@ namespace Google.ProtocolBuffers {
...
@@ -85,7 +85,7 @@ namespace Google.ProtocolBuffers {
}
}
if
(
hasRepeats
)
{
if
(
hasRepeats
)
{
var
tmp
=
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>();
var
tmp
=
new
Sorted
List
<
FieldDescriptor
,
object
>();
foreach
(
KeyValuePair
<
FieldDescriptor
,
object
>
entry
in
fields
)
{
foreach
(
KeyValuePair
<
FieldDescriptor
,
object
>
entry
in
fields
)
{
IList
<
object
>
list
=
entry
.
Value
as
IList
<
object
>;
IList
<
object
>
list
=
entry
.
Value
as
IList
<
object
>;
tmp
[
entry
.
Key
]
=
list
==
null
?
entry
.
Value
:
Lists
.
AsReadOnly
(
list
);
tmp
[
entry
.
Key
]
=
list
==
null
?
entry
.
Value
:
Lists
.
AsReadOnly
(
list
);
...
...
src/ProtocolBuffers/GeneratedMessage.cs
View file @
b49d3c78
...
@@ -69,8 +69,8 @@ namespace Google.ProtocolBuffers {
...
@@ -69,8 +69,8 @@ namespace Google.ProtocolBuffers {
internal
IDictionary
<
FieldDescriptor
,
Object
>
GetMutableFieldMap
()
{
internal
IDictionary
<
FieldDescriptor
,
Object
>
GetMutableFieldMap
()
{
// Use a Sorted
Dictionary
so we'll end up serializing fields in order
// Use a Sorted
List
so we'll end up serializing fields in order
var
ret
=
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>();
var
ret
=
new
Sorted
List
<
FieldDescriptor
,
object
>();
MessageDescriptor
descriptor
=
DescriptorForType
;
MessageDescriptor
descriptor
=
DescriptorForType
;
foreach
(
FieldDescriptor
field
in
descriptor
.
Fields
)
{
foreach
(
FieldDescriptor
field
in
descriptor
.
Fields
)
{
IFieldAccessor
<
TMessage
,
TBuilder
>
accessor
=
InternalFieldAccessors
[
field
];
IFieldAccessor
<
TMessage
,
TBuilder
>
accessor
=
InternalFieldAccessors
[
field
];
...
...
src/ProtocolBuffers/MessageStreamIterator.cs
View file @
b49d3c78
...
@@ -54,6 +54,9 @@ namespace Google.ProtocolBuffers {
...
@@ -54,6 +54,9 @@ namespace Google.ProtocolBuffers {
private
readonly
ExtensionRegistry
extensionRegistry
;
private
readonly
ExtensionRegistry
extensionRegistry
;
private
readonly
int
sizeLimit
;
private
readonly
int
sizeLimit
;
// Type.EmptyTypes isn't present on the compact framework
private
static
readonly
Type
[]
EmptyTypes
=
new
Type
[
0
];
/// <summary>
/// <summary>
/// Delegate created via reflection trickery (once per type) to create a builder
/// Delegate created via reflection trickery (once per type) to create a builder
/// and read a message from a CodedInputStream with it. Note that unlike in Java,
/// and read a message from a CodedInputStream with it. Note that unlike in Java,
...
@@ -77,7 +80,7 @@ namespace Google.ProtocolBuffers {
...
@@ -77,7 +80,7 @@ namespace Google.ProtocolBuffers {
Type
builderType
=
FindBuilderType
();
Type
builderType
=
FindBuilderType
();
// Yes, it's redundant to find this again, but it's only the once...
// Yes, it's redundant to find this again, but it's only the once...
MethodInfo
createBuilderMethod
=
typeof
(
TMessage
).
GetMethod
(
"CreateBuilder"
,
Type
.
EmptyTypes
);
MethodInfo
createBuilderMethod
=
typeof
(
TMessage
).
GetMethod
(
"CreateBuilder"
,
EmptyTypes
);
Delegate
builderBuilder
=
Delegate
.
CreateDelegate
(
Delegate
builderBuilder
=
Delegate
.
CreateDelegate
(
typeof
(
Func
<>).
MakeGenericType
(
builderType
),
null
,
createBuilderMethod
);
typeof
(
Func
<>).
MakeGenericType
(
builderType
),
null
,
createBuilderMethod
);
...
@@ -102,7 +105,7 @@ namespace Google.ProtocolBuffers {
...
@@ -102,7 +105,7 @@ namespace Google.ProtocolBuffers {
/// Works out the builder type for TMessage, or throws an ArgumentException to explain why it can't.
/// Works out the builder type for TMessage, or throws an ArgumentException to explain why it can't.
/// </summary>
/// </summary>
private
static
Type
FindBuilderType
()
{
private
static
Type
FindBuilderType
()
{
MethodInfo
createBuilderMethod
=
typeof
(
TMessage
).
GetMethod
(
"CreateBuilder"
,
Type
.
EmptyTypes
);
MethodInfo
createBuilderMethod
=
typeof
(
TMessage
).
GetMethod
(
"CreateBuilder"
,
EmptyTypes
);
if
(
createBuilderMethod
==
null
)
{
if
(
createBuilderMethod
==
null
)
{
throw
new
ArgumentException
(
"Message type "
+
typeof
(
TMessage
).
FullName
+
" has no CreateBuilder method."
);
throw
new
ArgumentException
(
"Message type "
+
typeof
(
TMessage
).
FullName
+
" has no CreateBuilder method."
);
}
}
...
...
src/ProtocolBuffers/Properties/AssemblyInfo.cs
View file @
b49d3c78
...
@@ -64,7 +64,9 @@ using System.Runtime.CompilerServices;
...
@@ -64,7 +64,9 @@ using System.Runtime.CompilerServices;
// by using the '*' as shown below:
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
#if !COMPACT_FRAMEWORK_35
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
#endif
[
assembly
:
InternalsVisibleTo
(
"Google.ProtocolBuffers.Test,PublicKey="
+
[
assembly
:
InternalsVisibleTo
(
"Google.ProtocolBuffers.Test,PublicKey="
+
"00240000048000009400000006020000002400005253413100040000010001008179f2dd31a648"
+
"00240000048000009400000006020000002400005253413100040000010001008179f2dd31a648"
+
...
...
src/ProtocolBuffers/ProtocolBuffers.csproj
View file @
b49d3c78
...
@@ -114,7 +114,7 @@
...
@@ -114,7 +114,7 @@
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"RpcUtil.cs"
/>
<Compile
Include=
"RpcUtil.cs"
/>
<Compile
Include=
"SilverlightCompatibility.cs"
/>
<Compile
Include=
"SilverlightCompatibility.cs"
/>
<Compile
Include=
"Sorted
Dictionary
.cs"
/>
<Compile
Include=
"Sorted
List
.cs"
/>
<Compile
Include=
"TextFormat.cs"
/>
<Compile
Include=
"TextFormat.cs"
/>
<Compile
Include=
"TextGenerator.cs"
/>
<Compile
Include=
"TextGenerator.cs"
/>
<Compile
Include=
"TextTokenizer.cs"
/>
<Compile
Include=
"TextTokenizer.cs"
/>
...
...
src/ProtocolBuffers/ProtocolBuffersCF.csproj
0 → 100644
View file @
b49d3c78
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{49B51802-9D09-4AD8-A0EE-0DA704EFA379}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Google.ProtocolBuffers</RootNamespace>
<AssemblyName>Google.ProtocolBuffers</AssemblyName>
<ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PlatformFamilyName>PocketPC</PlatformFamilyName>
<PlatformID>b2c48bd2-963d-4549-9169-1fa021dce484</PlatformID>
<OSVersion>5.2</OSVersion>
<DeployDirSuffix>compactframework</DeployDirSuffix>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<NativePlatformName>Windows Mobile 6 Professional SDK</NativePlatformName>
<FormFactorID>
</FormFactorID>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>COMPACT_FRAMEWORK_35;DEBUG;TRACE;$(PlatformFamilyName)</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<FileAlignment>512</FileAlignment>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>COMPACT_FRAMEWORK_35;TRACE;$(PlatformFamilyName)</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<FileAlignment>512</FileAlignment>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractBuilder.cs" />
<Compile Include="AbstractMessage.cs" />
<Compile Include="ByteString.cs" />
<Compile Include="CodedInputStream.cs" />
<Compile Include="CodedOutputStream.cs" />
<Compile Include="Collections\Dictionaries.cs" />
<Compile Include="Collections\Enumerables.cs" />
<Compile Include="Collections\IPopsicleList.cs" />
<Compile Include="Collections\Lists.cs" />
<Compile Include="Collections\PopsicleList.cs" />
<Compile Include="Collections\ReadOnlyDictionary.cs" />
<Compile Include="Delegates.cs" />
<Compile Include="DescriptorProtos\CSharpOptions.cs" />
<Compile Include="DescriptorProtos\DescriptorProtoFile.cs" />
<Compile Include="DescriptorProtos\IDescriptorProto.cs" />
<Compile Include="DescriptorProtos\PartialClasses.cs" />
<Compile Include="Descriptors\DescriptorBase.cs" />
<Compile Include="Descriptors\DescriptorPool.cs" />
<Compile Include="Descriptors\DescriptorUtil.cs" />
<Compile Include="Descriptors\DescriptorValidationException.cs" />
<Compile Include="Descriptors\EnumDescriptor.cs" />
<Compile Include="Descriptors\EnumValueDescriptor.cs" />
<Compile Include="Descriptors\FieldDescriptor.cs" />
<Compile Include="Descriptors\FieldMappingAttribute.cs" />
<Compile Include="Descriptors\FieldType.cs" />
<Compile Include="Descriptors\FileDescriptor.cs" />
<Compile Include="Descriptors\IDescriptor.cs" />
<Compile Include="Descriptors\IndexedDescriptorBase.cs" />
<Compile Include="Descriptors\MappedType.cs" />
<Compile Include="Descriptors\MessageDescriptor.cs" />
<Compile Include="Descriptors\MethodDescriptor.cs" />
<Compile Include="Descriptors\PackageDescriptor.cs" />
<Compile Include="Descriptors\ServiceDescriptor.cs" />
<Compile Include="DynamicMessage.cs" />
<Compile Include="ExtendableBuilder.cs" />
<Compile Include="ExtendableMessage.cs" />
<Compile Include="ExtensionInfo.cs" />
<Compile Include="ExtensionRegistry.cs" />
<Compile Include="FieldAccess\FieldAccessorTable.cs" />
<Compile Include="FieldAccess\IFieldAccessor.cs" />
<Compile Include="FieldAccess\ReflectionUtil.cs" />
<Compile Include="FieldAccess\RepeatedEnumAccessor.cs" />
<Compile Include="FieldAccess\RepeatedMessageAccessor.cs" />
<Compile Include="FieldAccess\RepeatedPrimitiveAccessor.cs" />
<Compile Include="FieldAccess\SingleEnumAccessor.cs" />
<Compile Include="FieldAccess\SingleMessageAccessor.cs" />
<Compile Include="FieldAccess\SinglePrimitiveAccessor.cs" />
<Compile Include="FieldSet.cs" />
<Compile Include="GeneratedBuilder.cs" />
<Compile Include="GeneratedExtensionBase.cs" />
<Compile Include="GeneratedMessage.cs" />
<Compile Include="GeneratedRepeatExtension.cs" />
<Compile Include="GeneratedSingleExtension.cs" />
<Compile Include="IBuilder.cs" />
<Compile Include="IMessage.cs" />
<Compile Include="InvalidProtocolBufferException.cs" />
<Compile Include="IRpcChannel.cs" />
<Compile Include="IRpcController.cs" />
<Compile Include="IService.cs" />
<Compile Include="MessageStreamIterator.cs" />
<Compile Include="MessageStreamWriter.cs" />
<Compile Include="MessageUtil.cs" />
<Compile Include="NameHelpers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RpcUtil.cs" />
<Compile Include="SilverlightCompatibility.cs" />
<Compile Include="SortedList.cs" />
<Compile Include="TextFormat.cs" />
<Compile Include="TextGenerator.cs" />
<Compile Include="TextTokenizer.cs" />
<Compile Include="ThrowHelper.cs" />
<Compile Include="UninitializedMessageException.cs" />
<Compile Include="UnknownField.cs" />
<Compile Include="UnknownFieldSet.cs" />
<Compile Include="WireFormat.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
<HostingProcess disable="1" />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
src/ProtocolBuffers/Sorted
Dictionary
.cs
→
src/ProtocolBuffers/Sorted
List
.cs
View file @
b49d3c78
...
@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers
...
@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers
/// This is only used for Silverlight, which doesn't have the normal
/// This is only used for Silverlight, which doesn't have the normal
/// sorted collections.
/// sorted collections.
/// </summary>
/// </summary>
internal
sealed
class
Sorted
Dictionary
<
TKey
,
TValue
>
:
IDictionary
<
TKey
,
TValue
>
internal
sealed
class
Sorted
List
<
TKey
,
TValue
>
:
IDictionary
<
TKey
,
TValue
>
{
{
private
readonly
IDictionary
<
TKey
,
TValue
>
wrapped
=
new
Dictionary
<
TKey
,
TValue
>();
private
readonly
IDictionary
<
TKey
,
TValue
>
wrapped
=
new
Dictionary
<
TKey
,
TValue
>();
...
...
src/ProtocolBuffers/UnknownFieldSet.cs
View file @
b49d3c78
...
@@ -243,11 +243,10 @@ namespace Google.ProtocolBuffers {
...
@@ -243,11 +243,10 @@ namespace Google.ProtocolBuffers {
public
sealed
class
Builder
public
sealed
class
Builder
{
{
/// <summary>
/// <summary>
/// Mapping from number to field. Note that by using a Sorted
Dictionary
we ensure
/// Mapping from number to field. Note that by using a Sorted
List
we ensure
/// that the fields will be serialized in ascending order.
/// that the fields will be serialized in ascending order.
/// </summary>
/// </summary>
private
IDictionary
<
int
,
UnknownField
>
fields
=
new
SortedDictionary
<
int
,
UnknownField
>();
private
IDictionary
<
int
,
UnknownField
>
fields
=
new
SortedList
<
int
,
UnknownField
>();
// Optimization: We keep around a builder for the last field that was
// Optimization: We keep around a builder for the last field that was
// modified so that we can efficiently add to it multiple times in a
// modified so that we can efficiently add to it multiple times in a
// row (important when parsing an unknown repeated field).
// row (important when parsing an unknown repeated field).
...
...
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