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
0d91952a
Commit
0d91952a
authored
Oct 14, 2012
by
csharptest
Committed by
rogerk
Oct 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring compatibility code to use FrameworkPortability class
parent
14e011f6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
20 additions
and
51 deletions
+20
-51
AbstractReader.cs
src/ProtocolBuffers.Serialization/AbstractReader.cs
+0
-24
AbstractTextReader.cs
src/ProtocolBuffers.Serialization/AbstractTextReader.cs
+1
-1
AbstractWriter.cs
src/ProtocolBuffers.Serialization/AbstractWriter.cs
+2
-2
DictionaryReader.cs
src/ProtocolBuffers.Serialization/DictionaryReader.cs
+1
-1
JsonTextCursor.cs
src/ProtocolBuffers.Serialization/JsonTextCursor.cs
+4
-4
XmlFormatReader.cs
src/ProtocolBuffers.Serialization/XmlFormatReader.cs
+1
-1
CodedOutputStream.ComputeSize.cs
src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
+2
-2
Delegates.cs
src/ProtocolBuffers/Delegates.cs
+0
-7
GeneratedMessageLite.cs
src/ProtocolBuffers/GeneratedMessageLite.cs
+1
-1
TextFormat.cs
src/ProtocolBuffers/TextFormat.cs
+6
-6
TextTokenizer.cs
src/ProtocolBuffers/TextTokenizer.cs
+2
-2
No files found.
src/ProtocolBuffers.Serialization/AbstractReader.cs
View file @
0d91952a
...
@@ -698,28 +698,5 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -698,28 +698,5 @@ namespace Google.ProtocolBuffers.Serialization
}
}
#
endregion
#
endregion
internal
static
bool
TryParseInt32
(
string
text
,
out
int
number
)
{
return
TryParseInt32
(
text
,
NumberStyles
.
Any
,
CultureInfo
.
InvariantCulture
,
out
number
);
}
internal
static
bool
TryParseInt32
(
string
text
,
NumberStyles
style
,
IFormatProvider
format
,
out
int
number
)
{
#if COMPACT_FRAMEWORK
try
{
number
=
int
.
Parse
(
text
,
NumberStyles
.
Integer
,
CultureInfo
.
InvariantCulture
);
return
true
;
}
catch
{
number
=
0
;
return
false
;
}
#else
return
int
.
TryParse
(
text
,
NumberStyles
.
Integer
,
CultureInfo
.
InvariantCulture
,
out
number
);
#endif
}
}
}
}
}
\ No newline at end of file
src/ProtocolBuffers.Serialization/AbstractTextReader.cs
View file @
0d91952a
...
@@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers.Serialization
if
(
ReadAsText
(
ref
text
,
typeof
(
Enum
)))
if
(
ReadAsText
(
ref
text
,
typeof
(
Enum
)))
{
{
int
number
;
int
number
;
if
(
TryParseInt32
(
text
,
NumberStyles
.
Integer
,
CultureInfo
.
InvariantCulture
,
out
number
))
if
(
FrameworkPortability
.
TryParseInt32
(
text
,
NumberStyles
.
Integer
,
FrameworkPortability
.
InvariantCulture
,
out
number
))
{
{
value
=
number
;
value
=
number
;
return
true
;
return
true
;
...
...
src/ProtocolBuffers.Serialization/AbstractWriter.cs
View file @
0d91952a
...
@@ -157,8 +157,8 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -157,8 +157,8 @@ namespace Google.ProtocolBuffers.Serialization
}
}
else
if
(
value
is
IConvertible
)
else
if
(
value
is
IConvertible
)
{
{
WriteEnum
(
field
,
((
IConvertible
)
value
).
ToInt32
(
CultureInfo
.
InvariantCulture
),
WriteEnum
(
field
,
((
IConvertible
)
value
).
ToInt32
(
FrameworkPortability
.
InvariantCulture
),
((
IConvertible
)
value
).
ToString
(
CultureInfo
.
InvariantCulture
));
((
IConvertible
)
value
).
ToString
(
FrameworkPortability
.
InvariantCulture
));
}
}
else
else
{
{
...
...
src/ProtocolBuffers.Serialization/DictionaryReader.cs
View file @
0d91952a
...
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers.Serialization
{
{
if
(
obj
is
IConvertible
)
if
(
obj
is
IConvertible
)
{
{
value
=
(
T
)
Convert
.
ChangeType
(
obj
,
typeof
(
T
),
CultureInfo
.
InvariantCulture
);
value
=
(
T
)
Convert
.
ChangeType
(
obj
,
typeof
(
T
),
FrameworkPortability
.
InvariantCulture
);
}
}
else
else
{
{
...
...
src/ProtocolBuffers.Serialization/JsonTextCursor.cs
View file @
0d91952a
...
@@ -195,7 +195,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -195,7 +195,7 @@ namespace Google.ProtocolBuffers.Serialization
if
(!
cond
)
if
(!
cond
)
{
{
throw
new
FormatException
(
throw
new
FormatException
(
String
.
Format
(
CultureInfo
.
InvariantCulture
,
String
.
Format
(
FrameworkPortability
.
InvariantCulture
,
"({0}:{1}) error: Unexpected token {2}, expected: {3}."
,
"({0}:{1}) error: Unexpected token {2}, expected: {3}."
,
_lineNo
,
_linePos
,
_lineNo
,
_linePos
,
CharDisplay
(
_next
),
CharDisplay
(
_next
),
...
@@ -210,7 +210,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -210,7 +210,7 @@ namespace Google.ProtocolBuffers.Serialization
if
(!
cond
)
if
(!
cond
)
{
{
throw
new
FormatException
(
throw
new
FormatException
(
String
.
Format
(
CultureInfo
.
InvariantCulture
,
String
.
Format
(
FrameworkPortability
.
InvariantCulture
,
"({0},{1}) error: {2}"
,
_lineNo
,
_linePos
,
message
));
"({0},{1}) error: {2}"
,
_lineNo
,
_linePos
,
message
));
}
}
}
}
...
@@ -225,7 +225,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -225,7 +225,7 @@ namespace Google.ProtocolBuffers.Serialization
format
=
String
.
Format
(
format
,
args
);
format
=
String
.
Format
(
format
,
args
);
}
}
throw
new
FormatException
(
throw
new
FormatException
(
String
.
Format
(
CultureInfo
.
InvariantCulture
,
String
.
Format
(
FrameworkPortability
.
InvariantCulture
,
"({0},{1}) error: {2}"
,
_lineNo
,
_linePos
,
format
));
"({0},{1}) error: {2}"
,
_lineNo
,
_linePos
,
format
));
}
}
}
}
...
@@ -322,7 +322,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -322,7 +322,7 @@ namespace Google.ProtocolBuffers.Serialization
string
hex
=
new
string
(
new
char
[]
{
ReadChar
(),
ReadChar
(),
ReadChar
(),
ReadChar
()});
string
hex
=
new
string
(
new
char
[]
{
ReadChar
(),
ReadChar
(),
ReadChar
(),
ReadChar
()});
int
result
;
int
result
;
Assert
(
Assert
(
AbstractTextReader
.
TryParseInt32
(
hex
,
NumberStyles
.
AllowHexSpecifier
,
CultureInfo
.
InvariantCulture
,
FrameworkPortability
.
TryParseInt32
(
hex
,
NumberStyles
.
AllowHexSpecifier
,
FrameworkPortability
.
InvariantCulture
,
out
result
),
out
result
),
"Expected a 4-character hex specifier."
);
"Expected a 4-character hex specifier."
);
sb
.
Add
((
char
)
result
);
sb
.
Add
((
char
)
result
);
...
...
src/ProtocolBuffers.Serialization/XmlFormatReader.cs
View file @
0d91952a
...
@@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers.Serialization
...
@@ -269,7 +269,7 @@ namespace Google.ProtocolBuffers.Serialization
{
{
int
number
;
int
number
;
string
temp
;
string
temp
;
if
(
null
!=
(
temp
=
_input
.
GetAttribute
(
"value"
))
&&
TryParseInt32
(
temp
,
out
number
))
if
(
null
!=
(
temp
=
_input
.
GetAttribute
(
"value"
))
&&
FrameworkPortability
.
TryParseInt32
(
temp
,
out
number
))
{
{
Skip
();
Skip
();
value
=
number
;
value
=
number
;
...
...
src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
View file @
0d91952a
...
@@ -575,7 +575,7 @@ namespace Google.ProtocolBuffers
...
@@ -575,7 +575,7 @@ namespace Google.ProtocolBuffers
case
FieldType
.
Enum
:
case
FieldType
.
Enum
:
if
(
value
is
Enum
)
if
(
value
is
Enum
)
{
{
return
ComputeEnumSize
(
fieldNumber
,
((
IConvertible
)
value
).
ToInt32
(
CultureInfo
.
InvariantCulture
));
return
ComputeEnumSize
(
fieldNumber
,
((
IConvertible
)
value
).
ToInt32
(
FrameworkPortability
.
InvariantCulture
));
}
}
else
else
{
{
...
@@ -631,7 +631,7 @@ namespace Google.ProtocolBuffers
...
@@ -631,7 +631,7 @@ namespace Google.ProtocolBuffers
case
FieldType
.
Enum
:
case
FieldType
.
Enum
:
if
(
value
is
Enum
)
if
(
value
is
Enum
)
{
{
return
ComputeEnumSizeNoTag
(((
IConvertible
)
value
).
ToInt32
(
CultureInfo
.
InvariantCulture
));
return
ComputeEnumSizeNoTag
(((
IConvertible
)
value
).
ToInt32
(
FrameworkPortability
.
InvariantCulture
));
}
}
else
else
{
{
...
...
src/ProtocolBuffers/Delegates.cs
View file @
0d91952a
...
@@ -50,11 +50,5 @@ namespace Google.ProtocolBuffers
...
@@ -50,11 +50,5 @@ namespace Google.ProtocolBuffers
internal
delegate
TResult
Func
<
T1
,
T2
,
TResult
>(
T1
arg1
,
T2
arg2
);
internal
delegate
TResult
Func
<
T1
,
T2
,
TResult
>(
T1
arg1
,
T2
arg2
);
internal
delegate
TResult
Func
<
T1
,
T2
,
T3
,
TResult
>(
T1
arg1
,
T2
arg2
,
T3
arg3
);
internal
delegate
TResult
Func
<
T1
,
T2
,
T3
,
T4
,
TResult
>(
T1
arg1
,
T2
arg2
,
T3
arg3
,
T4
arg4
);
internal
delegate
void
Action
();
internal
delegate
void
Action
<
T1
,
T2
>(
T1
arg1
,
T2
arg2
);
internal
delegate
void
Action
<
T1
,
T2
>(
T1
arg1
,
T2
arg2
);
}
}
\ No newline at end of file
src/ProtocolBuffers/GeneratedMessageLite.cs
View file @
0d91952a
...
@@ -111,7 +111,7 @@ namespace Google.ProtocolBuffers
...
@@ -111,7 +111,7 @@ namespace Google.ProtocolBuffers
}
}
else
else
{
{
writer
.
WriteLine
(
"{0}: {1}"
,
name
,
((
IConvertible
)
value
).
ToString
(
CultureInfo
.
InvariantCulture
));
writer
.
WriteLine
(
"{0}: {1}"
,
name
,
((
IConvertible
)
value
).
ToString
(
FrameworkPortability
.
InvariantCulture
));
}
}
}
}
...
...
src/ProtocolBuffers/TextFormat.cs
View file @
0d91952a
...
@@ -170,10 +170,10 @@ namespace Google.ProtocolBuffers
...
@@ -170,10 +170,10 @@ namespace Google.ProtocolBuffers
// the double to/from string will trim the precision to 6 places. As with other numeric formats
// the double to/from string will trim the precision to 6 places. As with other numeric formats
// below, always use the invariant culture so it's predictable.
// below, always use the invariant culture so it's predictable.
case
FieldType
.
Float
:
case
FieldType
.
Float
:
generator
.
Print
(((
float
)
value
).
ToString
(
"r"
,
CultureInfo
.
InvariantCulture
));
generator
.
Print
(((
float
)
value
).
ToString
(
"r"
,
FrameworkPortability
.
InvariantCulture
));
break
;
break
;
case
FieldType
.
Double
:
case
FieldType
.
Double
:
generator
.
Print
(((
double
)
value
).
ToString
(
"r"
,
CultureInfo
.
InvariantCulture
));
generator
.
Print
(((
double
)
value
).
ToString
(
"r"
,
FrameworkPortability
.
InvariantCulture
));
break
;
break
;
case
FieldType
.
Int32
:
case
FieldType
.
Int32
:
...
@@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers
...
@@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers
case
FieldType
.
Fixed64
:
case
FieldType
.
Fixed64
:
// The simple Object.ToString converts using the current culture.
// The simple Object.ToString converts using the current culture.
// We want to always use the invariant culture so it's predictable.
// We want to always use the invariant culture so it's predictable.
generator
.
Print
(((
IConvertible
)
value
).
ToString
(
CultureInfo
.
InvariantCulture
));
generator
.
Print
(((
IConvertible
)
value
).
ToString
(
FrameworkPortability
.
InvariantCulture
));
break
;
break
;
case
FieldType
.
Bool
:
case
FieldType
.
Bool
:
// Explicitly use the Java true/false
// Explicitly use the Java true/false
...
@@ -314,7 +314,7 @@ namespace Google.ProtocolBuffers
...
@@ -314,7 +314,7 @@ namespace Google.ProtocolBuffers
case
"nanf"
:
case
"nanf"
:
return
float
.
NaN
;
return
float
.
NaN
;
default
:
default
:
return
float
.
Parse
(
text
,
CultureInfo
.
InvariantCulture
);
return
float
.
Parse
(
text
,
FrameworkPortability
.
InvariantCulture
);
}
}
}
}
...
@@ -331,7 +331,7 @@ namespace Google.ProtocolBuffers
...
@@ -331,7 +331,7 @@ namespace Google.ProtocolBuffers
case
"nan"
:
case
"nan"
:
return
double
.
NaN
;
return
double
.
NaN
;
default
:
default
:
return
double
.
Parse
(
text
,
CultureInfo
.
InvariantCulture
);
return
double
.
Parse
(
text
,
FrameworkPortability
.
InvariantCulture
);
}
}
}
}
...
@@ -708,7 +708,7 @@ namespace Google.ProtocolBuffers
...
@@ -708,7 +708,7 @@ namespace Google.ProtocolBuffers
{
{
// Explicitly specify the invariant culture so that this code does not break when
// Explicitly specify the invariant culture so that this code does not break when
// executing in Turkey.
// executing in Turkey.
String
lowerName
=
name
.
ToLower
(
CultureInfo
.
InvariantCulture
);
String
lowerName
=
name
.
ToLower
(
FrameworkPortability
.
InvariantCulture
);
field
=
type
.
FindDescriptor
<
FieldDescriptor
>(
lowerName
);
field
=
type
.
FindDescriptor
<
FieldDescriptor
>(
lowerName
);
// If the case-insensitive match worked but the field is NOT a group,
// If the case-insensitive match worked but the field is NOT a group,
// TODO(jonskeet): What? Java comment ends here!
// TODO(jonskeet): What? Java comment ends here!
...
...
src/ProtocolBuffers/TextTokenizer.cs
View file @
0d91952a
...
@@ -346,7 +346,7 @@ namespace Google.ProtocolBuffers
...
@@ -346,7 +346,7 @@ namespace Google.ProtocolBuffers
try
try
{
{
double
result
=
double
.
Parse
(
currentToken
,
CultureInfo
.
InvariantCulture
);
double
result
=
double
.
Parse
(
currentToken
,
FrameworkPortability
.
InvariantCulture
);
NextToken
();
NextToken
();
return
result
;
return
result
;
}
}
...
@@ -387,7 +387,7 @@ namespace Google.ProtocolBuffers
...
@@ -387,7 +387,7 @@ namespace Google.ProtocolBuffers
try
try
{
{
float
result
=
float
.
Parse
(
currentToken
,
CultureInfo
.
InvariantCulture
);
float
result
=
float
.
Parse
(
currentToken
,
FrameworkPortability
.
InvariantCulture
);
NextToken
();
NextToken
();
return
result
;
return
result
;
}
}
...
...
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