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