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
1237c3f1
Unverified
Commit
1237c3f1
authored
Dec 14, 2017
by
Jisi Liu
Committed by
GitHub
Dec 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4045 from pherl/deprecate
Add deprecation annotation for oneof case.
parents
426cf6f3
594ec226
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
11 deletions
+34
-11
DeprecatedFieldTest.java
...rc/test/java/com/google/protobuf/DeprecatedFieldTest.java
+14
-6
descriptor_test.py
python/google/protobuf/internal/descriptor_test.py
+13
-0
java_message.cc
src/google/protobuf/compiler/java/java_message.cc
+4
-5
unittest.proto
src/google/protobuf/unittest.proto
+3
-0
No files found.
java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
View file @
1237c3f1
...
...
@@ -37,22 +37,22 @@ import junit.framework.TestCase;
/**
* Test field deprecation
*
*
* @author birdo@google.com (Roberto Scaramuzzi)
*/
public
class
DeprecatedFieldTest
extends
TestCase
{
private
String
[]
deprecatedGetterNames
=
{
"hasDeprecatedInt32"
,
"getDeprecatedInt32"
};
private
String
[]
deprecatedBuilderGetterNames
=
{
"hasDeprecatedInt32"
,
"getDeprecatedInt32"
,
"clearDeprecatedInt32"
};
private
String
[]
deprecatedBuilderSetterNames
=
{
"setDeprecatedInt32"
};
"setDeprecatedInt32"
};
public
void
testDeprecatedField
()
throws
Exception
{
Class
<?>
deprecatedFields
=
TestDeprecatedFields
.
class
;
Class
<?>
deprecatedFieldsBuilder
=
TestDeprecatedFields
.
Builder
.
class
;
...
...
@@ -72,7 +72,15 @@ public class DeprecatedFieldTest extends TestCase {
isDeprecated
(
method
));
}
}
public
void
testDeprecatedFieldInOneof
()
throws
Exception
{
Class
<?>
oneofCase
=
TestDeprecatedFields
.
OneofFieldsCase
.
class
;
String
name
=
"DEPRECATED_INT32_IN_ONEOF"
;
java
.
lang
.
reflect
.
Field
enumValue
=
oneofCase
.
getField
(
name
);
assertTrue
(
"Enum value "
+
name
+
" should be deprecated."
,
isDeprecated
(
enumValue
));
}
private
boolean
isDeprecated
(
AnnotatedElement
annotated
)
{
return
annotated
.
isAnnotationPresent
(
Deprecated
.
class
);
}
...
...
python/google/protobuf/internal/descriptor_test.py
View file @
1237c3f1
...
...
@@ -742,6 +742,19 @@ class DescriptorCopyToProtoTest(unittest.TestCase):
deprecated: true
>
>
field {
name: "deprecated_int32_in_oneof"
number: 2
label: LABEL_OPTIONAL
type: TYPE_INT32
options {
deprecated: true
}
oneof_index: 0
}
oneof_decl {
name: "oneof_fields"
}
"""
self
.
_InternalTestCopyToProto
(
...
...
src/google/protobuf/compiler/java/java_message.cc
View file @
1237c3f1
...
...
@@ -437,11 +437,10 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
for
(
int
j
=
0
;
j
<
descriptor_
->
oneof_decl
(
i
)
->
field_count
();
j
++
)
{
const
FieldDescriptor
*
field
=
descriptor_
->
oneof_decl
(
i
)
->
field
(
j
);
printer
->
Print
(
"$field_name$($field_number$),
\n
"
,
"field_name"
,
ToUpper
(
field
->
name
()),
"field_number"
,
SimpleItoa
(
field
->
number
()));
"$deprecation$$field_name$($field_number$),
\n
"
,
"deprecation"
,
field
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
,
"field_name"
,
ToUpper
(
field
->
name
()),
"field_number"
,
SimpleItoa
(
field
->
number
()));
}
printer
->
Print
(
"$cap_oneof_name$_NOT_SET(0);
\n
"
,
...
...
src/google/protobuf/unittest.proto
View file @
1237c3f1
...
...
@@ -189,6 +189,9 @@ message NestedTestAllTypes {
message
TestDeprecatedFields
{
optional
int32
deprecated_int32
=
1
[
deprecated
=
true
];
oneof
oneof_fields
{
int32
deprecated_int32_in_oneof
=
2
[
deprecated
=
true
];
}
}
message
TestDeprecatedMessage
{
...
...
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