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
d6dd0a45
Commit
d6dd0a45
authored
Jun 05, 2009
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CLSCompliance.
parent
0864d30b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
100 additions
and
1 deletion
+100
-1
EnumFieldGenerator.cs
src/ProtoGen/EnumFieldGenerator.cs
+3
-0
ExtensionGenerator.cs
src/ProtoGen/ExtensionGenerator.cs
+6
-0
FieldGeneratorBase.cs
src/ProtoGen/FieldGeneratorBase.cs
+6
-0
PrimitiveFieldGenerator.cs
src/ProtoGen/PrimitiveFieldGenerator.cs
+3
-0
RepeatedPrimitiveFieldGenerator.cs
src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
+7
-0
AssemblyInfo.cs
src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs
+4
-0
UnitTestCustomOptionsProtoFile.cs
...Buffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
+6
-0
UnitTestProtoFile.cs
src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
+0
-0
CodedInputStream.cs
src/ProtocolBuffers/CodedInputStream.cs
+13
-0
CodedOutputStream.cs
src/ProtocolBuffers/CodedOutputStream.cs
+26
-0
DescriptorProtoFile.cs
src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+3
-0
FieldDescriptor.cs
src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
+4
-0
ExtendableBuilder.cs
src/ProtocolBuffers/ExtendableBuilder.cs
+2
-0
GeneratedBuilder.cs
src/ProtocolBuffers/GeneratedBuilder.cs
+1
-0
AssemblyInfo.cs
src/ProtocolBuffers/Properties/AssemblyInfo.cs
+3
-0
UnknownField.cs
src/ProtocolBuffers/UnknownField.cs
+4
-0
UnknownFieldSet.cs
src/ProtocolBuffers/UnknownFieldSet.cs
+2
-0
WireFormat.cs
src/ProtocolBuffers/WireFormat.cs
+7
-1
No files found.
src/ProtoGen/EnumFieldGenerator.cs
View file @
d6dd0a45
...
...
@@ -15,6 +15,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"public bool Has{0} {{"
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return has{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} {1} {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return {0}_; }}"
,
Name
);
writer
.
WriteLine
(
"}"
);
...
...
@@ -24,10 +25,12 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"public bool Has{0} {{"
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.Has{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} {1} {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
" set {{ Set{0}(value); }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public Builder Set{0}({1} value) {{"
,
PropertyName
,
TypeName
);
writer
.
WriteLine
(
" result.has{0} = true;"
,
PropertyName
);
writer
.
WriteLine
(
" result.{0}_ = value;"
,
Name
);
...
...
src/ProtoGen/ExtensionGenerator.cs
View file @
d6dd0a45
...
...
@@ -30,8 +30,14 @@ namespace Google.ProtocolBuffers.ProtoGen {
public
void
Generate
(
TextGenerator
writer
)
{
writer
.
WriteLine
(
"public const int {0} = {1};"
,
GetFieldConstantName
(
Descriptor
),
Descriptor
.
FieldNumber
);
if
(
Descriptor
.
IsRepeated
)
{
if
(!
Descriptor
.
IsCLSCompliant
)
{
writer
.
WriteLine
(
"[global::System.CLSCompliant(false)]"
);
}
writer
.
WriteLine
(
"{0} static pb::GeneratedExtensionBase<scg::IList<{1}>> {2};"
,
ClassAccessLevel
,
type
,
name
);
}
else
{
if
(!
Descriptor
.
IsCLSCompliant
)
{
writer
.
WriteLine
(
"[global::System.CLSCompliant(false)]"
);
}
writer
.
WriteLine
(
"{0} static pb::GeneratedExtensionBase<{1}> {2};"
,
ClassAccessLevel
,
type
,
name
);
}
}
...
...
src/ProtoGen/FieldGeneratorBase.cs
View file @
d6dd0a45
...
...
@@ -97,6 +97,12 @@ namespace Google.ProtocolBuffers.ProtoGen {
}
}
protected
void
AddClsComplianceCheck
(
TextGenerator
writer
)
{
if
(!
Descriptor
.
IsCLSCompliant
)
{
writer
.
WriteLine
(
"[global::System.CLSCompliant(false)]"
);
}
}
/// <summary>
/// For encodings with fixed sizes, returns that size in bytes. Otherwise
/// returns -1. TODO(jonskeet): Make this less ugly.
...
...
src/ProtoGen/PrimitiveFieldGenerator.cs
View file @
d6dd0a45
...
...
@@ -15,6 +15,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"public bool Has{0} {{"
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return has{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} {1} {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return {0}_; }}"
,
Name
);
writer
.
WriteLine
(
"}"
);
...
...
@@ -24,10 +25,12 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"public bool Has{0} {{"
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.Has{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} {1} {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.{0}; }}"
,
PropertyName
);
writer
.
WriteLine
(
" set {{ Set{0}(value); }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public Builder Set{0}({1} value) {{"
,
PropertyName
,
TypeName
);
AddNullCheck
(
writer
);
writer
.
WriteLine
(
" result.has{0} = true;"
,
PropertyName
);
...
...
src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
View file @
d6dd0a45
...
...
@@ -16,6 +16,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
"private int {0}MemoizedSerializedSize;"
,
Name
);
}
writer
.
WriteLine
(
"private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();"
,
TypeName
,
Name
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public scg::IList<{0}> {1}List {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return pbc::Lists.AsReadOnly({0}_); }}"
,
Name
);
writer
.
WriteLine
(
"}"
);
...
...
@@ -25,6 +26,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
writer
.
WriteLine
(
" get {{ return {0}_.Count; }}"
,
Name
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} Get{1}(int index) {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" return {0}_[index];"
,
Name
);
writer
.
WriteLine
(
"}"
);
...
...
@@ -32,25 +34,30 @@ namespace Google.ProtocolBuffers.ProtoGen {
public
void
GenerateBuilderMembers
(
TextGenerator
writer
)
{
// Note: We can return the original list here, because we make it unmodifiable when we build
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public scg::IList<{0}> {1}List {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.{0}_; }}"
,
Name
);
writer
.
WriteLine
(
"}"
);
writer
.
WriteLine
(
"public int {0}Count {{"
,
PropertyName
);
writer
.
WriteLine
(
" get {{ return result.{0}Count; }}"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public {0} Get{1}(int index) {{"
,
TypeName
,
PropertyName
);
writer
.
WriteLine
(
" return result.Get{0}(index);"
,
PropertyName
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public Builder Set{0}(int index, {1} value) {{"
,
PropertyName
,
TypeName
);
AddNullCheck
(
writer
);
writer
.
WriteLine
(
" result.{0}_[index] = value;"
,
Name
);
writer
.
WriteLine
(
" return this;"
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public Builder Add{0}({1} value) {{"
,
PropertyName
,
TypeName
);
AddNullCheck
(
writer
);
writer
.
WriteLine
(
" result.{0}_.Add(value);"
,
Name
,
TypeName
);
writer
.
WriteLine
(
" return this;"
);
writer
.
WriteLine
(
"}"
);
AddClsComplianceCheck
(
writer
);
writer
.
WriteLine
(
"public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{"
,
PropertyName
,
TypeName
);
writer
.
WriteLine
(
" base.AddRange(values, result.{0}_);"
,
Name
);
writer
.
WriteLine
(
" return this;"
);
...
...
src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs
View file @
d6dd0a45
using
System
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
...
...
@@ -34,3 +35,6 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// We don't really need CLSCompliance, but if the assembly builds with no warnings,
// that means the generator is okay.
[assembly: CLSCompliant(true)]
src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
View file @
d6dd0a45
...
...
@@ -47,10 +47,12 @@ namespace Google.ProtocolBuffers.TestProtos {
#
endregion
#
region
Extensions
public
const
int
FileOpt1FieldNumber
=
7736974
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
ulong
>
FileOpt1
;
public
const
int
MessageOpt1FieldNumber
=
7739036
;
public
static
pb
::
GeneratedExtensionBase
<
int
>
MessageOpt1
;
public
const
int
FieldOpt1FieldNumber
=
7740936
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
ulong
>
FieldOpt1
;
public
const
int
FieldOpt2FieldNumber
=
7753913
;
public
static
pb
::
GeneratedExtensionBase
<
int
>
FieldOpt2
;
...
...
@@ -67,16 +69,20 @@ namespace Google.ProtocolBuffers.TestProtos {
public
const
int
Int64OptFieldNumber
=
7705542
;
public
static
pb
::
GeneratedExtensionBase
<
long
>
Int64Opt
;
public
const
int
Uint32OptFieldNumber
=
7704880
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
uint
>
Uint32Opt
;
public
const
int
Uint64OptFieldNumber
=
7702367
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
ulong
>
Uint64Opt
;
public
const
int
Sint32OptFieldNumber
=
7701568
;
public
static
pb
::
GeneratedExtensionBase
<
int
>
Sint32Opt
;
public
const
int
Sint64OptFieldNumber
=
7700863
;
public
static
pb
::
GeneratedExtensionBase
<
long
>
Sint64Opt
;
public
const
int
Fixed32OptFieldNumber
=
7700307
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
uint
>
Fixed32Opt
;
public
const
int
Fixed64OptFieldNumber
=
7700194
;
[
global
::
System
.
CLSCompliant
(
false
)]
public
static
pb
::
GeneratedExtensionBase
<
ulong
>
Fixed64Opt
;
public
const
int
Sfixed32OptFieldNumber
=
7698645
;
public
static
pb
::
GeneratedExtensionBase
<
int
>
Sfixed32Opt
;
...
...
src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
View file @
d6dd0a45
This diff is collapsed.
Click to expand it.
src/ProtocolBuffers/CodedInputStream.cs
View file @
d6dd0a45
...
...
@@ -126,6 +126,7 @@ namespace Google.ProtocolBuffers {
/// </summary>
/// <exception cref="InvalidProtocolBufferException">The last
/// tag read was not the one specified</exception>
[
CLSCompliant
(
false
)]
public
void
CheckLastTagWas
(
uint
value
)
{
if
(
lastTag
!=
value
)
{
throw
InvalidProtocolBufferException
.
InvalidEndTag
();
...
...
@@ -140,6 +141,7 @@ namespace Google.ProtocolBuffers {
/// since a protocol message may legally end wherever a tag occurs, and
/// zero is not a valid tag number.
/// </summary>
[
CLSCompliant
(
false
)]
public
uint
ReadTag
()
{
if
(
IsAtEnd
)
{
lastTag
=
0
;
...
...
@@ -175,6 +177,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a uint64 field from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
ulong
ReadUInt64
()
{
return
ReadRawVarint64
();
}
...
...
@@ -196,6 +199,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a fixed64 field from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
ulong
ReadFixed64
()
{
return
ReadRawLittleEndian64
();
}
...
...
@@ -203,6 +207,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a fixed32 field from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
uint
ReadFixed32
()
{
return
ReadRawLittleEndian32
();
}
...
...
@@ -298,6 +303,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Reads a uint32 field value from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
uint
ReadUInt32
()
{
return
ReadRawVarint32
();
}
...
...
@@ -418,6 +424,7 @@ namespace Google.ProtocolBuffers {
/// That means we can check the size just once, then just read directly from the buffer
/// without constant rechecking of the buffer length.
/// </summary>
[
CLSCompliant
(
false
)]
public
uint
ReadRawVarint32
()
{
if
(
bufferPos
+
5
>
bufferSize
)
{
return
SlowReadRawVarint32
();
...
...
@@ -495,6 +502,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a raw varint from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
ulong
ReadRawVarint64
()
{
int
shift
=
0
;
ulong
result
=
0
;
...
...
@@ -512,6 +520,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a 32-bit little-endian integer from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
uint
ReadRawLittleEndian32
()
{
uint
b1
=
ReadRawByte
();
uint
b2
=
ReadRawByte
();
...
...
@@ -523,6 +532,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Read a 64-bit little-endian integer from the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
ulong
ReadRawLittleEndian64
()
{
ulong
b1
=
ReadRawByte
();
ulong
b2
=
ReadRawByte
();
...
...
@@ -546,6 +556,7 @@ namespace Google.ProtocolBuffers {
/// sign-extended to 64 bits to be varint encoded, thus always taking
/// 10 bytes on the wire.)
/// </remarks>
[
CLSCompliant
(
false
)]
public
static
int
DecodeZigZag32
(
uint
n
)
{
return
(
int
)(
n
>>
1
)
^
-(
int
)(
n
&
1
);
}
...
...
@@ -559,6 +570,7 @@ namespace Google.ProtocolBuffers {
/// sign-extended to 64 bits to be varint encoded, thus always taking
/// 10 bytes on the wire.)
/// </remarks>
[
CLSCompliant
(
false
)]
public
static
long
DecodeZigZag64
(
ulong
n
)
{
return
(
long
)(
n
>>
1
)
^
-(
long
)(
n
&
1
);
}
...
...
@@ -849,6 +861,7 @@ namespace Google.ProtocolBuffers {
/// </summary>
/// <returns>false if the tag is an end-group tag, in which case
/// nothing is skipped. Otherwise, returns true.</returns>
[
CLSCompliant
(
false
)]
public
bool
SkipField
(
uint
tag
)
{
switch
(
WireFormat
.
GetTagWireType
(
tag
))
{
case
WireFormat
.
WireType
.
Varint
:
...
...
src/ProtocolBuffers/CodedOutputStream.cs
View file @
d6dd0a45
...
...
@@ -133,6 +133,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a uint64 field value, including tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteUInt64
(
int
fieldNumber
,
ulong
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint64
(
value
);
...
...
@@ -162,6 +163,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a fixed64 field value, including tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteFixed64
(
int
fieldNumber
,
ulong
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteRawLittleEndian64
(
value
);
...
...
@@ -170,6 +172,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a fixed32 field value, including tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteFixed32
(
int
fieldNumber
,
uint
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteRawLittleEndian32
(
value
);
...
...
@@ -230,6 +233,7 @@ namespace Google.ProtocolBuffers {
WriteRawBytes
(
bytes
);
}
[
CLSCompliant
(
false
)]
public
void
WriteUInt32
(
int
fieldNumber
,
uint
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint32
(
value
);
...
...
@@ -344,6 +348,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a uint64 field value, without a tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteUInt64NoTag
(
ulong
value
)
{
WriteRawVarint64
(
value
);
}
...
...
@@ -370,6 +375,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a fixed64 field value, without a tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteFixed64NoTag
(
ulong
value
)
{
WriteRawLittleEndian64
(
value
);
}
...
...
@@ -377,6 +383,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Writes a fixed32 field value, without a tag, to the stream.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteFixed32NoTag
(
uint
value
)
{
WriteRawLittleEndian32
(
value
);
}
...
...
@@ -424,6 +431,7 @@ namespace Google.ProtocolBuffers {
WriteRawBytes
(
bytes
);
}
[
CLSCompliant
(
false
)]
public
void
WriteUInt32NoTag
(
uint
value
)
{
WriteRawVarint32
(
value
);
}
...
...
@@ -454,6 +462,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Encodes and writes a tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteTag
(
int
fieldNumber
,
WireFormat
.
WireType
type
)
{
WriteRawVarint32
(
WireFormat
.
MakeTag
(
fieldNumber
,
type
));
}
...
...
@@ -475,6 +484,7 @@ namespace Google.ProtocolBuffers {
/// there's enough buffer space left to whizz through without checking
/// for each byte; otherwise, we resort to calling WriteRawByte each time.
/// </summary>
[
CLSCompliant
(
false
)]
public
void
WriteRawVarint32
(
uint
value
)
{
if
(
position
+
5
>
limit
)
{
SlowWriteRawVarint32
(
value
);
...
...
@@ -492,6 +502,7 @@ namespace Google.ProtocolBuffers {
}
}
[
CLSCompliant
(
false
)]
public
void
WriteRawVarint64
(
ulong
value
)
{
while
(
true
)
{
if
((
value
&
~
0x7FU
L
)
==
0
)
{
...
...
@@ -504,6 +515,7 @@ namespace Google.ProtocolBuffers {
}
}
[
CLSCompliant
(
false
)]
public
void
WriteRawLittleEndian32
(
uint
value
)
{
WriteRawByte
((
byte
)
value
);
WriteRawByte
((
byte
)(
value
>>
8
));
...
...
@@ -511,6 +523,7 @@ namespace Google.ProtocolBuffers {
WriteRawByte
((
byte
)(
value
>>
24
));
}
[
CLSCompliant
(
false
)]
public
void
WriteRawLittleEndian64
(
ulong
value
)
{
WriteRawByte
((
byte
)
value
);
WriteRawByte
((
byte
)(
value
>>
8
));
...
...
@@ -530,6 +543,7 @@ namespace Google.ProtocolBuffers {
buffer
[
position
++]
=
value
;
}
[
CLSCompliant
(
false
)]
public
void
WriteRawByte
(
uint
value
)
{
WriteRawByte
((
byte
)
value
);
}
...
...
@@ -599,6 +613,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeUInt64Size
(
int
fieldNumber
,
ulong
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint64Size
(
value
);
}
...
...
@@ -628,6 +643,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeFixed64Size
(
int
fieldNumber
,
ulong
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian64Size
;
}
...
...
@@ -636,6 +652,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeFixed32Size
(
int
fieldNumber
,
uint
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian32Size
;
}
...
...
@@ -699,6 +716,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeUInt32Size
(
int
fieldNumber
,
uint
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
(
value
);
}
...
...
@@ -764,6 +782,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeUInt64SizeNoTag
(
ulong
value
)
{
return
ComputeRawVarint64Size
(
value
);
}
...
...
@@ -793,6 +812,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeFixed64SizeNoTag
(
ulong
value
)
{
return
LittleEndian64Size
;
}
...
...
@@ -801,6 +821,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeFixed32SizeNoTag
(
uint
value
)
{
return
LittleEndian32Size
;
}
...
...
@@ -861,6 +882,7 @@ namespace Google.ProtocolBuffers {
/// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeUInt32SizeNoTag
(
uint
value
)
{
return
ComputeRawVarint32Size
(
value
);
}
...
...
@@ -936,6 +958,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Compute the number of bytes that would be needed to encode a varint.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeRawVarint32Size
(
uint
value
)
{
if
((
value
&
(
0xffffffff
<<
7
))
==
0
)
return
1
;
if
((
value
&
(
0xffffffff
<<
14
))
==
0
)
return
2
;
...
...
@@ -947,6 +970,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Compute the number of bytes that would be needed to encode a varint.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
ComputeRawVarint64Size
(
ulong
value
)
{
if
((
value
&
(
0xffffffffffffffffL
<<
7
))
==
0
)
return
1
;
if
((
value
&
(
0xffffffffffffffffL
<<
14
))
==
0
)
return
2
;
...
...
@@ -1035,6 +1059,7 @@ namespace Google.ProtocolBuffers {
/// sign-extended to 64 bits to be varint encoded, thus always taking
/// 10 bytes on the wire.)
/// </remarks>
[
CLSCompliant
(
false
)]
public
static
uint
EncodeZigZag32
(
int
n
)
{
// Note: the right-shift must be arithmetic
return
(
uint
)((
n
<<
1
)
^
(
n
>>
31
));
...
...
@@ -1049,6 +1074,7 @@ namespace Google.ProtocolBuffers {
/// sign-extended to 64 bits to be varint encoded, thus always taking
/// 10 bytes on the wire.)
/// </remarks>
[
CLSCompliant
(
false
)]
public
static
ulong
EncodeZigZag64
(
long
n
)
{
return
(
ulong
)((
n
<<
1
)
^
(
n
>>
63
));
}
...
...
src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
View file @
d6dd0a45
...
...
@@ -6427,6 +6427,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public
bool
HasPositiveIntValue
{
get
{
return
hasPositiveIntValue
;
}
}
[
global
::
System
.
CLSCompliant
(
false
)]
public
ulong
PositiveIntValue
{
get
{
return
positiveIntValue_
;
}
}
...
...
@@ -6751,10 +6752,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public
bool
HasPositiveIntValue
{
get
{
return
result
.
HasPositiveIntValue
;
}
}
[
global
::
System
.
CLSCompliant
(
false
)]
public
ulong
PositiveIntValue
{
get
{
return
result
.
PositiveIntValue
;
}
set
{
SetPositiveIntValue
(
value
);
}
}
[
global
::
System
.
CLSCompliant
(
false
)]
public
Builder
SetPositiveIntValue
(
ulong
value
)
{
result
.
hasPositiveIntValue
=
true
;
result
.
positiveIntValue_
=
value
;
...
...
src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
View file @
d6dd0a45
...
...
@@ -278,6 +278,10 @@ namespace Google.ProtocolBuffers.Descriptors {
get
{
return
fieldType
;
}
}
public
bool
IsCLSCompliant
{
get
{
return
mappedType
!=
MappedType
.
UInt32
&&
mappedType
!=
MappedType
.
UInt64
;
}
}
public
int
FieldNumber
{
get
{
return
Proto
.
Number
;
}
}
...
...
src/ProtocolBuffers/ExtendableBuilder.cs
View file @
d6dd0a45
...
...
@@ -29,6 +29,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using
System
;
using
System.Collections.Generic
;
using
Google.ProtocolBuffers.Descriptors
;
...
...
@@ -111,6 +112,7 @@ namespace Google.ProtocolBuffers {
/// Called by subclasses to parse an unknown field or an extension.
/// </summary>
/// <returns>true unless the tag is an end-group tag</returns>
[
CLSCompliant
(
false
)]
protected
override
bool
ParseUnknownField
(
CodedInputStream
input
,
UnknownFieldSet
.
Builder
unknownFields
,
ExtensionRegistry
extensionRegistry
,
uint
tag
)
{
return
unknownFields
.
MergeFieldFrom
(
input
,
extensionRegistry
,
this
,
tag
);
...
...
src/ProtocolBuffers/GeneratedBuilder.cs
View file @
d6dd0a45
...
...
@@ -99,6 +99,7 @@ namespace Google.ProtocolBuffers {
/// Called by derived classes to parse an unknown field.
/// </summary>
/// <returns>true unless the tag is an end-group tag</returns>
[
CLSCompliant
(
false
)]
protected
virtual
bool
ParseUnknownField
(
CodedInputStream
input
,
UnknownFieldSet
.
Builder
unknownFields
,
ExtensionRegistry
extensionRegistry
,
uint
tag
)
{
return
unknownFields
.
MergeFieldFrom
(
tag
,
input
);
...
...
src/ProtocolBuffers/Properties/AssemblyInfo.cs
View file @
d6dd0a45
...
...
@@ -29,6 +29,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using
System
;
using
System.Reflection
;
using
System.Runtime.InteropServices
;
using
System.Runtime.CompilerServices
;
...
...
@@ -77,3 +78,4 @@ using System.Runtime.CompilerServices;
"5e09a6084558f989ccde66094f07822808d3a9b922b0e85b912070032e90bb35360be7efb7982b"
+
"702d7a5c6ed1e21d8ca587b4f4c9d2b81210d3641cc75f506cdfc628ac5453ff0a6886986c981d"
+
"12245bc7"
)]
[assembly: CLSCompliant(true)]
\ No newline at end of file
src/ProtocolBuffers/UnknownField.cs
View file @
d6dd0a45
...
...
@@ -29,6 +29,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
Google.ProtocolBuffers.Collections
;
...
...
@@ -292,6 +293,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Adds a varint value.
/// </summary>
[
CLSCompliant
(
false
)]
public
Builder
AddVarint
(
ulong
value
)
{
varintList
=
Add
(
varintList
,
value
);
return
this
;
...
...
@@ -300,6 +302,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Adds a fixed32 value.
/// </summary>
[
CLSCompliant
(
false
)]
public
Builder
AddFixed32
(
uint
value
)
{
fixed32List
=
Add
(
fixed32List
,
value
);
return
this
;
...
...
@@ -308,6 +311,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Adds a fixed64 value.
/// </summary>
[
CLSCompliant
(
false
)]
public
Builder
AddFixed64
(
ulong
value
)
{
fixed64List
=
Add
(
fixed64List
,
value
);
return
this
;
...
...
src/ProtocolBuffers/UnknownFieldSet.cs
View file @
d6dd0a45
...
...
@@ -339,6 +339,7 @@ namespace Google.ProtocolBuffers {
/// <param name="tag">The field's tag number, which was already parsed.</param>
/// <param name="input">The coded input stream containing the field</param>
/// <returns>false if the tag is an "end group" tag, true otherwise</returns>
[
CLSCompliant
(
false
)]
public
bool
MergeFieldFrom
(
uint
tag
,
CodedInputStream
input
)
{
int
number
=
WireFormat
.
GetTagFieldNumber
(
tag
);
switch
(
WireFormat
.
GetTagWireType
(
tag
))
{
...
...
@@ -408,6 +409,7 @@ namespace Google.ProtocolBuffers {
/// value. This is used in particular when an unknown enum value is
/// encountered.
/// </summary>
[
CLSCompliant
(
false
)]
public
Builder
MergeVarintField
(
int
number
,
ulong
value
)
{
if
(
number
==
0
)
{
throw
new
ArgumentOutOfRangeException
(
"number"
,
"Zero is not a valid field number."
);
...
...
src/ProtocolBuffers/WireFormat.cs
View file @
d6dd0a45
...
...
@@ -58,7 +58,7 @@ namespace Google.ProtocolBuffers {
internal
const
int
BoolSize
=
1
;
#endregion
[
CLSCompliant
(
false
)]
public
enum
WireType
:
uint
{
Varint
=
0
,
Fixed64
=
1
,
...
...
@@ -87,10 +87,12 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Given a tag value, determines the wire type (lower 3 bits).
/// </summary>
[
CLSCompliant
(
false
)]
public
static
WireType
GetTagWireType
(
uint
tag
)
{
return
(
WireType
)
(
tag
&
TagTypeMask
);
}
[
CLSCompliant
(
false
)]
public
static
bool
IsEndGroupTag
(
uint
tag
)
{
return
(
WireType
)(
tag
&
TagTypeMask
)
==
WireType
.
EndGroup
;
}
...
...
@@ -98,6 +100,7 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Given a tag value, determines the field number (the upper 29 bits).
/// </summary>
[
CLSCompliant
(
false
)]
public
static
int
GetTagFieldNumber
(
uint
tag
)
{
return
(
int
)
tag
>>
TagTypeBits
;
}
...
...
@@ -106,10 +109,12 @@ namespace Google.ProtocolBuffers {
/// Makes a tag value given a field number and wire type.
/// TODO(jonskeet): Should we just have a Tag structure?
/// </summary>
[
CLSCompliant
(
false
)]
public
static
uint
MakeTag
(
int
fieldNumber
,
WireType
wireType
)
{
return
(
uint
)
(
fieldNumber
<<
TagTypeBits
)
|
(
uint
)
wireType
;
}
[
CLSCompliant
(
false
)]
public
static
uint
MakeTag
(
FieldDescriptor
field
)
{
return
MakeTag
(
field
.
FieldNumber
,
GetWireType
(
field
));
}
...
...
@@ -126,6 +131,7 @@ namespace Google.ProtocolBuffers {
/// Converts a field type to its wire type. Done with a switch for the sake
/// of speed - this is significantly faster than a dictionary lookup.
/// </summary>
[
CLSCompliant
(
false
)]
public
static
WireType
GetWireType
(
FieldType
fieldType
)
{
switch
(
fieldType
)
{
case
FieldType
.
Double
:
...
...
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