Last (hopefully) changes to pre-processing directives

pull/288/head
csharptest 12 years ago committed by rogerk
parent 0f56b84298
commit 6716432ca6
  1. 2
      lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs
  2. 2
      src/ProtocolBuffers.Test/SerializableAttribute.cs
  3. 17
      src/ProtocolBuffers/CodedInputStream.cs
  4. 22
      src/ProtocolBuffers/CodedOutputStream.cs
  5. 2
      src/ProtocolBuffers/CustomSerialization.cs
  6. 22
      src/ProtocolBuffers/FrameworkPortability.cs
  7. 4
      src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
  8. 4
      src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
  9. 12
      src/ProtocolBuffersLite.Test/SerializableAttribute.cs
  10. 2
      src/ProtocolBuffersLite.Test/SerializableLiteTest.cs

@ -1,6 +1,6 @@
 
using System; using System;
#if !SILVERLIGHT && !COMPACT_FRAMEWORK #if CLIENTPROFILE
namespace Microsoft.VisualStudio.TestTools.UnitTesting namespace Microsoft.VisualStudio.TestTools.UnitTesting
{ {
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]

@ -1,4 +1,4 @@
#if SILVERLIGHT #if NOSERIALIZABLE && !COMPACT_FRAMEWORK
namespace System namespace System
{ {

@ -231,22 +231,7 @@ namespace Google.ProtocolBuffers
/// </summary> /// </summary>
public bool ReadDouble(ref double value) public bool ReadDouble(ref double value)
{ {
#if SILVERLIGHT || COMPACT_FRAMEWORK value = FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64());
if (BitConverter.IsLittleEndian && 8 <= bufferSize - bufferPos)
{
value = BitConverter.ToDouble(buffer, bufferPos);
bufferPos += 8;
}
else
{
byte[] rawBytes = ReadRawBytes(8);
if (!BitConverter.IsLittleEndian)
ByteArray.Reverse(rawBytes);
value = BitConverter.ToDouble(rawBytes, 0);
}
#else
value = BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64());
#endif
return true; return true;
} }

@ -496,27 +496,7 @@ namespace Google.ProtocolBuffers
/// </summary> /// </summary>
public void WriteDoubleNoTag(double value) public void WriteDoubleNoTag(double value)
{ {
#if SILVERLIGHT || COMPACT_FRAMEWORK WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value));
byte[] rawBytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
ByteArray.Reverse(rawBytes);
if (limit - position >= 8)
{
buffer[position++] = rawBytes[0];
buffer[position++] = rawBytes[1];
buffer[position++] = rawBytes[2];
buffer[position++] = rawBytes[3];
buffer[position++] = rawBytes[4];
buffer[position++] = rawBytes[5];
buffer[position++] = rawBytes[6];
buffer[position++] = rawBytes[7];
}
else
WriteRawBytes(rawBytes, 0, 8);
#else
WriteRawLittleEndian64((ulong) BitConverter.DoubleToInt64Bits(value));
#endif
} }
/// <summary> /// <summary>

@ -34,7 +34,7 @@
#endregion #endregion
/* /*
* This entire source file is not supported on the Silverlight platform * This entire source file is not supported on some platform
*/ */
#if !NOSERIALIZABLE #if !NOSERIALIZABLE

@ -63,6 +63,28 @@ namespace Google.ProtocolBuffers
get { return CultureInfo.InvariantCulture; } get { return CultureInfo.InvariantCulture; }
} }
internal static double Int64ToDouble(long value)
{
#if CLIENTPROFILE
return BitConverter.Int64BitsToDouble(value);
#else
double[] arresult = new double[1];
Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
return arresult[0];
#endif
}
internal static long DoubleToInt64(double value)
{
#if CLIENTPROFILE
return BitConverter.DoubleToInt64Bits(value);
#else
long[] arresult = new long[1];
Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
return arresult[0];
#endif
}
internal static bool TryParseInt32(string text, out int number) internal static bool TryParseInt32(string text, out int number)
{ {
return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number); return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number);

@ -69,6 +69,9 @@
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs"> <Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link> <Link>Properties\AssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\ProtocolBuffers.Test\SerializableAttribute.cs">
<Link>SerializableAttribute.cs</Link>
</Compile>
<Compile Include="..\ProtocolBuffers.Test\TestRpcForMimeTypes.cs"> <Compile Include="..\ProtocolBuffers.Test\TestRpcForMimeTypes.cs">
<Link>TestRpcForMimeTypes.cs</Link> <Link>TestRpcForMimeTypes.cs</Link>
</Compile> </Compile>
@ -80,7 +83,6 @@
<Compile Include="ExtendableBuilderLiteTest.cs" /> <Compile Include="ExtendableBuilderLiteTest.cs" />
<Compile Include="ExtendableMessageLiteTest.cs" /> <Compile Include="ExtendableMessageLiteTest.cs" />
<Compile Include="LiteTest.cs" /> <Compile Include="LiteTest.cs" />
<Compile Include="SerializableAttribute.cs" />
<Compile Include="SerializableLiteTest.cs" /> <Compile Include="SerializableLiteTest.cs" />
<Compile Include="TestLiteByApi.cs" /> <Compile Include="TestLiteByApi.cs" />
<Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" /> <Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />

@ -69,6 +69,9 @@
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs"> <Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link> <Link>Properties\AssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\ProtocolBuffers.Test\SerializableAttribute.cs">
<Link>SerializableAttribute.cs</Link>
</Compile>
<Compile Include="AbstractBuilderLiteTest.cs" /> <Compile Include="AbstractBuilderLiteTest.cs" />
<Compile Include="AbstractMessageLiteTest.cs" /> <Compile Include="AbstractMessageLiteTest.cs" />
<Compile Include="ExtendableBuilderLiteTest.cs" /> <Compile Include="ExtendableBuilderLiteTest.cs" />
@ -76,7 +79,6 @@
<Compile Include="InteropLiteTest.cs" /> <Compile Include="InteropLiteTest.cs" />
<Compile Include="LiteTest.cs" /> <Compile Include="LiteTest.cs" />
<Compile Include="MissingFieldAndExtensionTest.cs" /> <Compile Include="MissingFieldAndExtensionTest.cs" />
<Compile Include="SerializableAttribute.cs" />
<Compile Include="TestLiteByApi.cs" /> <Compile Include="TestLiteByApi.cs" />
<Compile Include="TestProtos\UnitTestExtrasFullProtoFile.cs" /> <Compile Include="TestProtos\UnitTestExtrasFullProtoFile.cs" />
<Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" /> <Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />

@ -1,12 +0,0 @@
#if SILVERLIGHT
namespace System
{
[AttributeUsage(AttributeTargets.Class)]
public class SerializableAttribute : Attribute
{
public SerializableAttribute () : base() { }
}
}
#endif

@ -1,5 +1,5 @@
using System; using System;
#if !SILVERLIGHT && !COMPACT_FRAMEWORK #if !NOSERIALIZABLE
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.Serialization; using System.Runtime.Serialization;

Loading…
Cancel
Save