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
6f8dd211
Commit
6f8dd211
authored
Mar 29, 2016
by
alien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review fixes
parent
0d32ab37
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
7 deletions
+5
-7
unittest_issues.proto
csharp/protos/unittest_issues.proto
+1
-1
IssuesTest.cs
csharp/src/Google.Protobuf.Test/IssuesTest.cs
+1
-0
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+1
-2
FieldDescriptor.cs
csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
+1
-1
MessageDescriptor.cs
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+1
-3
No files found.
csharp/protos/unittest_issues.proto
View file @
6f8dd211
...
...
@@ -119,7 +119,7 @@ message TestJsonFieldOrdering {
}
message
TestJsonName
{
//
json_name field options are not properly handled during deserializa
tion
//
Message for testing the effects for of the json_name op
tion
string
name
=
1
;
string
description
=
2
[
json_name
=
"desc"
];
string
guid
=
3
[
json_name
=
"exid"
];
...
...
csharp/src/Google.Protobuf.Test/IssuesTest.cs
View file @
6f8dd211
...
...
@@ -66,6 +66,7 @@ namespace Google.Protobuf
var
settings
=
new
JsonParser
.
Settings
(
10
,
TypeRegistry
.
FromFiles
(
UnittestIssuesReflection
.
Descriptor
));
var
parser
=
new
JsonParser
(
settings
);
// It is safe to use either original field name or explicitly specified json_name
Assert
.
AreEqual
(
new
TestJsonName
{
Name
=
"test"
,
Description
=
"test2"
,
Guid
=
"test3"
},
parser
.
Parse
<
TestJsonName
>(
"{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"
));
}
...
...
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
6f8dd211
...
...
@@ -238,8 +238,7 @@ namespace Google.Protobuf
writer
.
Write
(
PropertySeparator
);
}
WriteString
(
writer
,
string
.
IsNullOrEmpty
(
accessor
.
Descriptor
.
JsonName
)
?
ToCamelCase
(
accessor
.
Descriptor
.
Name
)
:
accessor
.
Descriptor
.
JsonName
);
WriteString
(
writer
,
accessor
.
Descriptor
.
JsonName
);
writer
.
Write
(
NameValueSeparator
);
WriteValue
(
writer
,
value
);
...
...
csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
View file @
6f8dd211
...
...
@@ -94,7 +94,7 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The json_name option of the descriptor's target.
/// </summary>
public
string
JsonName
{
get
{
return
proto
.
JsonName
;
}
}
public
string
JsonName
{
get
{
return
proto
.
JsonName
==
""
?
JsonFormatter
.
ToCamelCase
(
proto
.
Name
)
:
proto
.
JsonName
;
}
}
internal
FieldDescriptorProto
Proto
{
get
{
return
proto
;
}
}
...
...
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
View file @
6f8dd211
...
...
@@ -102,10 +102,8 @@ namespace Google.Protobuf.Reflection
var
map
=
new
Dictionary
<
string
,
FieldDescriptor
>();
foreach
(
var
field
in
fields
)
{
map
[
JsonFormatter
.
ToCamelCase
(
field
.
Name
)]
=
field
;
map
[
field
.
Name
]
=
field
;
if
(!
string
.
IsNullOrEmpty
(
field
.
JsonName
))
map
[
field
.
JsonName
]
=
field
;
map
[
field
.
JsonName
]
=
field
;
}
return
new
ReadOnlyDictionary
<
string
,
FieldDescriptor
>(
map
);
}
...
...
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