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
a098e809
Commit
a098e809
authored
Sep 02, 2016
by
Jisi Liu
Committed by
GitHub
Sep 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1862 from pherl/3.0.0-GA
Cherry pick c# changes from master
parents
9befe479
4e169bf0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
16 deletions
+18
-16
JsonFormatterTest.cs
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+6
-0
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+10
-2
csharp_enum.cc
src/google/protobuf/compiler/csharp/csharp_enum.cc
+1
-3
csharp_generator.cc
src/google/protobuf/compiler/csharp/csharp_generator.cc
+0
-3
csharp_options.h
src/google/protobuf/compiler/csharp/csharp_options.h
+1
-8
No files found.
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
View file @
a098e809
...
...
@@ -230,6 +230,12 @@ namespace Google.Protobuf
[
TestCase
(
"foo_bar"
,
"fooBar"
)]
[
TestCase
(
"bananaBanana"
,
"bananaBanana"
)]
[
TestCase
(
"BANANABanana"
,
"bananaBanana"
)]
[
TestCase
(
"simple"
,
"simple"
)]
[
TestCase
(
"ACTION_AND_ADVENTURE"
,
"actionAndAdventure"
)]
[
TestCase
(
"action_and_adventure"
,
"actionAndAdventure"
)]
[
TestCase
(
"kFoo"
,
"kFoo"
)]
[
TestCase
(
"HTTPServer"
,
"httpServer"
)]
[
TestCase
(
"CLIENT"
,
"client"
)]
public
void
ToCamelCase
(
string
original
,
string
expected
)
{
Assert
.
AreEqual
(
expected
,
JsonFormatter
.
ToCamelCase
(
original
));
...
...
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
a098e809
...
...
@@ -274,7 +274,6 @@ namespace Google.Protobuf
}
// Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase
// TODO: Use the new field in FieldDescriptor.
internal
static
string
ToCamelCase
(
string
input
)
{
bool
capitalizeNext
=
false
;
...
...
@@ -305,6 +304,7 @@ namespace Google.Protobuf
(!
wasCap
||
(
i
+
1
<
input
.
Length
&&
char
.
IsLower
(
input
[
i
+
1
]))))
{
firstWord
=
false
;
result
.
Append
(
input
[
i
]);
}
else
{
...
...
@@ -320,8 +320,16 @@ namespace Google.Protobuf
result
.
Append
(
char
.
ToUpperInvariant
(
input
[
i
]));
continue
;
}
else
{
result
.
Append
(
input
[
i
]);
continue
;
}
}
else
{
result
.
Append
(
char
.
ToLowerInvariant
(
input
[
i
]));
}
result
.
Append
(
input
[
i
]);
}
return
result
.
ToString
();
}
...
...
src/google/protobuf/compiler/csharp/csharp_enum.cc
View file @
a098e809
...
...
@@ -68,9 +68,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
for
(
int
i
=
0
;
i
<
descriptor_
->
value_count
();
i
++
)
{
WriteEnumValueDocComment
(
printer
,
descriptor_
->
value
(
i
));
string
original_name
=
descriptor_
->
value
(
i
)
->
name
();
string
name
=
options
()
->
legacy_enum_values
?
descriptor_
->
value
(
i
)
->
name
()
:
GetEnumValueName
(
descriptor_
->
name
(),
descriptor_
->
value
(
i
)
->
name
());
string
name
=
GetEnumValueName
(
descriptor_
->
name
(),
descriptor_
->
value
(
i
)
->
name
());
// Make sure we don't get any duplicate names due to prefix removal.
while
(
!
used_names
.
insert
(
name
).
second
)
{
// It's possible we'll end up giving this warning multiple times, but that's better than not at all.
...
...
src/google/protobuf/compiler/csharp/csharp_generator.cc
View file @
a098e809
...
...
@@ -83,9 +83,6 @@ bool Generator::Generate(
cli_options
.
base_namespace_specified
=
true
;
}
else
if
(
options
[
i
].
first
==
"internal_access"
)
{
cli_options
.
internal_access
=
true
;
}
else
if
(
options
[
i
].
first
==
"legacy_enum_values"
)
{
// TODO: Remove this before final release
cli_options
.
legacy_enum_values
=
true
;
}
else
{
*
error
=
"Unknown generator option: "
+
options
[
i
].
first
;
return
false
;
...
...
src/google/protobuf/compiler/csharp/csharp_options.h
View file @
a098e809
...
...
@@ -45,8 +45,7 @@ struct Options {
file_extension
(
".cs"
),
base_namespace
(
""
),
base_namespace_specified
(
false
),
internal_access
(
false
),
legacy_enum_values
(
false
)
{
internal_access
(
false
)
{
}
// Extension of the generated file. Defaults to ".cs"
string
file_extension
;
...
...
@@ -69,12 +68,6 @@ struct Options {
// Whether the generated classes should have accessibility level of "internal".
// Defaults to false that generates "public" classes.
bool
internal_access
;
// By default, C# codegen now uses PascalCased enum values names, after
// removing the enum type name as a prefix (if it *is* a prefix of the value).
// Setting this option reverts to the previous behavior of just copying the
// value name specified in the .proto file, allowing gradual migration.
// This option will be removed before final release.
bool
legacy_enum_values
;
};
}
// namespace csharp
...
...
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