Working to reduce number of conditional complication directives, and migrate towards feature-based condtions rather than platform-based

pull/288/head
csharptest 12 years ago committed by rogerk
parent 5cda54bd8b
commit 945bd1d516
  1. 4
      src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
  2. 10
      src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
  3. 2
      src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
  4. 6
      src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
  5. 7
      src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
  6. 7
      src/ProtocolBuffers.Test/Compatibility/TestResources.cs
  7. 7
      src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
  8. 6
      src/ProtocolBuffers.Test/DescriptorsTest.cs
  9. 19
      src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
  10. BIN
      src/ProtocolBuffers.Test/Resources/golden_message
  11. BIN
      src/ProtocolBuffers.Test/Resources/golden_packed_fields_message
  12. 116
      src/ProtocolBuffers.Test/Resources/text_format_unittest_data.txt
  13. 116
      src/ProtocolBuffers.Test/Resources/text_format_unittest_extensions_data.txt
  14. 2
      src/ProtocolBuffers.Test/SerializableTest.cs
  15. 131
      src/ProtocolBuffers.Test/TestResources.Designer.cs
  16. 133
      src/ProtocolBuffers.Test/TestResources.resx
  17. 51
      src/ProtocolBuffers.Test/TestUtil.cs
  18. 10
      src/ProtocolBuffers.Test/TextFormatTest.cs
  19. 2
      src/ProtocolBuffers/CustomSerialization.cs
  20. 3
      src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
  21. 2
      src/ProtocolBuffers/FrameworkPortability.cs
  22. 4
      src/ProtocolBuffers/SortedList.cs
  23. 4
      src/ProtocolBuffers/ThrowHelper.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;

@ -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
}
}

@ -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()

@ -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
{

@ -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
{

@ -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
{

@ -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
{

@ -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()
{

@ -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.

@ -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"

@ -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"

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

@ -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);
}
}
}
}

@ -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>

@ -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.

@ -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
}

@ -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;

@ -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)
{

@ -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
{

@ -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>
{

@ -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
}
}
}
Loading…
Cancel
Save