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
ca4cbda9
Commit
ca4cbda9
authored
Aug 14, 2008
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extensions don't need to go under a separate type.
parent
d6c94957
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
22 deletions
+24
-22
DescriptorsTest.cs
csharp/ProtocolBuffers.Test/DescriptorsTest.cs
+1
-1
MessageTest.cs
csharp/ProtocolBuffers.Test/MessageTest.cs
+4
-4
UnitTestMessageSetProtoFile.cs
...colBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
+4
-4
UnitTestOptimizeForProtoFile.cs
...olBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
+2
-2
UnitTestProtoFile.cs
csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
+2
-2
WireFormatTest.cs
csharp/ProtocolBuffers.Test/WireFormatTest.cs
+6
-6
csharp_message.cc
src/google/protobuf/compiler/csharp/csharp_message.cc
+5
-3
No files found.
csharp/ProtocolBuffers.Test/DescriptorsTest.cs
View file @
ca4cbda9
...
@@ -114,7 +114,7 @@ namespace Google.ProtocolBuffers {
...
@@ -114,7 +114,7 @@ namespace Google.ProtocolBuffers {
FieldDescriptor
messageField
=
messageType
.
FindDescriptor
<
FieldDescriptor
>(
"optional_foreign_message"
);
FieldDescriptor
messageField
=
messageType
.
FindDescriptor
<
FieldDescriptor
>(
"optional_foreign_message"
);
FieldDescriptor
cordField
=
messageType
.
FindDescriptor
<
FieldDescriptor
>(
"optional_cord"
);
FieldDescriptor
cordField
=
messageType
.
FindDescriptor
<
FieldDescriptor
>(
"optional_cord"
);
FieldDescriptor
extension
=
UnitTestProtoFile
.
OptionalInt32Extension
.
Descriptor
;
FieldDescriptor
extension
=
UnitTestProtoFile
.
OptionalInt32Extension
.
Descriptor
;
FieldDescriptor
nestedExtension
=
TestRequired
.
Types
.
Single
.
Descriptor
;
FieldDescriptor
nestedExtension
=
TestRequired
.
Single
.
Descriptor
;
Assert
.
AreEqual
(
"optional_int32"
,
primitiveField
.
Name
);
Assert
.
AreEqual
(
"optional_int32"
,
primitiveField
.
Name
);
Assert
.
AreEqual
(
"protobuf_unittest.TestAllTypes.optional_int32"
,
Assert
.
AreEqual
(
"protobuf_unittest.TestAllTypes.optional_int32"
,
...
...
csharp/ProtocolBuffers.Test/MessageTest.cs
View file @
ca4cbda9
...
@@ -116,16 +116,16 @@ namespace Google.ProtocolBuffers {
...
@@ -116,16 +116,16 @@ namespace Google.ProtocolBuffers {
Assert
.
IsTrue
(
builder
.
IsInitialized
);
Assert
.
IsTrue
(
builder
.
IsInitialized
);
builder
.
SetExtension
(
TestRequired
.
Types
.
Single
,
TestRequiredUninitialized
);
builder
.
SetExtension
(
TestRequired
.
Single
,
TestRequiredUninitialized
);
Assert
.
IsFalse
(
builder
.
IsInitialized
);
Assert
.
IsFalse
(
builder
.
IsInitialized
);
builder
.
SetExtension
(
TestRequired
.
Types
.
Single
,
TestRequiredInitialized
);
builder
.
SetExtension
(
TestRequired
.
Single
,
TestRequiredInitialized
);
Assert
.
IsTrue
(
builder
.
IsInitialized
);
Assert
.
IsTrue
(
builder
.
IsInitialized
);
builder
.
AddExtension
(
TestRequired
.
Types
.
Multi
,
TestRequiredUninitialized
);
builder
.
AddExtension
(
TestRequired
.
Multi
,
TestRequiredUninitialized
);
Assert
.
IsFalse
(
builder
.
IsInitialized
);
Assert
.
IsFalse
(
builder
.
IsInitialized
);
builder
.
SetExtension
(
TestRequired
.
Types
.
Multi
,
0
,
TestRequiredInitialized
);
builder
.
SetExtension
(
TestRequired
.
Multi
,
0
,
TestRequiredInitialized
);
Assert
.
IsTrue
(
builder
.
IsInitialized
);
Assert
.
IsTrue
(
builder
.
IsInitialized
);
}
}
...
...
csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
View file @
ca4cbda9
...
@@ -518,10 +518,10 @@ namespace Google.ProtocolBuffers.TestProtos {
...
@@ -518,10 +518,10 @@ namespace Google.ProtocolBuffers.TestProtos {
get
{
return
self
::
UnitTestMessageSetProtoFile
.
internal__static_protobuf_unittest_TestMessageSetExtension1__FieldAccessorTable
;
}
get
{
return
self
::
UnitTestMessageSetProtoFile
.
internal__static_protobuf_unittest_TestMessageSetExtension1__FieldAccessorTable
;
}
}
}
#
region
Nested
types
public
static
class
Types
{
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestMessageSetExtension1
>
MessageSetExtension
=
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestMessageSetExtension1
>
MessageSetExtension
=
pb
::
GeneratedSingleExtension
<
self
::
TestMessageSetExtension1
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
pb
::
GeneratedSingleExtension
<
self
::
TestMessageSetExtension1
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
#
region
Nested
types
public
static
class
Types
{
}
}
#
endregion
#
endregion
...
@@ -728,10 +728,10 @@ namespace Google.ProtocolBuffers.TestProtos {
...
@@ -728,10 +728,10 @@ namespace Google.ProtocolBuffers.TestProtos {
get
{
return
self
::
UnitTestMessageSetProtoFile
.
internal__static_protobuf_unittest_TestMessageSetExtension2__FieldAccessorTable
;
}
get
{
return
self
::
UnitTestMessageSetProtoFile
.
internal__static_protobuf_unittest_TestMessageSetExtension2__FieldAccessorTable
;
}
}
}
#
region
Nested
types
public
static
class
Types
{
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestMessageSetExtension2
>
MessageSetExtension
=
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestMessageSetExtension2
>
MessageSetExtension
=
pb
::
GeneratedSingleExtension
<
self
::
TestMessageSetExtension2
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
pb
::
GeneratedSingleExtension
<
self
::
TestMessageSetExtension2
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
#
region
Nested
types
public
static
class
Types
{
}
}
#
endregion
#
endregion
...
...
csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
View file @
ca4cbda9
...
@@ -75,10 +75,10 @@ namespace Google.ProtocolBuffers.TestProtos {
...
@@ -75,10 +75,10 @@ namespace Google.ProtocolBuffers.TestProtos {
get
{
return
self
::
UnitTestOptimizeForProtoFile
.
internal__static_protobuf_unittest_TestOptimizedForSize__FieldAccessorTable
;
}
get
{
return
self
::
UnitTestOptimizeForProtoFile
.
internal__static_protobuf_unittest_TestOptimizedForSize__FieldAccessorTable
;
}
}
}
#
region
Nested
types
public
static
class
Types
{
public
static
readonly
pb
::
GeneratedExtensionBase
<
int
>
TestExtension
=
public
static
readonly
pb
::
GeneratedExtensionBase
<
int
>
TestExtension
=
pb
::
GeneratedSingleExtension
<
int
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
pb
::
GeneratedSingleExtension
<
int
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
#
region
Nested
types
public
static
class
Types
{
}
}
#
endregion
#
endregion
...
...
csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
View file @
ca4cbda9
...
@@ -6147,13 +6147,13 @@ namespace Google.ProtocolBuffers.TestProtos {
...
@@ -6147,13 +6147,13 @@ namespace Google.ProtocolBuffers.TestProtos {
get
{
return
self
::
UnitTestProtoFile
.
internal__static_protobuf_unittest_TestRequired__FieldAccessorTable
;
}
get
{
return
self
::
UnitTestProtoFile
.
internal__static_protobuf_unittest_TestRequired__FieldAccessorTable
;
}
}
}
#
region
Nested
types
public
static
class
Types
{
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestRequired
>
Single
=
public
static
readonly
pb
::
GeneratedExtensionBase
<
self
::
TestRequired
>
Single
=
pb
::
GeneratedSingleExtension
<
self
::
TestRequired
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
pb
::
GeneratedSingleExtension
<
self
::
TestRequired
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
public
static
readonly
public
static
readonly
pb
::
GeneratedExtensionBase
<
scg
::
IList
<
self
::
TestRequired
>>
Multi
=
pb
::
GeneratedExtensionBase
<
scg
::
IList
<
self
::
TestRequired
>>
Multi
=
pb
::
GeneratedRepeatExtension
<
self
::
TestRequired
>.
CreateInstance
(
Descriptor
.
Extensions
[
1
]);
pb
::
GeneratedRepeatExtension
<
self
::
TestRequired
>.
CreateInstance
(
Descriptor
.
Extensions
[
1
]);
#
region
Nested
types
public
static
class
Types
{
}
}
#
endregion
#
endregion
...
...
csharp/ProtocolBuffers.Test/WireFormatTest.cs
View file @
ca4cbda9
...
@@ -121,10 +121,10 @@ namespace Google.ProtocolBuffers {
...
@@ -121,10 +121,10 @@ namespace Google.ProtocolBuffers {
TestMessageSet
messageSet
=
TestMessageSet
messageSet
=
TestMessageSet
.
CreateBuilder
()
TestMessageSet
.
CreateBuilder
()
.
SetExtension
(
.
SetExtension
(
TestMessageSetExtension1
.
Types
.
MessageSetExtension
,
TestMessageSetExtension1
.
MessageSetExtension
,
TestMessageSetExtension1
.
CreateBuilder
().
SetI
(
123
).
Build
())
TestMessageSetExtension1
.
CreateBuilder
().
SetI
(
123
).
Build
())
.
SetExtension
(
.
SetExtension
(
TestMessageSetExtension2
.
Types
.
MessageSetExtension
,
TestMessageSetExtension2
.
MessageSetExtension
,
TestMessageSetExtension2
.
CreateBuilder
().
SetStr
(
"foo"
).
Build
())
TestMessageSetExtension2
.
CreateBuilder
().
SetStr
(
"foo"
).
Build
())
.
SetUnknownFields
(
.
SetUnknownFields
(
UnknownFieldSet
.
CreateBuilder
()
UnknownFieldSet
.
CreateBuilder
()
...
@@ -159,8 +159,8 @@ namespace Google.ProtocolBuffers {
...
@@ -159,8 +159,8 @@ namespace Google.ProtocolBuffers {
[
Test
]
[
Test
]
public
void
ParseMessageSet
()
{
public
void
ParseMessageSet
()
{
ExtensionRegistry
extensionRegistry
=
ExtensionRegistry
.
CreateInstance
();
ExtensionRegistry
extensionRegistry
=
ExtensionRegistry
.
CreateInstance
();
extensionRegistry
.
Add
(
TestMessageSetExtension1
.
Types
.
MessageSetExtension
);
extensionRegistry
.
Add
(
TestMessageSetExtension1
.
MessageSetExtension
);
extensionRegistry
.
Add
(
TestMessageSetExtension2
.
Types
.
MessageSetExtension
);
extensionRegistry
.
Add
(
TestMessageSetExtension2
.
MessageSetExtension
);
// Set up a RawMessageSet with two known messages and an unknown one.
// Set up a RawMessageSet with two known messages and an unknown one.
RawMessageSet
raw
=
RawMessageSet
raw
=
...
@@ -194,8 +194,8 @@ namespace Google.ProtocolBuffers {
...
@@ -194,8 +194,8 @@ namespace Google.ProtocolBuffers {
TestMessageSet
messageSet
=
TestMessageSet
messageSet
=
TestMessageSet
.
ParseFrom
(
data
,
extensionRegistry
);
TestMessageSet
.
ParseFrom
(
data
,
extensionRegistry
);
Assert
.
AreEqual
(
123
,
messageSet
.
GetExtension
(
TestMessageSetExtension1
.
Types
.
MessageSetExtension
).
I
);
Assert
.
AreEqual
(
123
,
messageSet
.
GetExtension
(
TestMessageSetExtension1
.
MessageSetExtension
).
I
);
Assert
.
AreEqual
(
"foo"
,
messageSet
.
GetExtension
(
TestMessageSetExtension2
.
Types
.
MessageSetExtension
).
Str
);
Assert
.
AreEqual
(
"foo"
,
messageSet
.
GetExtension
(
TestMessageSetExtension2
.
MessageSetExtension
).
Str
);
// Check for unknown field with type LENGTH_DELIMITED,
// Check for unknown field with type LENGTH_DELIMITED,
// number UNKNOWN_TYPE_ID, and contents "bar".
// number UNKNOWN_TYPE_ID, and contents "bar".
...
...
src/google/protobuf/compiler/csharp/csharp_message.cc
View file @
ca4cbda9
...
@@ -237,6 +237,11 @@ void MessageGenerator::Generate(io::Printer* printer) {
...
@@ -237,6 +237,11 @@ void MessageGenerator::Generate(io::Printer* printer) {
"fileclass"
,
ClassName
(
descriptor_
->
file
()),
"fileclass"
,
ClassName
(
descriptor_
->
file
()),
"identifier"
,
UniqueFileScopeIdentifier
(
descriptor_
));
"identifier"
,
UniqueFileScopeIdentifier
(
descriptor_
));
// Extensions don't need to go in an extra nested type
for
(
int
i
=
0
;
i
<
descriptor_
->
extension_count
();
i
++
)
{
ExtensionGenerator
(
descriptor_
->
extension
(
i
)).
Generate
(
printer
);
}
if
(
descriptor_
->
enum_type_count
()
if
(
descriptor_
->
enum_type_count
()
+
descriptor_
->
nested_type_count
()
+
descriptor_
->
nested_type_count
()
+
descriptor_
->
extension_count
()
>
0
)
{
+
descriptor_
->
extension_count
()
>
0
)
{
...
@@ -252,9 +257,6 @@ void MessageGenerator::Generate(io::Printer* printer) {
...
@@ -252,9 +257,6 @@ void MessageGenerator::Generate(io::Printer* printer) {
MessageGenerator
(
descriptor_
->
nested_type
(
i
)).
Generate
(
printer
);
MessageGenerator
(
descriptor_
->
nested_type
(
i
)).
Generate
(
printer
);
}
}
for
(
int
i
=
0
;
i
<
descriptor_
->
extension_count
();
i
++
)
{
ExtensionGenerator
(
descriptor_
->
extension
(
i
)).
Generate
(
printer
);
}
printer
->
Outdent
();
printer
->
Outdent
();
printer
->
Print
(
"}
\r\n
"
);
printer
->
Print
(
"}
\r\n
"
);
printer
->
Print
(
"#endregion
\r\n\r\n
"
);
printer
->
Print
(
"#endregion
\r\n\r\n
"
);
...
...
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