Skip to content

Commit 6716432

Browse files
csharptestrogerk
authored and
rogerk
committed
Last (hopefully) changes to pre-processing directives
1 parent 0f56b84 commit 6716432

10 files changed

+34
-55
lines changed

lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

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

src/ProtocolBuffers.Test/SerializableAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if SILVERLIGHT
1+
#if NOSERIALIZABLE && !COMPACT_FRAMEWORK
22

33
namespace System
44
{

src/ProtocolBuffers/CodedInputStream.cs

+1-16
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,7 @@ public bool ReadTag(out uint fieldTag, out string fieldName)
231231
/// </summary>
232232
public bool ReadDouble(ref double value)
233233
{
234-
#if SILVERLIGHT || COMPACT_FRAMEWORK
235-
if (BitConverter.IsLittleEndian && 8 <= bufferSize - bufferPos)
236-
{
237-
value = BitConverter.ToDouble(buffer, bufferPos);
238-
bufferPos += 8;
239-
}
240-
else
241-
{
242-
byte[] rawBytes = ReadRawBytes(8);
243-
if (!BitConverter.IsLittleEndian)
244-
ByteArray.Reverse(rawBytes);
245-
value = BitConverter.ToDouble(rawBytes, 0);
246-
}
247-
#else
248-
value = BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64());
249-
#endif
234+
value = FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64());
250235
return true;
251236
}
252237

src/ProtocolBuffers/CodedOutputStream.cs

+1-21
Original file line numberDiff line numberDiff line change
@@ -496,27 +496,7 @@ public void WriteFieldNoTag(FieldType fieldType, object value)
496496
/// </summary>
497497
public void WriteDoubleNoTag(double value)
498498
{
499-
#if SILVERLIGHT || COMPACT_FRAMEWORK
500-
byte[] rawBytes = BitConverter.GetBytes(value);
501-
if (!BitConverter.IsLittleEndian)
502-
ByteArray.Reverse(rawBytes);
503-
504-
if (limit - position >= 8)
505-
{
506-
buffer[position++] = rawBytes[0];
507-
buffer[position++] = rawBytes[1];
508-
buffer[position++] = rawBytes[2];
509-
buffer[position++] = rawBytes[3];
510-
buffer[position++] = rawBytes[4];
511-
buffer[position++] = rawBytes[5];
512-
buffer[position++] = rawBytes[6];
513-
buffer[position++] = rawBytes[7];
514-
}
515-
else
516-
WriteRawBytes(rawBytes, 0, 8);
517-
#else
518-
WriteRawLittleEndian64((ulong) BitConverter.DoubleToInt64Bits(value));
519-
#endif
499+
WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value));
520500
}
521501

522502
/// <summary>

src/ProtocolBuffers/CustomSerialization.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#endregion
3636
/*
37-
* This entire source file is not supported on the Silverlight platform
37+
* This entire source file is not supported on some platform
3838
*/
3939
#if !NOSERIALIZABLE
4040

src/ProtocolBuffers/FrameworkPortability.cs

+22
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ internal static CultureInfo InvariantCulture
6363
get { return CultureInfo.InvariantCulture; }
6464
}
6565

66+
internal static double Int64ToDouble(long value)
67+
{
68+
#if CLIENTPROFILE
69+
return BitConverter.Int64BitsToDouble(value);
70+
#else
71+
double[] arresult = new double[1];
72+
Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
73+
return arresult[0];
74+
#endif
75+
}
76+
77+
internal static long DoubleToInt64(double value)
78+
{
79+
#if CLIENTPROFILE
80+
return BitConverter.DoubleToInt64Bits(value);
81+
#else
82+
long[] arresult = new long[1];
83+
Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
84+
return arresult[0];
85+
#endif
86+
}
87+
6688
internal static bool TryParseInt32(string text, out int number)
6789
{
6890
return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number);

src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
7070
<Link>Properties\AssemblyInfo.cs</Link>
7171
</Compile>
72+
<Compile Include="..\ProtocolBuffers.Test\SerializableAttribute.cs">
73+
<Link>SerializableAttribute.cs</Link>
74+
</Compile>
7275
<Compile Include="..\ProtocolBuffers.Test\TestRpcForMimeTypes.cs">
7376
<Link>TestRpcForMimeTypes.cs</Link>
7477
</Compile>
@@ -80,7 +83,6 @@
8083
<Compile Include="ExtendableBuilderLiteTest.cs" />
8184
<Compile Include="ExtendableMessageLiteTest.cs" />
8285
<Compile Include="LiteTest.cs" />
83-
<Compile Include="SerializableAttribute.cs" />
8486
<Compile Include="SerializableLiteTest.cs" />
8587
<Compile Include="TestLiteByApi.cs" />
8688
<Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />

src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@
6969
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
7070
<Link>Properties\AssemblyInfo.cs</Link>
7171
</Compile>
72+
<Compile Include="..\ProtocolBuffers.Test\SerializableAttribute.cs">
73+
<Link>SerializableAttribute.cs</Link>
74+
</Compile>
7275
<Compile Include="AbstractBuilderLiteTest.cs" />
7376
<Compile Include="AbstractMessageLiteTest.cs" />
7477
<Compile Include="ExtendableBuilderLiteTest.cs" />
7578
<Compile Include="ExtendableMessageLiteTest.cs" />
7679
<Compile Include="InteropLiteTest.cs" />
7780
<Compile Include="LiteTest.cs" />
7881
<Compile Include="MissingFieldAndExtensionTest.cs" />
79-
<Compile Include="SerializableAttribute.cs" />
8082
<Compile Include="TestLiteByApi.cs" />
8183
<Compile Include="TestProtos\UnitTestExtrasFullProtoFile.cs" />
8284
<Compile Include="TestProtos\UnitTestExtrasLiteProtoFile.cs" />

src/ProtocolBuffersLite.Test/SerializableAttribute.cs

-12
This file was deleted.

src/ProtocolBuffersLite.Test/SerializableLiteTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
#if !SILVERLIGHT && !COMPACT_FRAMEWORK
2+
#if !NOSERIALIZABLE
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Runtime.Serialization;

0 commit comments

Comments
 (0)