Commit d6dd0a45 authored by Jon Skeet's avatar Jon Skeet

Add CLSCompliance.

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