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
ad2d775e
Commit
ad2d775e
authored
Mar 07, 2016
by
avgweb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace StringBuilder with TextWriter in JsonFormatter
parent
9242d9b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
14 deletions
+26
-14
GeneratedMessageTest.cs
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
+9
-0
MapField.cs
csharp/src/Google.Protobuf/Collections/MapField.cs
+4
-3
RepeatedField.cs
csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+4
-3
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+0
-0
FieldMaskPartial.cs
...rp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
+9
-8
No files found.
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
View file @
ad2d775e
...
...
@@ -710,5 +710,14 @@ namespace Google.Protobuf
Assert
.
AreEqual
(
"{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }"
,
message
.
ToString
());
Assert
.
AreEqual
(
"{ \"singleForeignMessage\": { \"c\": 16 } }"
,
JsonFormatter
.
Default
.
Format
(
message
));
}
[
Test
]
public
void
CustomDiagnosticMessage_DirectToTextWriterCall
()
{
var
message
=
new
ForeignMessage
{
C
=
31
};
var
writer
=
new
StringWriter
();
JsonFormatter
.
Default
.
Format
(
message
,
writer
);
Assert
.
AreEqual
(
"{ \"c\": 31 }"
,
writer
.
ToString
());
}
}
}
csharp/src/Google.Protobuf/Collections/MapField.cs
View file @
ad2d775e
...
...
@@ -34,6 +34,7 @@ using Google.Protobuf.Reflection;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
Google.Protobuf.Compatibility
;
...
...
@@ -474,9 +475,9 @@ namespace Google.Protobuf.Collections
/// </summary>
public
override
string
ToString
()
{
var
builder
=
new
StringBuild
er
();
JsonFormatter
.
Default
.
WriteDictionary
(
build
er
,
this
);
return
build
er
.
ToString
();
var
writer
=
new
StringWrit
er
();
JsonFormatter
.
Default
.
WriteDictionary
(
writ
er
,
this
);
return
writ
er
.
ToString
();
}
#
region
IDictionary
explicit
interface
implementation
...
...
csharp/src/Google.Protobuf/Collections/RepeatedField.cs
View file @
ad2d775e
...
...
@@ -33,6 +33,7 @@
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
namespace
Google.Protobuf.Collections
...
...
@@ -474,9 +475,9 @@ namespace Google.Protobuf.Collections
/// </summary>
public
override
string
ToString
()
{
var
builder
=
new
StringBuild
er
();
JsonFormatter
.
Default
.
WriteList
(
build
er
,
this
);
return
build
er
.
ToString
();
var
writer
=
new
StringWrit
er
();
JsonFormatter
.
Default
.
WriteList
(
writ
er
,
this
);
return
writ
er
.
ToString
();
}
/// <summary>
...
...
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
ad2d775e
This diff is collapsed.
Click to expand it.
csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
View file @
ad2d775e
...
...
@@ -33,6 +33,7 @@
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -57,19 +58,19 @@ namespace Google.Protobuf.WellKnownTypes
var
firstInvalid
=
paths
.
FirstOrDefault
(
p
=>
!
ValidatePath
(
p
));
if
(
firstInvalid
==
null
)
{
var
builder
=
new
StringBuild
er
();
JsonFormatter
.
WriteString
(
build
er
,
string
.
Join
(
","
,
paths
.
Select
(
JsonFormatter
.
ToCamelCase
)));
return
build
er
.
ToString
();
var
writer
=
new
StringWrit
er
();
JsonFormatter
.
WriteString
(
writ
er
,
string
.
Join
(
","
,
paths
.
Select
(
JsonFormatter
.
ToCamelCase
)));
return
writ
er
.
ToString
();
}
else
{
if
(
diagnosticOnly
)
{
var
builder
=
new
StringBuild
er
();
builder
.
Append
(
"{ \"@warning\": \"Invalid FieldMask\", \"paths\": "
);
JsonFormatter
.
Default
.
WriteList
(
builder
,
(
IList
)
paths
);
builder
.
Append
(
" }"
);
return
build
er
.
ToString
();
var
writer
=
new
StringWrit
er
();
writer
.
Write
(
"{ \"@warning\": \"Invalid FieldMask\", \"paths\": "
);
JsonFormatter
.
Default
.
WriteList
(
writer
,
(
IList
)
paths
);
writer
.
Write
(
" }"
);
return
writ
er
.
ToString
();
}
else
{
...
...
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