diff options
author | Jon Skeet <skeet@pobox.com> | 2009-06-05 22:00:05 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2009-06-05 22:00:05 +0100 |
commit | d6dd0a45608ffc34d53a60cc3db33cb38e6c2a18 (patch) | |
tree | d3aa02f1cbea4437b404bc7aa77cbc02f7e398dd /src/ProtocolBuffers | |
parent | 0864d30b977e0ae90a111004f597d777ce3082ed (diff) | |
download | protobuf-d6dd0a45608ffc34d53a60cc3db33cb38e6c2a18.tar.gz protobuf-d6dd0a45608ffc34d53a60cc3db33cb38e6c2a18.tar.bz2 protobuf-d6dd0a45608ffc34d53a60cc3db33cb38e6c2a18.zip |
Add CLSCompliance.
Diffstat (limited to 'src/ProtocolBuffers')
-rw-r--r-- | src/ProtocolBuffers/CodedInputStream.cs | 13 | ||||
-rw-r--r-- | src/ProtocolBuffers/CodedOutputStream.cs | 26 | ||||
-rw-r--r-- | src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs | 3 | ||||
-rw-r--r-- | src/ProtocolBuffers/Descriptors/FieldDescriptor.cs | 4 | ||||
-rw-r--r-- | src/ProtocolBuffers/ExtendableBuilder.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/GeneratedBuilder.cs | 1 | ||||
-rw-r--r-- | src/ProtocolBuffers/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/UnknownField.cs | 4 | ||||
-rw-r--r-- | src/ProtocolBuffers/UnknownFieldSet.cs | 2 | ||||
-rw-r--r-- | src/ProtocolBuffers/WireFormat.cs | 8 |
10 files changed, 64 insertions, 1 deletions
diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index 04308554..132773c9 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/src/ProtocolBuffers/CodedInputStream.cs @@ -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: diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs index 7cc5ff46..e5f890f9 100644 --- a/src/ProtocolBuffers/CodedOutputStream.cs +++ b/src/ProtocolBuffers/CodedOutputStream.cs @@ -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 & ~0x7FUL) == 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)); } diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index fef56372..03c4615c 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -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; diff --git a/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index cd1477ac..7d99ed21 100644 --- a/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -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; } } diff --git a/src/ProtocolBuffers/ExtendableBuilder.cs b/src/ProtocolBuffers/ExtendableBuilder.cs index b88f2994..db8e0939 100644 --- a/src/ProtocolBuffers/ExtendableBuilder.cs +++ b/src/ProtocolBuffers/ExtendableBuilder.cs @@ -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); diff --git a/src/ProtocolBuffers/GeneratedBuilder.cs b/src/ProtocolBuffers/GeneratedBuilder.cs index cdef93f6..638279e7 100644 --- a/src/ProtocolBuffers/GeneratedBuilder.cs +++ b/src/ProtocolBuffers/GeneratedBuilder.cs @@ -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); diff --git a/src/ProtocolBuffers/Properties/AssemblyInfo.cs b/src/ProtocolBuffers/Properties/AssemblyInfo.cs index 21bf418e..8d587d18 100644 --- a/src/ProtocolBuffers/Properties/AssemblyInfo.cs +++ b/src/ProtocolBuffers/Properties/AssemblyInfo.cs @@ -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 diff --git a/src/ProtocolBuffers/UnknownField.cs b/src/ProtocolBuffers/UnknownField.cs index 1873e302..62b96feb 100644 --- a/src/ProtocolBuffers/UnknownField.cs +++ b/src/ProtocolBuffers/UnknownField.cs @@ -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; diff --git a/src/ProtocolBuffers/UnknownFieldSet.cs b/src/ProtocolBuffers/UnknownFieldSet.cs index f8cbce4c..9de09709 100644 --- a/src/ProtocolBuffers/UnknownFieldSet.cs +++ b/src/ProtocolBuffers/UnknownFieldSet.cs @@ -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."); diff --git a/src/ProtocolBuffers/WireFormat.cs b/src/ProtocolBuffers/WireFormat.cs index 8f723d54..2b850533 100644 --- a/src/ProtocolBuffers/WireFormat.cs +++ b/src/ProtocolBuffers/WireFormat.cs @@ -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: |