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
b075ff5c
Commit
b075ff5c
authored
Nov 03, 2009
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a flag to allow code contracts to be emitted
parent
b49d3c78
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
24 deletions
+61
-24
protoc.exe
lib/protoc.exe
+0
-0
csharp_options.proto
protos/google/protobuf/csharp_options.proto
+3
-2
UmbrellaClassGenerator.cs
src/ProtoGen/UmbrellaClassGenerator.cs
+3
-1
CSharpOptions.cs
src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
+54
-12
FileDescriptor.cs
src/ProtocolBuffers/Descriptors/FileDescriptor.cs
+0
-9
MessageDescriptor.cs
src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
+1
-0
No files found.
lib/protoc.exe
View file @
b075ff5c
No preview for this file type
protos/google/protobuf/csharp_options.proto
View file @
b075ff5c
...
...
@@ -6,10 +6,11 @@ package google.protobuf;
message
CSharpFileOptions
{
optional
string
namespace
=
1
;
optional
string
umbrella_classname
=
2
;
optional
bool
public_classes
=
3
;
optional
string
umbrella_classname
=
2
;
optional
bool
public_classes
=
3
[
default
=
true
]
;
optional
bool
multiple_files
=
4
;
optional
bool
nest_classes
=
5
;
optional
bool
code_contracts
=
6
;
}
extend
FileOptions
{
...
...
src/ProtoGen/UmbrellaClassGenerator.cs
View file @
b075ff5c
...
...
@@ -115,8 +115,10 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"namespace {0} {{"
,
Descriptor
.
CSharpOptions
.
Namespace
);
writer
.
Indent
();
writer
.
WriteLine
();
}
if
(
Descriptor
.
CSharpOptions
.
CodeContracts
)
{
writer
.
WriteLine
(
"[global::System.Diagnostics.Contracts.ContractVerificationAttribute(false)]"
);
}
writer
.
WriteLine
(
"{0} static partial class {1} {{"
,
ClassAccessLevel
,
Descriptor
.
CSharpOptions
.
UmbrellaClassname
);
writer
.
WriteLine
();
writer
.
Indent
();
...
...
src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
View file @
b075ff5c
...
...
@@ -37,21 +37,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
byte
[]
descriptorData
=
global
::
System
.
Convert
.
FromBase64String
(
"CiRnb29nbGUvcHJvdG9idWYvY3NoYXJwX29wdGlvbnMucHJvdG8SD2dvb2ds"
+
"ZS5wcm90b2J1ZhogZ29vZ2xlL3Byb3RvYnVmL2Rlc2NyaXB0b3IucHJvdG8i"
+
"iAEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1"
+
"bWJyZWxsYV9jbGFzc25hbWUYAiABKAkSFgoOcHVibGljX2NsYXNzZXMYAyAB"
+
"KAgSFgoObXVsdGlwbGVfZmlsZXMYBCABKAgSFAoMbmVzdF9jbGFzc2VzGAUg"
+
"ASgIIisKEkNTaGFycEZpZWxkT3B0aW9ucxIVCg1wcm9wZXJ0eV9uYW1lGAEg"
+
"ASgJOl4KE2NzaGFycF9maWxlX29wdGlvbnMSHC5nb29nbGUucHJvdG9idWYu"
+
"RmlsZU9wdGlvbnMY6AcgASgLMiIuZ29vZ2xlLnByb3RvYnVmLkNTaGFycEZp"
+
"bGVPcHRpb25zOmEKFGNzaGFycF9maWVsZF9vcHRpb25zEh0uZ29vZ2xlLnBy"
+
"b3RvYnVmLkZpZWxkT3B0aW9ucxjoByABKAsyIy5nb29nbGUucHJvdG9idWYu"
+
"Q1NoYXJwRmllbGRPcHRpb25z"
);
"pgEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1"
+
"bWJyZWxsYV9jbGFzc25hbWUYAiABKAkSHAoOcHVibGljX2NsYXNzZXMYAyAB"
+
"KAg6BHRydWUSFgoObXVsdGlwbGVfZmlsZXMYBCABKAgSFAoMbmVzdF9jbGFz"
+
"c2VzGAUgASgIEhYKDmNvZGVfY29udHJhY3RzGAYgASgIIisKEkNTaGFycEZp"
+
"ZWxkT3B0aW9ucxIVCg1wcm9wZXJ0eV9uYW1lGAEgASgJOl4KE2NzaGFycF9m"
+
"aWxlX29wdGlvbnMSHC5nb29nbGUucHJvdG9idWYuRmlsZU9wdGlvbnMY6Acg"
+
"ASgLMiIuZ29vZ2xlLnByb3RvYnVmLkNTaGFycEZpbGVPcHRpb25zOmEKFGNz"
+
"aGFycF9maWVsZF9vcHRpb25zEh0uZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0"
+
"aW9ucxjoByABKAsyIy5nb29nbGUucHJvdG9idWYuQ1NoYXJwRmllbGRPcHRp"
+
"b25z"
);
pbd
::
FileDescriptor
.
InternalDescriptorAssigner
assigner
=
delegate
(
pbd
::
FileDescriptor
root
)
{
descriptor
=
root
;
internal__static_google_protobuf_CSharpFileOptions__Descriptor
=
Descriptor
.
MessageTypes
[
0
];
internal__static_google_protobuf_CSharpFileOptions__FieldAccessorTable
=
new
pb
::
FieldAccess
.
FieldAccessorTable
<
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpFileOptions
,
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpFileOptions
.
Builder
>(
internal__static_google_protobuf_CSharpFileOptions__Descriptor
,
new
string
[]
{
"Namespace"
,
"UmbrellaClassname"
,
"PublicClasses"
,
"MultipleFiles"
,
"NestClasses"
,
});
new
string
[]
{
"Namespace"
,
"UmbrellaClassname"
,
"PublicClasses"
,
"MultipleFiles"
,
"NestClasses"
,
"CodeContracts"
,
});
internal__static_google_protobuf_CSharpFieldOptions__Descriptor
=
Descriptor
.
MessageTypes
[
1
];
internal__static_google_protobuf_CSharpFieldOptions__FieldAccessorTable
=
new
pb
::
FieldAccess
.
FieldAccessorTable
<
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpFieldOptions
,
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpFieldOptions
.
Builder
>(
internal__static_google_protobuf_CSharpFieldOptions__Descriptor
,
...
...
@@ -113,7 +114,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public
const
int
PublicClassesFieldNumber
=
3
;
private
bool
hasPublicClasses
;
private
bool
publicClasses_
=
fals
e
;
private
bool
publicClasses_
=
tru
e
;
public
bool
HasPublicClasses
{
get
{
return
hasPublicClasses
;
}
}
...
...
@@ -141,6 +142,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
get
{
return
nestClasses_
;
}
}
public
const
int
CodeContractsFieldNumber
=
6
;
private
bool
hasCodeContracts
;
private
bool
codeContracts_
=
false
;
public
bool
HasCodeContracts
{
get
{
return
hasCodeContracts
;
}
}
public
bool
CodeContracts
{
get
{
return
codeContracts_
;
}
}
public
override
bool
IsInitialized
{
get
{
return
true
;
...
...
@@ -163,6 +174,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if
(
HasNestClasses
)
{
output
.
WriteBool
(
5
,
NestClasses
);
}
if
(
HasCodeContracts
)
{
output
.
WriteBool
(
6
,
CodeContracts
);
}
UnknownFields
.
WriteTo
(
output
);
}
...
...
@@ -188,6 +202,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if
(
HasNestClasses
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
5
,
NestClasses
);
}
if
(
HasCodeContracts
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
6
,
CodeContracts
);
}
size
+=
UnknownFields
.
SerializedSize
;
memoizedSerializedSize
=
size
;
return
size
;
...
...
@@ -295,6 +312,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if
(
other
.
HasNestClasses
)
{
NestClasses
=
other
.
NestClasses
;
}
if
(
other
.
HasCodeContracts
)
{
CodeContracts
=
other
.
CodeContracts
;
}
this
.
MergeUnknownFields
(
other
.
UnknownFields
);
return
this
;
}
...
...
@@ -347,6 +367,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
NestClasses
=
input
.
ReadBool
();
break
;
}
case
48
:
{
CodeContracts
=
input
.
ReadBool
();
break
;
}
}
}
}
...
...
@@ -404,7 +428,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public
Builder
ClearPublicClasses
()
{
result
.
hasPublicClasses
=
false
;
result
.
publicClasses_
=
fals
e
;
result
.
publicClasses_
=
tru
e
;
return
this
;
}
...
...
@@ -443,6 +467,24 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
result
.
nestClasses_
=
false
;
return
this
;
}
public
bool
HasCodeContracts
{
get
{
return
result
.
HasCodeContracts
;
}
}
public
bool
CodeContracts
{
get
{
return
result
.
CodeContracts
;
}
set
{
SetCodeContracts
(
value
);
}
}
public
Builder
SetCodeContracts
(
bool
value
)
{
result
.
hasCodeContracts
=
true
;
result
.
codeContracts_
=
value
;
return
this
;
}
public
Builder
ClearCodeContracts
()
{
result
.
hasCodeContracts
=
false
;
result
.
codeContracts_
=
false
;
return
this
;
}
}
static
CSharpFileOptions
()
{
object
.
ReferenceEquals
(
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpOptions
.
Descriptor
,
null
);
...
...
src/ProtocolBuffers/Descriptors/FileDescriptor.cs
View file @
b075ff5c
...
...
@@ -94,15 +94,6 @@ namespace Google.ProtocolBuffers.Descriptors {
if
(!
builder
.
HasNamespace
)
{
builder
.
Namespace
=
Package
;
}
if
(!
builder
.
HasMultipleFiles
)
{
builder
.
MultipleFiles
=
false
;
}
if
(!
builder
.
HasNestClasses
)
{
builder
.
NestClasses
=
false
;
}
if
(!
builder
.
HasPublicClasses
)
{
builder
.
PublicClasses
=
true
;
}
if
(!
builder
.
HasUmbrellaClassname
)
{
int
lastSlash
=
Name
.
LastIndexOf
(
'/'
);
string
baseName
=
Name
.
Substring
(
lastSlash
+
1
);
...
...
src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
View file @
b075ff5c
...
...
@@ -57,6 +57,7 @@ namespace Google.ProtocolBuffers.Descriptors {
enumTypes
=
DescriptorUtil
.
ConvertAndMakeReadOnly
(
proto
.
EnumTypeList
,
(
type
,
index
)
=>
new
EnumDescriptor
(
type
,
file
,
this
,
index
));
// TODO(jonskeet): Sort fields first?
fields
=
DescriptorUtil
.
ConvertAndMakeReadOnly
(
proto
.
FieldList
,
(
field
,
index
)
=>
new
FieldDescriptor
(
field
,
file
,
this
,
index
,
false
));
...
...
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