aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2012-10-14 15:12:29 -0500
committerrogerk <devnull@localhost>2012-10-14 15:12:29 -0500
commit945bd1d516d94389a1f3d4b29e754fcd345ce955 (patch)
tree5d6e818790c44b54a6c1a68a649ed0c817b25ddc
parent5cda54bd8b7269cf8f48ff7af28acfd4783c5a45 (diff)
downloadprotobuf-945bd1d516d94389a1f3d4b29e754fcd345ce955.tar.gz
protobuf-945bd1d516d94389a1f3d4b29e754fcd345ce955.tar.bz2
protobuf-945bd1d516d94389a1f3d4b29e754fcd345ce955.zip
Working to reduce number of conditional complication directives, and migrate towards feature-based condtions rather than platform-based
-rw-r--r--src/ProtocolBuffers.Serialization/JsonFormatWriter.cs4
-rw-r--r--src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs10
-rw-r--r--src/ProtocolBuffers.Test/CodedOutputStreamTest.cs2
-rw-r--r--src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs6
-rw-r--r--src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs7
-rw-r--r--src/ProtocolBuffers.Test/Compatibility/TestResources.cs7
-rw-r--r--src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs7
-rw-r--r--src/ProtocolBuffers.Test/DescriptorsTest.cs6
-rw-r--r--src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj19
-rw-r--r--src/ProtocolBuffers.Test/Resources/golden_messagebin0 -> 487 bytes
-rw-r--r--src/ProtocolBuffers.Test/Resources/golden_packed_fields_messagebin0 -> 142 bytes
-rw-r--r--src/ProtocolBuffers.Test/Resources/text_format_unittest_data.txt116
-rw-r--r--src/ProtocolBuffers.Test/Resources/text_format_unittest_extensions_data.txt116
-rw-r--r--src/ProtocolBuffers.Test/SerializableTest.cs2
-rw-r--r--src/ProtocolBuffers.Test/TestResources.Designer.cs131
-rw-r--r--src/ProtocolBuffers.Test/TestResources.resx133
-rw-r--r--src/ProtocolBuffers.Test/TestUtil.cs51
-rw-r--r--src/ProtocolBuffers.Test/TextFormatTest.cs10
-rw-r--r--src/ProtocolBuffers/CustomSerialization.cs2
-rw-r--r--src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs3
-rw-r--r--src/ProtocolBuffers/FrameworkPortability.cs2
-rw-r--r--src/ProtocolBuffers/SortedList.cs4
-rw-r--r--src/ProtocolBuffers/ThrowHelper.cs4
23 files changed, 527 insertions, 115 deletions
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
index 4fe6ea7c..1c71dc95 100644
--- a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
@@ -100,11 +100,7 @@ namespace Google.ProtocolBuffers.Serialization
private class JsonStreamWriter : JsonFormatWriter
{
-#if SILVERLIGHT || COMPACT_FRAMEWORK
static readonly Encoding Encoding = new UTF8Encoding(false);
-#else
- private static readonly Encoding Encoding = Encoding.ASCII;
-#endif
private readonly byte[] _buffer;
private Stream _output;
private int _bufferPos;
diff --git a/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs b/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
index a2f683f7..14e72ba8 100644
--- a/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
+++ b/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
@@ -7,9 +7,6 @@ namespace Google.ProtocolBuffers.Serialization
/// <summary>
/// The exception raised when a recursion limit is reached while parsing input.
/// </summary>
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
- [Serializable]
-#endif
public sealed class RecursionLimitExceededException : FormatException
{
const string message = "Possible malicious message had too many levels of nesting.";
@@ -17,12 +14,5 @@ namespace Google.ProtocolBuffers.Serialization
internal RecursionLimitExceededException() : base(message)
{
}
-
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
- private RecursionLimitExceededException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
-#endif
}
}
diff --git a/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
index f6e7537c..172c14bd 100644
--- a/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
+++ b/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
@@ -196,7 +196,6 @@ namespace Google.ProtocolBuffers
0x9abcdef012345678UL);
}
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
[TestMethod]
public void WriteWholeMessage()
{
@@ -230,7 +229,6 @@ namespace Google.ProtocolBuffers
TestUtil.AssertEqualBytes(TestUtil.GetGoldenPackedFieldsMessage().ToByteArray(),
rawBytes);
}
-#endif
[TestMethod]
public void EncodeZigZag32()
diff --git a/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs b/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
index 8438d94f..9707f8e8 100644
--- a/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
+++ b/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
@@ -1,11 +1,5 @@
using System;
-#if SILVERLIGHT
-using TestClass = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
-using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
-using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
-#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#endif
namespace Google.ProtocolBuffers.Compatibility
{
diff --git a/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs b/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
index fddddf84..73037cce 100644
--- a/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
+++ b/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
@@ -3,14 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Google.ProtocolBuffers.Serialization;
-#if SILVERLIGHT
-using TestClass = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
-using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
-using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
-#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#endif
-
namespace Google.ProtocolBuffers.Compatibility
{
diff --git a/src/ProtocolBuffers.Test/Compatibility/TestResources.cs b/src/ProtocolBuffers.Test/Compatibility/TestResources.cs
index 2fc1322b..c3ce5883 100644
--- a/src/ProtocolBuffers.Test/Compatibility/TestResources.cs
+++ b/src/ProtocolBuffers.Test/Compatibility/TestResources.cs
@@ -2,14 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
-#if SILVERLIGHT
-using TestClass = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
-using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
-using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
-#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#endif
-
namespace Google.ProtocolBuffers.Compatibility
{
diff --git a/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs b/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
index 9113b589..70614744 100644
--- a/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
+++ b/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
@@ -2,14 +2,7 @@ using System.IO;
using System.Xml;
using Google.ProtocolBuffers.Serialization;
using Google.ProtocolBuffers.TestProtos;
-#if SILVERLIGHT
-using TestClass = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
-using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
-using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
-#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#endif
-
namespace Google.ProtocolBuffers.Compatibility
{
diff --git a/src/ProtocolBuffers.Test/DescriptorsTest.cs b/src/ProtocolBuffers.Test/DescriptorsTest.cs
index 5cf79e3b..ca10c621 100644
--- a/src/ProtocolBuffers.Test/DescriptorsTest.cs
+++ b/src/ProtocolBuffers.Test/DescriptorsTest.cs
@@ -229,7 +229,6 @@ namespace Google.ProtocolBuffers
Assert.IsFalse(repeatedField.IsRequired);
Assert.IsTrue(repeatedField.IsRepeated);
}
-#if !SILVERLIGHT
[TestMethod]
public void FieldDescriptorDefault()
{
@@ -240,13 +239,12 @@ namespace Google.ProtocolBuffers
Assert.AreEqual<object>(41, d.FindDescriptor<FieldDescriptor>("default_int32").DefaultValue);
d = TestExtremeDefaultValues.Descriptor;
- Assert.AreEqual<object>(
- ByteString.CopyFrom("\u0000\u0001\u0007\b\f\n\r\t\u000b\\\'\"\u00fe", Encoding.GetEncoding("iso-8859-1")),
+ Assert.AreEqual<object>(TestExtremeDefaultValues.DefaultInstance.EscapedBytes,
d.FindDescriptor<FieldDescriptor>("escaped_bytes").DefaultValue);
+
Assert.AreEqual<object>(uint.MaxValue, d.FindDescriptor<FieldDescriptor>("large_uint32").DefaultValue);
Assert.AreEqual<object>(ulong.MaxValue, d.FindDescriptor<FieldDescriptor>("large_uint64").DefaultValue);
}
-#endif
[TestMethod]
public void EnumDescriptor()
{
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
index 0d9f0abe..69b42306 100644
--- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
+++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
@@ -78,6 +78,11 @@
<Compile Include="Compatibility\XmlCompatibilityTests.cs" />
<Compile Include="SerializableAttribute.cs" />
<Compile Include="TestProtos\UnitTestExtrasProtoFile.cs" />
+ <Compile Include="TestResources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>TestResources.resx</DependentUpon>
+ </Compile>
<Compile Include="TestRpcForMimeTypes.cs" />
<Compile Include="TestReaderForUrlEncoded.cs" />
<Compile Include="CSharpOptionsTest.cs" />
@@ -155,6 +160,20 @@
<ItemGroup>
<EmbeddedResource Include="Compatibility\google_message1.dat" />
<EmbeddedResource Include="Compatibility\google_message2.dat" />
+ <EmbeddedResource Include="TestResources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>TestResources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\golden_message" />
+ <None Include="Resources\golden_packed_fields_message" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\text_format_unittest_data.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\text_format_unittest_extensions_data.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/src/ProtocolBuffers.Test/Resources/golden_message b/src/ProtocolBuffers.Test/Resources/golden_message
new file mode 100644
index 00000000..94898e49
--- /dev/null
+++ b/src/ProtocolBuffers.Test/Resources/golden_message
Binary files differ
diff --git a/src/ProtocolBuffers.Test/Resources/golden_packed_fields_message b/src/ProtocolBuffers.Test/Resources/golden_packed_fields_message
new file mode 100644
index 00000000..ee28d388
--- /dev/null
+++ b/src/ProtocolBuffers.Test/Resources/golden_packed_fields_message
Binary files differ
diff --git a/src/ProtocolBuffers.Test/Resources/text_format_unittest_data.txt b/src/ProtocolBuffers.Test/Resources/text_format_unittest_data.txt
new file mode 100644
index 00000000..d3e27b71
--- /dev/null
+++ b/src/ProtocolBuffers.Test/Resources/text_format_unittest_data.txt
@@ -0,0 +1,116 @@
+optional_int32: 101
+optional_int64: 102
+optional_uint32: 103
+optional_uint64: 104
+optional_sint32: 105
+optional_sint64: 106
+optional_fixed32: 107
+optional_fixed64: 108
+optional_sfixed32: 109
+optional_sfixed64: 110
+optional_float: 111
+optional_double: 112
+optional_bool: true
+optional_string: "115"
+optional_bytes: "116"
+OptionalGroup {
+ a: 117
+}
+optional_nested_message {
+ bb: 118
+}
+optional_foreign_message {
+ c: 119
+}
+optional_import_message {
+ d: 120
+}
+optional_nested_enum: BAZ
+optional_foreign_enum: FOREIGN_BAZ
+optional_import_enum: IMPORT_BAZ
+optional_string_piece: "124"
+optional_cord: "125"
+repeated_int32: 201
+repeated_int32: 301
+repeated_int64: 202
+repeated_int64: 302
+repeated_uint32: 203
+repeated_uint32: 303
+repeated_uint64: 204
+repeated_uint64: 304
+repeated_sint32: 205
+repeated_sint32: 305
+repeated_sint64: 206
+repeated_sint64: 306
+repeated_fixed32: 207
+repeated_fixed32: 307
+repeated_fixed64: 208
+repeated_fixed64: 308
+repeated_sfixed32: 209
+repeated_sfixed32: 309
+repeated_sfixed64: 210
+repeated_sfixed64: 310
+repeated_float: 211
+repeated_float: 311
+repeated_double: 212
+repeated_double: 312
+repeated_bool: true
+repeated_bool: false
+repeated_string: "215"
+repeated_string: "315"
+repeated_bytes: "216"
+repeated_bytes: "316"
+RepeatedGroup {
+ a: 217
+}
+RepeatedGroup {
+ a: 317
+}
+repeated_nested_message {
+ bb: 218
+}
+repeated_nested_message {
+ bb: 318
+}
+repeated_foreign_message {
+ c: 219
+}
+repeated_foreign_message {
+ c: 319
+}
+repeated_import_message {
+ d: 220
+}
+repeated_import_message {
+ d: 320
+}
+repeated_nested_enum: BAR
+repeated_nested_enum: BAZ
+repeated_foreign_enum: FOREIGN_BAR
+repeated_foreign_enum: FOREIGN_BAZ
+repeated_import_enum: IMPORT_BAR
+repeated_import_enum: IMPORT_BAZ
+repeated_string_piece: "224"
+repeated_string_piece: "324"
+repeated_cord: "225"
+repeated_cord: "325"
+default_int32: 401
+default_int64: 402
+default_uint32: 403
+default_uint64: 404
+default_sint32: 405
+default_sint64: 406
+default_fixed32: 407
+default_fixed64: 408
+default_sfixed32: 409
+default_sfixed64: 410
+default_float: 411
+default_double: 412
+default_bool: false
+default_string: "415"
+default_bytes: "416"
+default_nested_enum: FOO
+default_foreign_enum: FOREIGN_FOO
+default_import_enum: IMPORT_FOO
+default_string_piece: "424"
+default_cord: "425"
diff --git a/src/ProtocolBuffers.Test/Resources/text_format_unittest_extensions_data.txt b/src/ProtocolBuffers.Test/Resources/text_format_unittest_extensions_data.txt
new file mode 100644
index 00000000..4fc282c1
--- /dev/null
+++ b/src/ProtocolBuffers.Test/Resources/text_format_unittest_extensions_data.txt
@@ -0,0 +1,116 @@
+[protobuf_unittest.optional_int32_extension]: 101
+[protobuf_unittest.optional_int64_extension]: 102
+[protobuf_unittest.optional_uint32_extension]: 103
+[protobuf_unittest.optional_uint64_extension]: 104
+[protobuf_unittest.optional_sint32_extension]: 105
+[protobuf_unittest.optional_sint64_extension]: 106
+[protobuf_unittest.optional_fixed32_extension]: 107
+[protobuf_unittest.optional_fixed64_extension]: 108
+[protobuf_unittest.optional_sfixed32_extension]: 109
+[protobuf_unittest.optional_sfixed64_extension]: 110
+[protobuf_unittest.optional_float_extension]: 111
+[protobuf_unittest.optional_double_extension]: 112
+[protobuf_unittest.optional_bool_extension]: true
+[protobuf_unittest.optional_string_extension]: "115"
+[protobuf_unittest.optional_bytes_extension]: "116"
+[protobuf_unittest.optionalgroup_extension] {
+ a: 117
+}
+[protobuf_unittest.optional_nested_message_extension] {
+ bb: 118
+}
+[protobuf_unittest.optional_foreign_message_extension] {
+ c: 119
+}
+[protobuf_unittest.optional_import_message_extension] {
+ d: 120
+}
+[protobuf_unittest.optional_nested_enum_extension]: BAZ
+[protobuf_unittest.optional_foreign_enum_extension]: FOREIGN_BAZ
+[protobuf_unittest.optional_import_enum_extension]: IMPORT_BAZ
+[protobuf_unittest.optional_string_piece_extension]: "124"
+[protobuf_unittest.optional_cord_extension]: "125"
+[protobuf_unittest.repeated_int32_extension]: 201
+[protobuf_unittest.repeated_int32_extension]: 301
+[protobuf_unittest.repeated_int64_extension]: 202
+[protobuf_unittest.repeated_int64_extension]: 302
+[protobuf_unittest.repeated_uint32_extension]: 203
+[protobuf_unittest.repeated_uint32_extension]: 303
+[protobuf_unittest.repeated_uint64_extension]: 204
+[protobuf_unittest.repeated_uint64_extension]: 304
+[protobuf_unittest.repeated_sint32_extension]: 205
+[protobuf_unittest.repeated_sint32_extension]: 305
+[protobuf_unittest.repeated_sint64_extension]: 206
+[protobuf_unittest.repeated_sint64_extension]: 306
+[protobuf_unittest.repeated_fixed32_extension]: 207
+[protobuf_unittest.repeated_fixed32_extension]: 307
+[protobuf_unittest.repeated_fixed64_extension]: 208
+[protobuf_unittest.repeated_fixed64_extension]: 308
+[protobuf_unittest.repeated_sfixed32_extension]: 209
+[protobuf_unittest.repeated_sfixed32_extension]: 309
+[protobuf_unittest.repeated_sfixed64_extension]: 210
+[protobuf_unittest.repeated_sfixed64_extension]: 310
+[protobuf_unittest.repeated_float_extension]: 211
+[protobuf_unittest.repeated_float_extension]: 311
+[protobuf_unittest.repeated_double_extension]: 212
+[protobuf_unittest.repeated_double_extension]: 312
+[protobuf_unittest.repeated_bool_extension]: true
+[protobuf_unittest.repeated_bool_extension]: false
+[protobuf_unittest.repeated_string_extension]: "215"
+[protobuf_unittest.repeated_string_extension]: "315"
+[protobuf_unittest.repeated_bytes_extension]: "216"
+[protobuf_unittest.repeated_bytes_extension]: "316"
+[protobuf_unittest.repeatedgroup_extension] {
+ a: 217
+}
+[protobuf_unittest.repeatedgroup_extension] {
+ a: 317
+}
+[protobuf_unittest.repeated_nested_message_extension] {
+ bb: 218
+}
+[protobuf_unittest.repeated_nested_message_extension] {
+ bb: 318
+}
+[protobuf_unittest.repeated_foreign_message_extension] {
+ c: 219
+}
+[protobuf_unittest.repeated_foreign_message_extension] {
+ c: 319
+}
+[protobuf_unittest.repeated_import_message_extension] {
+ d: 220
+}
+[protobuf_unittest.repeated_import_message_extension] {
+ d: 320
+}
+[protobuf_unittest.repeated_nested_enum_extension]: BAR
+[protobuf_unittest.repeated_nested_enum_extension]: BAZ
+[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAR
+[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAZ
+[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAR
+[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAZ
+[protobuf_unittest.repeated_string_piece_extension]: "224"
+[protobuf_unittest.repeated_string_piece_extension]: "324"
+[protobuf_unittest.repeated_cord_extension]: "225"
+[protobuf_unittest.repeated_cord_extension]: "325"
+[protobuf_unittest.default_int32_extension]: 401
+[protobuf_unittest.default_int64_extension]: 402
+[protobuf_unittest.default_uint32_extension]: 403
+[protobuf_unittest.default_uint64_extension]: 404
+[protobuf_unittest.default_sint32_extension]: 405
+[protobuf_unittest.default_sint64_extension]: 406
+[protobuf_unittest.default_fixed32_extension]: 407
+[protobuf_unittest.default_fixed64_extension]: 408
+[protobuf_unittest.default_sfixed32_extension]: 409
+[protobuf_unittest.default_sfixed64_extension]: 410
+[protobuf_unittest.default_float_extension]: 411
+[protobuf_unittest.default_double_extension]: 412
+[protobuf_unittest.default_bool_extension]: false
+[protobuf_unittest.default_string_extension]: "415"
+[protobuf_unittest.default_bytes_extension]: "416"
+[protobuf_unittest.default_nested_enum_extension]: FOO
+[protobuf_unittest.default_foreign_enum_extension]: FOREIGN_FOO
+[protobuf_unittest.default_import_enum_extension]: IMPORT_FOO
+[protobuf_unittest.default_string_piece_extension]: "424"
+[protobuf_unittest.default_cord_extension]: "425"
diff --git a/src/ProtocolBuffers.Test/SerializableTest.cs b/src/ProtocolBuffers.Test/SerializableTest.cs
index b55358ef..90406140 100644
--- a/src/ProtocolBuffers.Test/SerializableTest.cs
+++ b/src/ProtocolBuffers.Test/SerializableTest.cs
@@ -1,4 +1,4 @@
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
+#if !NOSERIALIZABLE
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/src/ProtocolBuffers.Test/TestResources.Designer.cs b/src/ProtocolBuffers.Test/TestResources.Designer.cs
new file mode 100644
index 00000000..ada50c2b
--- /dev/null
+++ b/src/ProtocolBuffers.Test/TestResources.Designer.cs
@@ -0,0 +1,131 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.5456
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Google.ProtocolBuffers {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class TestResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal TestResources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Google.ProtocolBuffers.TestResources", typeof(TestResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static byte[] golden_message {
+ get {
+ object obj = ResourceManager.GetObject("golden_message", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ internal static byte[] golden_packed_fields_message {
+ get {
+ object obj = ResourceManager.GetObject("golden_packed_fields_message", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to optional_int32: 101
+ ///optional_int64: 102
+ ///optional_uint32: 103
+ ///optional_uint64: 104
+ ///optional_sint32: 105
+ ///optional_sint64: 106
+ ///optional_fixed32: 107
+ ///optional_fixed64: 108
+ ///optional_sfixed32: 109
+ ///optional_sfixed64: 110
+ ///optional_float: 111
+ ///optional_double: 112
+ ///optional_bool: true
+ ///optional_string: &quot;115&quot;
+ ///optional_bytes: &quot;116&quot;
+ ///OptionalGroup {
+ /// a: 117
+ ///}
+ ///optional_nested_message {
+ /// bb: 118
+ ///}
+ ///optional_foreign_message {
+ /// c: 119
+ ///}
+ ///optional_import_message {
+ /// d: 120
+ ///}
+ ///optional_nested_enum: BAZ [rest of string was truncated]&quot;;.
+ /// </summary>
+ internal static string text_format_unittest_data {
+ get {
+ return ResourceManager.GetString("text_format_unittest_data", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to [protobuf_unittest.optional_int32_extension]: 101
+ ///[protobuf_unittest.optional_int64_extension]: 102
+ ///[protobuf_unittest.optional_uint32_extension]: 103
+ ///[protobuf_unittest.optional_uint64_extension]: 104
+ ///[protobuf_unittest.optional_sint32_extension]: 105
+ ///[protobuf_unittest.optional_sint64_extension]: 106
+ ///[protobuf_unittest.optional_fixed32_extension]: 107
+ ///[protobuf_unittest.optional_fixed64_extension]: 108
+ ///[protobuf_unittest.optional_sfixed32_extension]: 109
+ ///[protobuf_unittest.optional_sfixed64_exten [rest of string was truncated]&quot;;.
+ /// </summary>
+ internal static string text_format_unittest_extensions_data {
+ get {
+ return ResourceManager.GetString("text_format_unittest_extensions_data", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/ProtocolBuffers.Test/TestResources.resx b/src/ProtocolBuffers.Test/TestResources.resx
new file mode 100644
index 00000000..65531bbd
--- /dev/null
+++ b/src/ProtocolBuffers.Test/TestResources.resx
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="golden_message" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\golden_message;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name="golden_packed_fields_message" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\golden_packed_fields_message;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name="text_format_unittest_data" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\text_format_unittest_data.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+ </data>
+ <data name="text_format_unittest_extensions_data" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\text_format_unittest_extensions_data.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/src/ProtocolBuffers.Test/TestUtil.cs b/src/ProtocolBuffers.Test/TestUtil.cs
index ffbb91d5..19c0df34 100644
--- a/src/ProtocolBuffers.Test/TestUtil.cs
+++ b/src/ProtocolBuffers.Test/TestUtil.cs
@@ -41,47 +41,12 @@ using System.IO;
using System.Text;
using System.Threading;
using Google.ProtocolBuffers.TestProtos;
-#if SILVERLIGHT
-using TestClass = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
-using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
-using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
-#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#endif
namespace Google.ProtocolBuffers
{
internal static class TestUtil
{
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
- private static string testDataDirectory;
-
- internal static string TestDataDirectory
- {
- get
- {
- if (testDataDirectory != null)
- {
- return testDataDirectory;
- }
-
- DirectoryInfo ancestor = new DirectoryInfo(".");
- // Search each parent directory looking for "testdata".
- while (ancestor != null)
- {
- string candidate = Path.Combine(ancestor.FullName, "testdata");
- if (Directory.Exists(candidate))
- {
- testDataDirectory = candidate;
- return candidate;
- }
- ancestor = ancestor.Parent;
- }
- // TODO(jonskeet): Come up with a better exception to throw
- throw new Exception("Unable to find directory containing test files");
- }
- }
-
private static ByteString goldenMessage = null;
internal static ByteString GoldenMessage
@@ -90,23 +55,12 @@ namespace Google.ProtocolBuffers
{
if (goldenMessage == null)
{
- goldenMessage = ReadBytesFromFile("golden_message");
+ goldenMessage = ByteString.CopyFrom(TestResources.golden_message);
}
return goldenMessage;
}
}
- internal static string ReadTextFromFile(string filePath)
- {
- return ReadBytesFromFile(filePath).ToStringUtf8();
- }
-
- internal static ByteString ReadBytesFromFile(String filename)
- {
- byte[] data = File.ReadAllBytes(Path.Combine(TestDataDirectory, filename));
- return ByteString.CopyFrom(data);
- }
-
private static ByteString goldenPackedFieldsMessage = null;
/// <summary>
@@ -120,12 +74,11 @@ namespace Google.ProtocolBuffers
{
if (goldenPackedFieldsMessage == null)
{
- goldenPackedFieldsMessage = ReadBytesFromFile("golden_packed_fields_message");
+ goldenPackedFieldsMessage = ByteString.CopyFrom(TestResources.golden_packed_fields_message);
}
return goldenPackedFieldsMessage;
}
-#endif
/// <summary>
/// Creates an unmodifiable ExtensionRegistry containing all the extensions
/// of TestAllExtensions.
diff --git a/src/ProtocolBuffers.Test/TextFormatTest.cs b/src/ProtocolBuffers.Test/TextFormatTest.cs
index 10ab4e15..3008c599 100644
--- a/src/ProtocolBuffers.Test/TextFormatTest.cs
+++ b/src/ProtocolBuffers.Test/TextFormatTest.cs
@@ -41,17 +41,14 @@ using Google.ProtocolBuffers.TestProtos;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;
using System.Threading;
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
namespace Google.ProtocolBuffers
{
[TestClass]
public class TextFormatTest
{
- private static readonly string AllFieldsSetText = TestUtil.ReadTextFromFile("text_format_unittest_data.txt");
-
- private static readonly string AllExtensionsSetText =
- TestUtil.ReadTextFromFile("text_format_unittest_extensions_data.txt");
+ private static readonly string AllFieldsSetText = TestResources.text_format_unittest_data;
+ private static readonly string AllExtensionsSetText = TestResources.text_format_unittest_extensions_data;
/// <summary>
/// Note that this is slightly different to the Java - 123.0 becomes 123, and 1.23E17 becomes 1.23E+17.
@@ -572,5 +569,4 @@ namespace Google.ProtocolBuffers
Assert.AreEqual(longText, builder.OptionalString);
}
}
-}
-#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/src/ProtocolBuffers/CustomSerialization.cs b/src/ProtocolBuffers/CustomSerialization.cs
index 256f2e67..a1aee029 100644
--- a/src/ProtocolBuffers/CustomSerialization.cs
+++ b/src/ProtocolBuffers/CustomSerialization.cs
@@ -36,7 +36,7 @@
/*
* This entire source file is not supported on the Silverlight platform
*/
-#if !SILVERLIGHT && !COMPACT_FRAMEWORK
+#if !NOSERIALIZABLE
using System;
using System.Runtime.Serialization;
diff --git a/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
index d2b6c51f..24f7fba9 100644
--- a/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
+++ b/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
@@ -63,8 +63,7 @@ namespace Google.ProtocolBuffers.FieldAccess
/// <summary>
/// Method used solely for implementing CreateUpcastDelegate. Public to avoid trust issues
- /// in low-trust scenarios, e.g. Silverlight.
- /// TODO(jonskeet): Check any of this actually works in Silverlight...
+ /// in low-trust scenarios.
/// </summary>
public static Func<TSource, object> CreateUpcastDelegateImpl<TSource, TResult>(MethodInfo method)
{
diff --git a/src/ProtocolBuffers/FrameworkPortability.cs b/src/ProtocolBuffers/FrameworkPortability.cs
index 774d5625..78b7db31 100644
--- a/src/ProtocolBuffers/FrameworkPortability.cs
+++ b/src/ProtocolBuffers/FrameworkPortability.cs
@@ -42,7 +42,7 @@ using System.Text.RegularExpressions;
namespace Google.ProtocolBuffers
{
/// <summary>
- /// Class containing helpful workarounds for Silverlight compatibility
+ /// Class containing helpful workarounds for various platform compatibility
/// </summary>
internal static class FrameworkPortability
{
diff --git a/src/ProtocolBuffers/SortedList.cs b/src/ProtocolBuffers/SortedList.cs
index 4dcf9282..2dd7da92 100644
--- a/src/ProtocolBuffers/SortedList.cs
+++ b/src/ProtocolBuffers/SortedList.cs
@@ -34,7 +34,7 @@
#endregion
-#if SILVERLIGHT
+#if NOSORTEDLIST
using System.Collections;
using System.Collections.Generic;
@@ -45,8 +45,6 @@ namespace Google.ProtocolBuffers
/// This is not particularly efficient: it wraps a normal dictionary
/// for most operations, but sorts by key when either iterating or
/// fetching the Keys/Values properties.
- /// This is only used for Silverlight, which doesn't have the normal
- /// sorted collections.
/// </summary>
internal sealed class SortedList<TKey, TValue> : IDictionary<TKey, TValue>
{
diff --git a/src/ProtocolBuffers/ThrowHelper.cs b/src/ProtocolBuffers/ThrowHelper.cs
index 22584dd0..34b3f653 100644
--- a/src/ProtocolBuffers/ThrowHelper.cs
+++ b/src/ProtocolBuffers/ThrowHelper.cs
@@ -82,11 +82,7 @@ namespace Google.ProtocolBuffers
public static Exception CreateMissingMethod(Type type, string methodName)
{
-#if SILVERLIGHT || COMPACT_FRAMEWORK
return new MissingMethodException(String.Format("The method '{0}' was not found on type {1}", methodName, type));
-#else
- return new MissingMethodException(String.Format("{0}", type), methodName);
-#endif
}
}
} \ No newline at end of file