diff options
author | garyb <garyb@system1.(none)> | 2012-07-16 19:34:22 +0400 |
---|---|---|
committer | garyb <garyb@system1.(none)> | 2012-10-11 02:20:04 +0400 |
commit | 0df90210692aed502e375aafb67f6b1f95b2bcf9 (patch) | |
tree | bbd1f2948ad79cbe977446bb5fc5e8d94dbdf74d /mcs/class/Managed.Windows.Forms/Test | |
parent | 03655fa4a892a07056f5369b4d552edcc71cd514 (diff) |
ResXDataNode based resx handling nearly complete. More tests added.
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/Test')
16 files changed, 1355 insertions, 2289 deletions
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_ITRS.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_ITRS.cs index c22a527844e..644dc49d473 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_ITRS.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_ITRS.cs @@ -1,155 +1,179 @@ -using System; +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2012 Gary Barnett +// +// Authors: +// Gary Barnett + +using System; using System.ComponentModel.Design; using System.Reflection; namespace MonoTests.System.Resources { - public class DummyTypeResolutionService : ITypeResolutionService { - public Assembly GetAssembly (AssemblyName name, bool throwOnError) - { - return null; - } - - public Assembly GetAssembly (AssemblyName name) - { - return null; - } - - public string GetPathOfAssembly (AssemblyName name) - { - return null; - } - - public Type GetType (string name, bool throwOnError, bool ignoreCase) - { - return null; - } - - public Type GetType (string name, bool throwOnError) - { - return null; - } - - public Type GetType (string name) - { - return null; - } - - public void ReferenceAssembly (AssemblyName name) - { - - } - } - - public class AlwaysReturnSerializableSubClassTypeResolutionService : ITypeResolutionService { - public Assembly GetAssembly (AssemblyName name, bool throwOnError) - { - throw new NotImplementedException ("I was accessed"); - } - - public Assembly GetAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public string GetPathOfAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public Type GetType (string name, bool throwOnError, bool ignoreCase) - { - return typeof (serializableSubClass); - } - - public Type GetType (string name, bool throwOnError) - { - return typeof (serializableSubClass); - } - - public Type GetType (string name) - { - return typeof (serializableSubClass); - } - - public void ReferenceAssembly (AssemblyName name) - { - - } - - } - - public class AlwaysReturnIntTypeResolutionService : ITypeResolutionService { - public Assembly GetAssembly (AssemblyName name, bool throwOnError) - { - throw new NotImplementedException ("I was accessed"); - } - - public Assembly GetAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public string GetPathOfAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public Type GetType (string name, bool throwOnError, bool ignoreCase) - { - return typeof (Int32); - } - - public Type GetType (string name, bool throwOnError) - { - return typeof (Int32); - } - - public Type GetType (string name) - { - return typeof (Int32); - } - - public void ReferenceAssembly (AssemblyName name) - { - - } - } - - public class ExceptionalTypeResolutionService : ITypeResolutionService { - public Assembly GetAssembly (AssemblyName name, bool throwOnError) - { - throw new NotImplementedException ("I was accessed"); - } - - public Assembly GetAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public string GetPathOfAssembly (AssemblyName name) - { - throw new NotImplementedException ("I was accessed"); - } - - public Type GetType (string name, bool throwOnError, bool ignoreCase) - { - throw new NotImplementedException ("I was accessed"); - } - - public Type GetType (string name, bool throwOnError) - { - throw new NotImplementedException ("I was accessed"); - } - - public Type GetType (string name) - { - throw new NotImplementedException ("I was accessed"); - } - - public void ReferenceAssembly (AssemblyName name) - { - - } - } + public class DummyTypeResolutionService : ITypeResolutionService { + public Assembly GetAssembly (AssemblyName name, bool throwOnError) + { + return null; + } + + public Assembly GetAssembly (AssemblyName name) + { + return null; + } + + public string GetPathOfAssembly (AssemblyName name) + { + return null; + } + + public Type GetType (string name, bool throwOnError, bool ignoreCase) + { + return null; + } + + public Type GetType (string name, bool throwOnError) + { + return null; + } + + public Type GetType (string name) + { + return null; + } + + public void ReferenceAssembly (AssemblyName name) + { + + } + } + + public class AlwaysReturnSerializableSubClassTypeResolutionService : ITypeResolutionService { + public Assembly GetAssembly (AssemblyName name, bool throwOnError) + { + throw new NotImplementedException ("I was accessed"); + } + + public Assembly GetAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public string GetPathOfAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public Type GetType (string name, bool throwOnError, bool ignoreCase) + { + return typeof (serializableSubClass); + } + + public Type GetType (string name, bool throwOnError) + { + return typeof (serializableSubClass); + } + + public Type GetType (string name) + { + return typeof (serializableSubClass); + } + + public void ReferenceAssembly (AssemblyName name) + { + + } + + } + + public class AlwaysReturnIntTypeResolutionService : ITypeResolutionService { + public Assembly GetAssembly (AssemblyName name, bool throwOnError) + { + throw new NotImplementedException ("I was accessed"); + } + + public Assembly GetAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public string GetPathOfAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public Type GetType (string name, bool throwOnError, bool ignoreCase) + { + return typeof (Int32); + } + + public Type GetType (string name, bool throwOnError) + { + return typeof (Int32); + } + + public Type GetType (string name) + { + return typeof (Int32); + } + + public void ReferenceAssembly (AssemblyName name) + { + + } + } + + public class ExceptionalTypeResolutionService : ITypeResolutionService { + public Assembly GetAssembly (AssemblyName name, bool throwOnError) + { + throw new NotImplementedException ("I was accessed"); + } + + public Assembly GetAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public string GetPathOfAssembly (AssemblyName name) + { + throw new NotImplementedException ("I was accessed"); + } + + public Type GetType (string name, bool throwOnError, bool ignoreCase) + { + throw new NotImplementedException ("I was accessed"); + } + + public Type GetType (string name, bool throwOnError) + { + throw new NotImplementedException ("I was accessed"); + } + + public Type GetType (string name) + { + throw new NotImplementedException ("I was accessed"); + } + + public void ReferenceAssembly (AssemblyName name) + { + + } + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_Resources.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_Resources.cs index ed596289b1b..4d5474b32c0 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_Resources.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/HelperClasses_Resources.cs @@ -1,4 +1,28 @@ -using System; +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2012 Gary Barnett +// +// Authors: +// Gary Barnett + +using System; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.ComponentModel; @@ -7,159 +31,159 @@ using System.IO; namespace MonoTests.System.Resources { class notserializable { - public object test; - public notserializable () - { - - } - } - - [SerializableAttribute] - public class serializable : ISerializable { - public string name; - public string value; - - public serializable () - { - } - - public serializable (string name, string value) - { - this.name = name; - this.value = value; - } - - public serializable (SerializationInfo info, StreamingContext ctxt) - { - name = (string) info.GetValue ("sername", typeof (string)); - value = (String) info.GetValue ("servalue", typeof (string)); - } - - public serializable (Stream stream) - { - BinaryFormatter bFormatter = new BinaryFormatter (); - serializable deser = (serializable) bFormatter.Deserialize (stream); - stream.Close (); - - name = deser.name; - value = deser.value; - } - - public void GetObjectData (SerializationInfo info, StreamingContext ctxt) - { - info.AddValue ("sername", name); - info.AddValue ("servalue", value); - } - - public override string ToString () - { - return String.Format ("name={0};value={1}", this.name, this.value); - } - - public override bool Equals (object obj) - { - serializable o = obj as serializable; - if (o == null) - return false; - return this.name.Equals (o.name) && this.value.Equals (o.value); - } - } - - [SerializableAttribute] - public class serializableSubClass : serializable { - public serializableSubClass () - { - } - - public serializableSubClass (SerializationInfo info, StreamingContext ctxt) - : base (info, ctxt) - { - } - - public serializableSubClass (Stream stream) - { - BinaryFormatter bFormatter = new BinaryFormatter (); - serializableSubClass deser = (serializableSubClass) bFormatter.Deserialize (stream); - stream.Close (); - - name = deser.name; - value = deser.value; - } - } - - [SerializableAttribute] - [TypeConverter (typeof (ThisAssemblyConvertableConverter))] - public class ThisAssemblyConvertable { - protected string name; - protected string value; - - public ThisAssemblyConvertable () - { - } - - public ThisAssemblyConvertable (string name, string value) - { - this.name = name; - this.value = value; - } - - public void GetObjectData (SerializationInfo info, StreamingContext ctxt) - { - info.AddValue ("sername", name); - info.AddValue ("servalue", value); - } - - public override string ToString () - { - return String.Format ("{0}\t{1}", name, value); - } - - public override bool Equals (object obj) - { - ThisAssemblyConvertable o = obj as ThisAssemblyConvertable; - if (o == null) - return false; - return this.name.Equals (o.name) && this.value.Equals (o.value); - } - } - - class ThisAssemblyConvertableConverter : TypeConverter { - public ThisAssemblyConvertableConverter () - { - } - - public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) - { - return sourceType == typeof (string); - } - - public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) - { - return destinationType == typeof (string); - } - - public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value) - { - if (value.GetType () != typeof (string)) - throw new Exception ("value not string"); - - string serialised = (string) value; - - string [] parts = serialised.Split ('\t'); - - if (parts.Length != 2) - throw new Exception ("string in incorrect format"); - - ThisAssemblyConvertable convertable = new ThisAssemblyConvertable (parts [0], parts [1]); - return convertable; - } - - public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - if (destinationType != typeof (String)) { - return base.ConvertTo (context, culture, value, destinationType); - } - - return ((ThisAssemblyConvertable) value).ToString (); - } - } + public object test; + public notserializable () + { + + } + } + + [SerializableAttribute] + public class serializable : ISerializable { + public string name; + public string value; + + public serializable () + { + } + + public serializable (string name, string value) + { + this.name = name; + this.value = value; + } + + public serializable (SerializationInfo info, StreamingContext ctxt) + { + name = (string) info.GetValue ("sername", typeof (string)); + value = (String) info.GetValue ("servalue", typeof (string)); + } + + public serializable (Stream stream) + { + BinaryFormatter bFormatter = new BinaryFormatter (); + serializable deser = (serializable) bFormatter.Deserialize (stream); + stream.Close (); + + name = deser.name; + value = deser.value; + } + + public void GetObjectData (SerializationInfo info, StreamingContext ctxt) + { + info.AddValue ("sername", name); + info.AddValue ("servalue", value); + } + + public override string ToString () + { + return String.Format ("name={0};value={1}", this.name, this.value); + } + + public override bool Equals (object obj) + { + serializable o = obj as serializable; + if (o == null) + return false; + return this.name.Equals (o.name) && this.value.Equals (o.value); + } + } + + [SerializableAttribute] + public class serializableSubClass : serializable { + public serializableSubClass () + { + } + + public serializableSubClass (SerializationInfo info, StreamingContext ctxt) + : base (info, ctxt) + { + } + + public serializableSubClass (Stream stream) + { + BinaryFormatter bFormatter = new BinaryFormatter (); + serializableSubClass deser = (serializableSubClass) bFormatter.Deserialize (stream); + stream.Close (); + + name = deser.name; + value = deser.value; + } + } + + [SerializableAttribute] + [TypeConverter (typeof (ThisAssemblyConvertableConverter))] + public class ThisAssemblyConvertable { + protected string name; + protected string value; + + public ThisAssemblyConvertable () + { + } + + public ThisAssemblyConvertable (string name, string value) + { + this.name = name; + this.value = value; + } + + public void GetObjectData (SerializationInfo info, StreamingContext ctxt) + { + info.AddValue ("sername", name); + info.AddValue ("servalue", value); + } + + public override string ToString () + { + return String.Format ("{0}\t{1}", name, value); + } + + public override bool Equals (object obj) + { + ThisAssemblyConvertable o = obj as ThisAssemblyConvertable; + if (o == null) + return false; + return this.name.Equals (o.name) && this.value.Equals (o.value); + } + } + + class ThisAssemblyConvertableConverter : TypeConverter { + public ThisAssemblyConvertableConverter () + { + } + + public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof (string); + } + + public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof (string); + } + + public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value.GetType () != typeof (string)) + throw new Exception ("value not string"); + + string serialised = (string) value; + + string [] parts = serialised.Split ('\t'); + + if (parts.Length != 2) + throw new Exception ("string in incorrect format"); + + ThisAssemblyConvertable convertable = new ThisAssemblyConvertable (parts [0], parts [1]); + return convertable; + } + + public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { + if (destinationType != typeof (String)) { + return base.ConvertTo (context, culture, value, destinationType); + } + + return ((ThisAssemblyConvertable) value).ToString (); + } + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAliasTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAliasTests.cs index b29c9bb5b76..e7877d67d99 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAliasTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAliasTests.cs @@ -38,24 +38,24 @@ namespace MonoTests.System.Resources { public void CantAccessValueWereOnlyFullNameInResXForEmbedded () // same as validity check in assemblynames tests { ResXDataNode node = GetNodeFromResXReader (convertableResX); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue ((AssemblyName[]) null); } [Test, ExpectedException (typeof (TypeLoadException))] public void CantAccessValueWereOnlyFullNameAndAliasInResXForEmbedded () { - ResXDataNode node = GetNodeFromResXReader (convertableResXAlias); - Assert.IsNotNull (node, "#A1"); + ResXDataNode node = GetNodeFromResXReader (convertableResXAlias); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue ((AssemblyName []) null); } [Test] public void CanAccessValueWereOnlyFullNameAndAssemblyInResXForEmbedded () { - ResXDataNode node = GetNodeFromResXReader (convertableResXAssembly); + ResXDataNode node = GetNodeFromResXReader (convertableResXAssembly); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue ((AssemblyName []) null); // this is the qualified name of the assembly found in dir string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; @@ -66,8 +66,8 @@ namespace MonoTests.System.Resources { [Test] public void CanAccessValueWereOnlyFullNameAndQualifiedAssemblyInResXForEmbedded () { - ResXDataNode node = GetNodeFromResXReader (convertableResXQualifiedAssemblyName); - Assert.IsNotNull (node, "#A1"); + ResXDataNode node = GetNodeFromResXReader (convertableResXQualifiedAssemblyName); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue ((AssemblyName []) null); string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; @@ -77,111 +77,7 @@ namespace MonoTests.System.Resources { static string convertableResX = @"<?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> @@ -204,111 +100,7 @@ namespace MonoTests.System.Resources { static string convertableResXAssembly = @"<?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> @@ -331,111 +123,7 @@ namespace MonoTests.System.Resources { static string convertableResXAlias = @"<?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> @@ -457,111 +145,7 @@ namespace MonoTests.System.Resources { static string convertableResXQualifiedAssemblyName = @"<?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> diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAssemblyNameTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAssemblyNameTests.cs index 6a7adbb39c0..aa0598f7db7 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAssemblyNameTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeAssemblyNameTests.cs @@ -35,7 +35,7 @@ using System.Globalization; namespace MonoTests.System.Resources { [TestFixture] - public class ResXDataNodeAssemblyNameTests : ResourcesTestHelper { + public class ResXDataNodeAssemblyNameTests : ResourcesTestHelper { /* [Test] public void CanPassAssemblyNameToGetValueToReturnSpecificVersionOfObjectClassInstance () @@ -120,40 +120,30 @@ namespace MonoTests.System.Resources { */ - [Test, ExpectedException (typeof (TypeLoadException))] - public void GetValueAssemblyNameUsedWereOnlyFullNameInResXForEmbedded_TestValidityCheck () - { - // just a check, if this passes other tests will give false results - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - - Assert.IsNotNull (node, "#A1"); - object obj = node.GetValue ((AssemblyName []) null); - } - [Test] - public void GetValueAssemblyNameUsedWhereOnlyFullNameInResXForEmbedded () + public void GetValueAssemblyNameUsedWhereOnlyFullNameInResX_TypeConverter () { // DummyAssembly must be in the same directory as current assembly to work correctly string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue (assemblyNames); Assert.AreEqual ("DummyAssembly.Convertable, " + aName, obj.GetType ().AssemblyQualifiedName); } [Test, ExpectedException (typeof (TypeLoadException))] - public void GetValueAssemblyNameRequiredEachTimeWhereOnlyFullNameInResXForEmbedded () + public void GetValueAssemblyNameRequiredEachTimeWhereOnlyFullNameInResX_TypeConverter () { // DummyAssembly must be in the same directory as current assembly to work correctly string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue (assemblyNames); Assert.AreEqual ("DummyAssembly.Convertable, " + aName, obj.GetType ().AssemblyQualifiedName, "#A2"); object obj2 = node.GetValue ((AssemblyName []) null); //should cause exception here @@ -161,176 +151,158 @@ namespace MonoTests.System.Resources { } //FIXME: does the way this test is run by NUnit affect the validity of the results showing that you need assembly name to pull type from current assembly? [Test, ExpectedException (typeof (TypeLoadException))] - public void CantLoadTypeFromThisAssemblyWithOnlyFullName () + public void CantLoadTypeFromThisAssemblyWithOnlyFullName_TypeConverter () { - ResXDataNode node = GetNodeFromResXReader (thisAssemblyConvertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + ResXDataNode node = GetNodeFromResXReader (thisAssemblyConvertableResXWithoutAssemblyName); + Assert.IsNotNull (node, "#A1"); object obj = node.GetValue ((AssemblyName []) null); } [Test] - public void CanLoadTypeFromThisAssemblyWithOnlyFullNamePassingAssemblyNames () + public void CanLoadTypeFromThisAssemblyWithOnlyFullNamePassingAssemblyNames_TypeConverter () { string aName = "System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"; AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (thisAssemblyConvertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (thisAssemblyConvertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); // would cause exception if couldnt find type object obj = node.GetValue (assemblyNames); Assert.IsInstanceOfType (typeof (ThisAssemblyConvertable), obj, "#A2"); } [Test] - public void GetValueTypeNameReturnsFullNameWereOnlyFullNameInResXForEmbedded () + public void GetValueTypeNameReturnsFullNameWereOnlyFullNameInResX_TypeConverter () { // just a check, if this passes other tests will give false results - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); string returnedType = node.GetValueTypeName ((AssemblyName []) null); Assert.AreEqual ("DummyAssembly.Convertable", returnedType, "#A2"); } [Test] - public void GetValueTypeNameAssemblyNameUsedWhereOnlyFullNameInResXForEmbedded () + public void GetValueTypeNameAssemblyNameUsedWhereOnlyFullNameInResX_TypeConverter () { // DummyAssembly must be in the same directory as current assembly to work correctly string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); string returnedType = node.GetValueTypeName (assemblyNames); Assert.AreEqual ("DummyAssembly.Convertable, " + aName, returnedType, "#A2"); } [Test] - public void GetValueTypeNameAssemblyNameUsedEachTimeWhereOnlyFullNameInResXForEmbedded () + public void GetValueTypeNameAssemblyNameUsedEachTimeWhereOnlyFullNameInResX_TypeConverter () { // DummyAssembly must be in the same directory as current assembly to work correctly string aName = "DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); + Assert.IsNotNull (node, "#A1"); string returnedName = node.GetValueTypeName (assemblyNames); Assert.AreEqual ("DummyAssembly.Convertable, " + aName, returnedName, "#A2"); string nameWithNullParam = node.GetValueTypeName ((AssemblyName []) null); Assert.AreEqual ("DummyAssembly.Convertable", nameWithNullParam, "#A3"); } + [Test] + public void AssemblyAutomaticallyLoaded_Serialized_GetValue () + { + ResXDataNode node = GetNodeFromResXReader (anotherSerializableFromDummyAssembly); + Assert.IsNotNull (node, "#A1"); + object value = node.GetValue ((AssemblyName[]) null); + Assert.AreEqual ("DummyAssembly.AnotherSerializable, DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", value.GetType ().AssemblyQualifiedName, "#A2"); + } + + [Test] + public void AssemblyAutomaticallyLoaded_Serialized_GetValueTypeName () + { + ResXDataNode node = GetNodeFromResXReader (anotherSerializableFromDummyAssembly); + Assert.IsNotNull (node, "#A1"); + string type = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual ("DummyAssembly.AnotherSerializable, DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", type, "#A2"); + } + + [Test, ExpectedException (typeof (ArgumentException))] + public void ErrorWhenAssemblyMissing_Serialized_GetValue () + { + ResXDataNode node = GetNodeFromResXReader (missingSerializableFromMissingAssembly); + Assert.IsNotNull (node, "#A1"); + object val = node.GetValue ((AssemblyName[]) null); + } + + [Test] + public void ReturnsObjectAssemblyMissing_Serialized_GetValueTypeName () + { + ResXDataNode node = GetNodeFromResXReader (missingSerializableFromMissingAssembly); + Assert.IsNotNull (node, "#A1"); + string type = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual (typeof (object).AssemblyQualifiedName, type, "#A2"); + } + + static string missingSerializableFromMissingAssembly = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""aname"" mimetype=""application/x-microsoft.net.object.binary.base64""> + <value> + AAEAAAD/////AQAAAAAAAAAMAgAAAEZNaXNzaW5nQXNzZW1ibHksIFZlcnNpb249MS4wLjAuMCwgQ3Vs + dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBQEAAAAhRHVtbXlBc3NlbWJseS5NaXNzaW5n + U2VyaWFsaXphYmxlAgAAAAdzZXJuYW1lCHNlcnZhbHVlAQECAAAABgMAAAAFYW5hbWUGBAAAAAZhdmFs + dWUL +</value> + </data> +</root>"; + + static string anotherSerializableFromDummyAssembly = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""aname"" mimetype=""application/x-microsoft.net.object.binary.base64""> + <value> + AAEAAAD/////AQAAAAAAAAAMAgAAAEREdW1teUFzc2VtYmx5LCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1 + cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAUBAAAAIUR1bW15QXNzZW1ibHkuQW5vdGhlclNl + cmlhbGl6YWJsZQIAAAAHc2VybmFtZQhzZXJ2YWx1ZQEBAgAAAAYDAAAABWFuYW1lBgQAAAAGYXZhbHVl + Cw== +</value> + </data> +</root>"; + static string convertableResXWithoutAssemblyName = @"<?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> @@ -352,111 +324,7 @@ namespace MonoTests.System.Resources { static string thisAssemblyConvertableResXWithoutAssemblyName = @"<?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> @@ -474,7 +342,7 @@ namespace MonoTests.System.Resources { <value>im a name im a value</value> </data> </root>"; - + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeByteArrayTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeByteArrayTests.cs index f17dfddb2d8..27312bfc73d 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeByteArrayTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeByteArrayTests.cs @@ -39,9 +39,9 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedBytes1To10 (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); - Assert.IsNotNull (returnedNode, "#A1"); + Assert.IsNotNull (returnedNode, "#A1"); object val = returnedNode.GetValue (new AlwaysReturnIntTypeResolutionService ()); Assert.IsInstanceOfType (typeof (byte[]), val, "#A2"); } @@ -51,7 +51,7 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedBytes1To10 (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); //would raise error if touched @@ -78,7 +78,7 @@ namespace MonoTests.System.Resources { originalNode = GetNodeEmdeddedBytes1To10 (); returnedNode = GetNodeFromResXReader (originalNode); - Assert.IsNotNull (returnedNode, "#A1"); + Assert.IsNotNull (returnedNode, "#A1"); string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnIntTypeResolutionService ()); Assert.AreEqual ((typeof (int)).AssemblyQualifiedName, returnedType, "#A2"); } @@ -90,7 +90,7 @@ namespace MonoTests.System.Resources { originalNode = GetNodeEmdeddedBytes1To10 (); returnedNode = GetNodeFromResXReader (originalNode); - Assert.IsNotNull (returnedNode, "#A1"); + Assert.IsNotNull (returnedNode, "#A1"); object obj = returnedNode.GetValue ((ITypeResolutionService) null); string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnIntTypeResolutionService ()); Assert.AreEqual ((typeof (int)).AssemblyQualifiedName, returnedType, "#A2"); @@ -111,8 +111,8 @@ namespace MonoTests.System.Resources { [Test] public void ChangesToReturnedByteArrayNotLaterWrittenBack () { - ResXDataNode originalNode, returnedNode, finalNode; - originalNode = GetNodeEmdeddedBytes1To10 (); + ResXDataNode originalNode, returnedNode, finalNode; + originalNode = GetNodeEmdeddedBytes1To10 (); returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTests.cs index c2c82258fb1..586b7aff7ed 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTests.cs @@ -57,7 +57,7 @@ namespace MonoTests.System.Resources { // check ITRS supplied to GetValue method not actually used ResXDataNode originalNode, returnedNode; originalNode = GetNodeFileRefToSerializable ("ser.bbb",true); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); object val = returnedNode.GetValue (new AlwaysReturnSerializableSubClassTypeResolutionService ()); @@ -70,7 +70,7 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); object obj = returnedNode.GetValue ((AssemblyName[]) null); @@ -85,7 +85,7 @@ namespace MonoTests.System.Resources { AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); object obj = returnedNode.GetValue (assemblyNames); @@ -147,7 +147,7 @@ namespace MonoTests.System.Resources { Assert.IsNotNull (ico, "#A1"); Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); } - + [Test] public void ResXFileRefWrongAssemblyNamesOK () { @@ -161,7 +161,7 @@ namespace MonoTests.System.Resources { } #endregion - + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTypeNameTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTypeNameTests.cs index 15622bdf735..ad154a07183 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTypeNameTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefGetValueTypeNameTests.cs @@ -45,7 +45,7 @@ namespace MonoTests.System.Resources { AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string typeName = returnedNode.GetValueTypeName (assemblyNames); @@ -57,7 +57,7 @@ namespace MonoTests.System.Resources { ResXDataNode originalNode, returnedNode; originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string typeName = returnedNode.GetValueTypeName ((AssemblyName []) null); @@ -71,7 +71,7 @@ namespace MonoTests.System.Resources { // GetValueTypeName changes the output of the method ResXDataNode originalNode, returnedNode; originalNode = GetNodeFileRefToSerializable ("ser.bbb",true); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnSerializableSubClassTypeResolutionService ()); @@ -91,10 +91,30 @@ namespace MonoTests.System.Resources { Assert.AreEqual ((typeof (serializableSubClass)).AssemblyQualifiedName, returnedType, "#A1"); } + [Test] + public void IfTypeResolutionFailsReturnsOrigString() + { + ResXFileRef fileRef = new ResXFileRef ("afile.name", "a.type.name"); + ResXDataNode node = new ResXDataNode ("aname", fileRef); + + string returnedType = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual ("a.type.name", returnedType); + } + + [Test] + public void AttemptsTypeResolution () + { + ResXFileRef fileRef = new ResXFileRef ("afile.name", "System.String"); + ResXDataNode node = new ResXDataNode ("aname", fileRef); + + string returnedType = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual (typeof (string).AssemblyQualifiedName, returnedType); + } + #region Initial Exploratory Tests [Test] - public void ResXFileRefNullAssemblyNamesOK () + public void NullAssemblyNamesOK () { ResXDataNode node = GetNodeFileRefToIcon (); @@ -103,7 +123,7 @@ namespace MonoTests.System.Resources { } [Test] - public void ResXFileRefNullITypeResolutionServiceOK () + public void NullITypeResolutionServiceOK () { ResXDataNode node = GetNodeFileRefToIcon (); @@ -112,7 +132,7 @@ namespace MonoTests.System.Resources { } [Test] - public void ResXFileRefWrongITypeResolutionServiceOK () + public void WrongITypeResolutionServiceOK () { ResXDataNode node = GetNodeFileRefToIcon (); @@ -121,18 +141,17 @@ namespace MonoTests.System.Resources { } [Test] - public void ResXFileRefWrongAssemblyNamesOK () + public void WrongAssemblyNamesOK () { ResXDataNode node = GetNodeFileRefToIcon (); AssemblyName [] ass = new AssemblyName [1]; - ass [0] = new AssemblyName ("System.Design"); + ass [0] = new AssemblyName ("DummyAssembly"); string name = node.GetValueTypeName (ass); Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); } #endregion - } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefTests.cs deleted file mode 100644 index 1b36f8bcc29..00000000000 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeFileRefTests.cs +++ /dev/null @@ -1,466 +0,0 @@ -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// Copyright (c) 2012 Gary Barnett -// -// Authors: -// Gary Barnett - -#if NET_2_0 -using System; -using System.IO; -using System.Reflection; -using System.Drawing; -using System.Resources; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Collections; - -using NUnit.Framework; -using System.ComponentModel.Design; -using System.Runtime.Serialization.Formatters.Binary; - -namespace MonoTests.System.Resources { - [TestFixture] - public class ResXDataNodeFileRefTests : MonoTests.System.Windows.Forms.TestHelper { - string _tempDirectory; - string _otherTempDirectory; - - [Test, ExpectedException (typeof (NotImplementedException))] - public void GetValueITRSTouchedWhenNodeFromReader () - { - // for a node returned from ResXResourceReader with FileRef, - // check params supplied to GetValue method of ResXDataNode are touched - - ResXDataNode originalNode, returnedNode; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb",true); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - // raises error if touched - Icon ico = (Icon) returnedNode.GetValue (new ExceptionalTypeResolutionService ()); - - } - } - - [Test] - public void GetValueITRSNotUsedWhenNodeFromReader () - { - // for a node returend from reader with a FileRef, - // check ITRS supplied to GetValue method not actually used - - ResXDataNode originalNode, returnedNode; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb",true); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - object val = returnedNode.GetValue (new AlwaysReturnSerializableSubClassTypeResolutionService ()); - - Assert.IsNotInstanceOfType (typeof (serializableSubClass), val, "#A2"); - Assert.IsInstanceOfType (typeof (serializable), val, "#A3"); - } - } - - [Test, ExpectedException(typeof (TypeLoadException))] - public void CantGetValueWithOnlyFullNameAsType () - { - ResXDataNode originalNode, returnedNode; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - object obj = returnedNode.GetValue ((AssemblyName[]) null); - - } - } - - [Test, ExpectedException (typeof (TypeLoadException))] - public void CantGetValueWithOnlyFullNameAsTypeByProvidingAssemblyName () - { - ResXDataNode originalNode, returnedNode; - - string aName = "System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"; - AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - object obj = returnedNode.GetValue (assemblyNames); - } - } - - [Test] - public void CanGetStrongNameFromGetValueTypeNameWithOnlyFullNameAsTypeByProvidingAssemblyName () - { - ResXDataNode originalNode, returnedNode; - - string aName = "System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"; - AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - string typeName = returnedNode.GetValueTypeName (assemblyNames); - - Assert.AreEqual ("MonoTests.System.Resources.serializable, " + aName, typeName, "#A2"); - } - } - - public void CanGetValueTypeNameWithOnlyFullNameAsType () - { - ResXDataNode originalNode, returnedNode; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb", false); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - string typeName = returnedNode.GetValueTypeName ((AssemblyName []) null); - - Assert.AreEqual ((typeof (serializable)).FullName, typeName, "#A2"); - } - } - - [Test] - public void GetValueTypeNameITRSUsedWhenNodeFromReader () - { - // for a node returned from ResXResourceReader, check supplying params to - // GetValueTypeName changes the output of the method - - ResXDataNode originalNode, returnedNode; - - originalNode = GetNodeFileRefToSerializable ("ser.bbb",true); - - string fileName = GetResXFileWithNode (originalNode); - - using (ResXResourceReader reader = new ResXResourceReader (fileName)) { - reader.UseResXDataNodes = true; - - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - returnedNode = (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - - Assert.IsNotNull (returnedNode, "#A1"); - - string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnSerializableSubClassTypeResolutionService ()); - - Assert.AreEqual ((typeof (serializableSubClass)).AssemblyQualifiedName, returnedType, "#A2"); - } - } - - [Test] - public void GetValueTypeNameITRSUsedWhenNodeCreatedNew () - { - // check supplying params GetValueTypeName of the - // UseResXDataNode does the output of the method for an instance - // initialised manually - - ResXDataNode node; - - node = GetNodeFileRefToSerializable ("ser.bbb",true); - - string returnedType = node.GetValueTypeName (new AlwaysReturnSerializableSubClassTypeResolutionService ()); - - Assert.AreEqual ((typeof (serializableSubClass)).AssemblyQualifiedName, returnedType, "#A1"); - } - - [Test, ExpectedException (typeof (NotImplementedException))] - public void GetValueITRSTouchedWhenNodeCreatedNew () - { - // check supplyied params to GetValue of the ResXDataNode are touched for - // an instance initialised by me - - ResXDataNode node; - - node = GetNodeFileRefToSerializable ("ser.bbb",true); - - //raises exception if param touched - Object obj = node.GetValue (new ExceptionalTypeResolutionService ()); - } - - [Test] - public void GetValueITRSNotUsedWhenNodeCreatedNew () - { - // check supplyied params to GetValue of the ResXDataNode are not used for - // an instance initialised by me - - ResXDataNode node; - - node = GetNodeFileRefToSerializable ("ser.bbb",true); - - object val = node.GetValue (new AlwaysReturnSerializableSubClassTypeResolutionService ()); - - Assert.IsNotInstanceOfType (typeof (serializableSubClass), val, "#A1"); - Assert.IsInstanceOfType (typeof (serializable), val, "#A2"); - } - - #region Initial Exploratory Tests - - [Test] - public void GetValueResXFileRefNullAssemblyNames () - { - ResXDataNode node = GetNodeFileRefToIcon (); - - Object ico = node.GetValue ((AssemblyName []) null); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void GetValueResXFileRefNullITypeResolutionService () - { - ResXDataNode node = GetNodeFileRefToIcon (); - - Object ico = node.GetValue ((ITypeResolutionService) null); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void GetValueTypeNameResXFileRefNullAssemblyNames () - { - ResXDataNode node = GetNodeFileRefToIcon (); - - string name = node.GetValueTypeName ((AssemblyName []) null); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } - - [Test] - public void GetValueTypeNameResXFileRefNullITypeResolutionService () - { - - ResXDataNode node = GetNodeFileRefToIcon (); - - string name = node.GetValueTypeName ((ITypeResolutionService) null); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } - - [Test] - public void GetValueTypeNameResXFileRefWrongITypeResolutionService () - { - - ResXDataNode node = GetNodeFileRefToIcon (); - - string name = node.GetValueTypeName (new DummyTypeResolutionService ()); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } - - [Test] - public void GetValueResXFileRefWrongITypeResolutionService () - { - ResXDataNode node = GetNodeFileRefToIcon (); - - Object ico = node.GetValue (new DummyTypeResolutionService ()); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void GetValueTypeNameResXFileRefWrongAssemblyNames () - { - - ResXDataNode node = GetNodeFileRefToIcon (); - - AssemblyName [] ass = new AssemblyName [1]; - - ass [0] = new AssemblyName ("System.Design"); - - string name = node.GetValueTypeName (ass); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } - - [Test] - public void GetValueResXFileRefWrongAssemblyNames () - { - ResXDataNode node = GetNodeFileRefToIcon (); - - AssemblyName [] ass = new AssemblyName [1]; - - ass [0] = new AssemblyName ("System.Design"); - - Object ico = node.GetValue (ass); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - #endregion - - [TearDown] - protected override void TearDown () - { - //teardown - if (Directory.Exists (_tempDirectory)) - Directory.Delete (_tempDirectory, true); - - base.TearDown (); - } - - string GetResXFileWithNode (ResXDataNode node) - { - string fileName; - - _tempDirectory = Path.Combine (Path.GetTempPath (), "ResXDataNodeTest"); - _otherTempDirectory = Path.Combine (_tempDirectory, "in"); - if (!Directory.Exists (_otherTempDirectory)) { - Directory.CreateDirectory (_otherTempDirectory); - } - - fileName = Path.Combine (_tempDirectory, "myresx.resx"); - - using (ResXResourceWriter writer = new ResXResourceWriter (fileName)) { - writer.AddResource (node); - } - - return fileName; - } - - ResXDataNode GetNodeFileRefToSerializable (string filename, bool assemblyQualifiedName) - { - _tempDirectory = Path.Combine (Path.GetTempPath (), "ResXDataNodeTest"); - _otherTempDirectory = Path.Combine (_tempDirectory, "in"); - if (!Directory.Exists (_otherTempDirectory)) { - Directory.CreateDirectory (_otherTempDirectory); - } - - string refFile = Path.Combine (_tempDirectory, filename); - - serializable ser = new serializable ("name", "value"); - - WriteToFile (refFile, ser); - - string typeName; - - if (assemblyQualifiedName) - typeName = typeof (serializable).AssemblyQualifiedName; - else - typeName = typeof (serializable).FullName; - - ResXFileRef fileRef = new ResXFileRef (refFile, typeName); - - ResXDataNode node = new ResXDataNode ("test", fileRef); - - return node; - } - - private static void WriteToFile (string filepath, serializable ser) - { - - Stream stream = File.Open (filepath, FileMode.Create); - BinaryFormatter bFormatter = new BinaryFormatter (); - bFormatter.Serialize (stream, ser); - stream.Close (); - } - - ResXDataNode GetNodeFileRefToIcon () - { - _tempDirectory = Path.Combine (Path.GetTempPath (), "ResXDataNodeTest"); - _otherTempDirectory = Path.Combine (_tempDirectory, "in"); - if (!Directory.Exists (_otherTempDirectory)) { - Directory.CreateDirectory (_otherTempDirectory); - } - - string refFile = Path.Combine (_tempDirectory, "32x32.ico"); - WriteEmbeddedResource ("32x32.ico", refFile); - - ResXFileRef fileRef = new ResXFileRef (refFile, typeof (Icon).AssemblyQualifiedName); - ResXDataNode node = new ResXDataNode ("test", fileRef); - - return node; - } - - private static void WriteEmbeddedResource (string name, string filename) - { - const int size = 512; - byte [] buffer = new byte [size]; - int count = 0; - - Stream input = typeof (ResXDataNodeTest).Assembly. - GetManifestResourceStream (name); - Stream output = File.Open (filename, FileMode.Create); - - try { - while ((count = input.Read (buffer, 0, size)) > 0) { - output.Write (buffer, 0, count); - } - } finally { - output.Close (); - } - } - - } - -} -#endif
\ No newline at end of file diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerialisedGetValueTypeNameTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerialisedGetValueTypeNameTests.cs index 31828e35216..1d1ce8ce18d 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerialisedGetValueTypeNameTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerialisedGetValueTypeNameTests.cs @@ -41,7 +41,7 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnSerializableSubClassTypeResolutionService ()); @@ -55,7 +55,7 @@ namespace MonoTests.System.Resources { // retrieving the value first time and returns this same value ignoring any new ITRS passed thereafter ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string defaultType = returnedNode.GetValueTypeName ((ITypeResolutionService) null); @@ -97,7 +97,7 @@ namespace MonoTests.System.Resources { // check that first call to GetValue sets the type for GetValueTypeName ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); // get value passing no params @@ -110,6 +110,84 @@ namespace MonoTests.System.Resources { Assert.AreNotEqual ((typeof (serializableSubClass)).AssemblyQualifiedName, newType, "#A4"); Assert.AreEqual ((typeof (serializable)).AssemblyQualifiedName, newType, "#A5"); } + + [Test] + public void SoapFormattedObject () + { + ResXDataNode node = GetNodeFromResXReader (serializedResXSOAP); + + Assert.IsNotNull (node, "#A1"); + string name = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual (typeof (serializable).AssemblyQualifiedName, name, "#A2"); + } + + [Test] + public void DeserializationErrorReturnsObjectType () + { + ResXDataNode node = GetNodeFromResXReader (serializedResXCorruped); + Assert.IsNotNull (node, "#A1"); + string type = node.GetValueTypeName ((AssemblyName []) null); + + Assert.AreEqual (typeof (object).AssemblyQualifiedName,type, "#A2"); + } + + static string serializedResXCorruped = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""test"" mimetype=""application/x-microsoft.net.object.binary.base64""> + <value> + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +</value> + </data> +</root>"; + + static string serializedResXSOAP = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""test"" mimetype=""application/x-microsoft.net.object.soap.base64""> + <value> + PFNPQVAtRU5WOkVudmVsb3BlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2Ui + IHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOlNPQVAtRU5DPSJodHRwOi8vc2No + ZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5nLyIgeG1sbnM6U09BUC1FTlY9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAu + b3JnL3NvYXAvZW52ZWxvcGUvIiB4bWxuczpjbHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vc29hcC9lbmNvZGlu + Zy9jbHIvMS4wIiBTT0FQLUVOVjplbmNvZGluZ1N0eWxlPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29k + aW5nLyI+DQo8U09BUC1FTlY6Qm9keT4NCjxhMTpzZXJpYWxpemFibGUgaWQ9InJlZi0xIiB4bWxuczphMT0iaHR0cDovL3Nj + aGVtYXMubWljcm9zb2Z0LmNvbS9jbHIvbnNhc3NlbS9Nb25vVGVzdHMuU3lzdGVtLlJlc291cmNlcy9TeXN0ZW0uV2luZG93 + cy5Gb3Jtc190ZXN0X25ldF8yXzAlMkMlMjBWZXJzaW9uJTNEMC4wLjAuMCUyQyUyMEN1bHR1cmUlM0RuZXV0cmFsJTJDJTIw + UHVibGljS2V5VG9rZW4lM0RudWxsIj4NCjxzZXJuYW1lIGlkPSJyZWYtMyI+YW5hbWU8L3Nlcm5hbWU+DQo8c2VydmFsdWUg + aWQ9InJlZi00Ij5hdmFsdWU8L3NlcnZhbHVlPg0KPC9hMTpzZXJpYWxpemFibGU+DQo8L1NPQVAtRU5WOkJvZHk+DQo8L1NP + QVAtRU5WOkVudmVsb3BlPg== + </value> + </data> +</root>"; } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerializedGetValueTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerializedGetValueTests.cs index 9f544c9dba6..aee26c6523c 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerializedGetValueTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeSerializedGetValueTests.cs @@ -29,6 +29,10 @@ using System.Resources; using System.Collections; using NUnit.Framework; using System.ComponentModel.Design; +using System.Runtime.Serialization.Formatters.Soap; +using System.Reflection; +using System.Text; +using System.Runtime.Serialization; namespace MonoTests.System.Resources { [TestFixture] @@ -38,7 +42,7 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); @@ -56,7 +60,7 @@ namespace MonoTests.System.Resources { { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); @@ -74,7 +78,7 @@ namespace MonoTests.System.Resources { originalNode = GetNodeEmdeddedSerializable (); returnedNode = GetNodeFromResXReader (originalNode); - + Assert.IsNotNull (returnedNode, "#A1"); object val = returnedNode.GetValue (new AlwaysReturnSerializableSubClassTypeResolutionService ()); Assert.IsInstanceOfType (typeof (serializableSubClass), val, "#A2"); @@ -95,7 +99,7 @@ namespace MonoTests.System.Resources { ResXDataNode originalNode, returnedNode; originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); //get value type passing params @@ -121,32 +125,95 @@ namespace MonoTests.System.Resources { Assert.IsInstanceOfType (typeof (serializable), obj, "#A1"); } + [Test, ExpectedException (typeof (SerializationException))] + public void DeserializationError () + { + ResXDataNode node = GetNodeFromResXReader (serializedResXCorruped); + Assert.IsNotNull (node, "#A1"); + object val = node.GetValue ((AssemblyName []) null); + } + + static string serializedResXCorruped = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""test"" mimetype=""application/x-microsoft.net.object.binary.base64""> + <value> + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +</value> + </data> +</root>"; + + static string soapSerializedSerializable = +@"<SOAP-ENV:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:clr=""http://schemas.microsoft.com/soap/encoding/clr/1.0"" SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""> +<SOAP-ENV:Body> +<a1:serializable id=""ref-1"" xmlns:a1=""http://schemas.microsoft.com/clr/nsassem/MonoTests.System.Resources/System.Windows.Forms_test_net_2_0%2C%20Version%3D0.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull""> +<sername id=""ref-3"">aname</sername> +<servalue id=""ref-4"">avalue</servalue> +</a1:serializable> +</SOAP-ENV:Body> +</SOAP-ENV:Envelope>"; + + static string serializedResXSOAP = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""test"" mimetype=""application/x-microsoft.net.object.soap.base64""> + <value> + PFNPQVAtRU5WOkVudmVsb3BlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2Ui + IHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOlNPQVAtRU5DPSJodHRwOi8vc2No + ZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5nLyIgeG1sbnM6U09BUC1FTlY9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAu + b3JnL3NvYXAvZW52ZWxvcGUvIiB4bWxuczpjbHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vc29hcC9lbmNvZGlu + Zy9jbHIvMS4wIiBTT0FQLUVOVjplbmNvZGluZ1N0eWxlPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29k + aW5nLyI+DQo8U09BUC1FTlY6Qm9keT4NCjxhMTpzZXJpYWxpemFibGUgaWQ9InJlZi0xIiB4bWxuczphMT0iaHR0cDovL3Nj + aGVtYXMubWljcm9zb2Z0LmNvbS9jbHIvbnNhc3NlbS9Nb25vVGVzdHMuU3lzdGVtLlJlc291cmNlcy9TeXN0ZW0uV2luZG93 + cy5Gb3Jtc190ZXN0X25ldF8yXzAlMkMlMjBWZXJzaW9uJTNEMC4wLjAuMCUyQyUyMEN1bHR1cmUlM0RuZXV0cmFsJTJDJTIw + UHVibGljS2V5VG9rZW4lM0RudWxsIj4NCjxzZXJuYW1lIGlkPSJyZWYtMyI+YW5hbWU8L3Nlcm5hbWU+DQo8c2VydmFsdWUg + aWQ9InJlZi00Ij5hdmFsdWU8L3NlcnZhbHVlPg0KPC9hMTpzZXJpYWxpemFibGU+DQo8L1NPQVAtRU5WOkJvZHk+DQo8L1NP + QVAtRU5WOkVudmVsb3BlPg== + </value> + </data> +</root>"; + [Test] - public void ChangesToReturnedObjectNotLaterWrittenBack () - { - ResXDataNode originalNode, returnedNode, finalNode; - - originalNode = GetNodeEmdeddedSerializable (); - returnedNode = GetNodeFromResXReader (originalNode); - - Assert.IsNotNull (returnedNode, "#A1"); - object val = returnedNode.GetValue ((ITypeResolutionService) null); - Assert.IsInstanceOfType (typeof (serializable), val, "#A2"); - - serializable ser = (serializable) val; - - Assert.AreEqual ("testName", ser.name, "A3"); - ser.name = "changed"; - finalNode = GetNodeFromResXReader (returnedNode); - - Assert.IsNotNull (finalNode, "#A4"); - object finalVal = finalNode.GetValue ((ITypeResolutionService) null); - Assert.IsInstanceOfType (typeof (serializable), finalVal, "#A5"); - - serializable finalSer = (serializable) finalVal; - // would be "changed" if written back - Assert.AreEqual ("testName", finalSer.name, "A6"); - } + public void SoapFormattedObject () + { + ResXDataNode node = GetNodeFromResXReader (serializedResXSOAP); + + Assert.IsNotNull (node, "#A1"); + object val = node.GetValue ((AssemblyName []) null); + Assert.IsInstanceOfType (typeof (serializable), val, "#A2"); + serializable ser = (serializable) val; + Assert.AreEqual ("aname", ser.name, "#A3"); + Assert.AreEqual ("avalue", ser.value, "#A4"); + } + } } #endif diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTest.cs index 2dfcf932117..204df74ee46 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTest.cs @@ -22,7 +22,7 @@ // ResXFileRefTest.cs: Unit Tests for ResXFileRef. // // Authors: -// Andreia Gaita (avidigal@novell.com) +// Andreia Gaita (avidigal@novell.com) // Gary Barnett @@ -56,15 +56,15 @@ namespace MonoTests.System.Resources { [ExpectedException (typeof (ArgumentNullException))] public void ConstructorEx2A () { - ResXDataNode d = new ResXDataNode (null, new ResXFileRef ("filename", "typename")); + ResXDataNode d = new ResXDataNode (null, new ResXFileRef ("filename", "typename")); } - [Test] - [ExpectedException (typeof (ArgumentNullException))] - public void ConstructorEx2B () - { - ResXDataNode d = new ResXDataNode ("aname", (ResXFileRef) null); - } + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void ConstructorEx2B () + { + ResXDataNode d = new ResXDataNode ("aname", (ResXFileRef) null); + } [Test] [ExpectedException (typeof (ArgumentException))] @@ -94,55 +94,52 @@ namespace MonoTests.System.Resources { ResXDataNode d = new ResXDataNode ("name", new notserializable ()); } - [Test] - public void Name () - { - ResXDataNode node = new ResXDataNode ("startname", (object) null); - Assert.AreEqual ("startname", node.Name, "#A1"); - node.Name = "newname"; - Assert.AreEqual ("newname", node.Name, "#A2"); - } - - [Test, ExpectedException (typeof (ArgumentNullException))] - public void NameCantBeNull () - { - ResXDataNode node = new ResXDataNode ("startname", (object) null); - node.Name = null; - } - - [Test, ExpectedException (typeof (ArgumentException))] - public void NameCantBeEmpty () - { - ResXDataNode node = new ResXDataNode ("name", (object) null); - node.Name = ""; - } - - //FIXME: according to docs, if no name assigned .Name should return null - //where do the ResXDataNodes with no name come from? ResXResourceReader? - - [Test] - public void FileRef () - { - ResXFileRef fileRef = new ResXFileRef ("fileName", "Type.Name"); - ResXDataNode node = new ResXDataNode ("name", fileRef); - Assert.AreEqual (fileRef, node.FileRef, "#A1"); - } - - [Test] - public void Comment () - { - ResXDataNode node = new ResXDataNode ("name", (object) null); - node.Comment = "acomment"; - Assert.AreEqual ("acomment", node.Comment, "#A1"); - } - - [Test] - public void CommentNullToStringEmpty () - { - ResXDataNode node = new ResXDataNode ("name", (object) null); - node.Comment = null; - Assert.AreEqual (String.Empty, node.Comment, "#A1"); - } + [Test] + public void Name () + { + ResXDataNode node = new ResXDataNode ("startname", (object) null); + Assert.AreEqual ("startname", node.Name, "#A1"); + node.Name = "newname"; + Assert.AreEqual ("newname", node.Name, "#A2"); + } + + [Test, ExpectedException (typeof (ArgumentNullException))] + public void NameCantBeNull () + { + ResXDataNode node = new ResXDataNode ("startname", (object) null); + node.Name = null; + } + + [Test, ExpectedException (typeof (ArgumentException))] + public void NameCantBeEmpty () + { + ResXDataNode node = new ResXDataNode ("name", (object) null); + node.Name = ""; + } + + [Test] + public void FileRef () + { + ResXFileRef fileRef = new ResXFileRef ("fileName", "Type.Name"); + ResXDataNode node = new ResXDataNode ("name", fileRef); + Assert.AreEqual (fileRef, node.FileRef, "#A1"); + } + + [Test] + public void Comment () + { + ResXDataNode node = new ResXDataNode ("name", (object) null); + node.Comment = "acomment"; + Assert.AreEqual ("acomment", node.Comment, "#A1"); + } + + [Test] + public void CommentNullToStringEmpty () + { + ResXDataNode node = new ResXDataNode ("name", (object) null); + node.Comment = null; + Assert.AreEqual (String.Empty, node.Comment, "#A1"); + } [Test] public void WriteRead1 () @@ -179,11 +176,31 @@ namespace MonoTests.System.Resources { public void ConstructorResXFileRef() { ResXDataNode node = GetNodeFileRefToIcon (); - Assert.IsNotNull (node.FileRef, "#A1"); + Assert.IsNotNull (node.FileRef, "#A1"); Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, node.FileRef.TypeName, "#A2"); Assert.AreEqual ("test", node.Name, "#A3"); } - + + [Test] + public void NullObjectWrittenToResXOK () + { + ResXDataNode node = new ResXDataNode ("aname", (object) null); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.IsNotNull (returnedNode, "#A1"); + Assert.IsNull (returnedNode.GetValue ((AssemblyName []) null), "#A2"); + } + + [Test] + public void NullObjectReturnedFromResXGetValueTypeNameReturnsObject () + { + ResXDataNode node = new ResXDataNode ("aname", (object) null); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.IsNotNull (returnedNode, "#A1"); + Assert.IsNull (returnedNode.GetValue ((AssemblyName []) null), "#A2"); + string type = returnedNode.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual (typeof (object).AssemblyQualifiedName, type, "#A3"); + } + [Test] public void DoesNotRequireResXFileToBeOpen_Serializable () { @@ -370,6 +387,26 @@ namespace MonoTests.System.Resources { rr.Close (); } + [Test] + public void BasePathSetOnResXResourceReaderDoesAffectResXDataNode () + { + ResXFileRef fileRef = new ResXFileRef ("file.name", "type.name"); + ResXDataNode node = new ResXDataNode("anode", fileRef); + string resXFile = GetResXFileWithNode (node, "afilename.xxx"); + + using (ResXResourceReader rr = new ResXResourceReader (resXFile)) { + rr.BasePath = "c:\\"; + rr.UseResXDataNodes = true; + IDictionaryEnumerator en = rr.GetEnumerator (); + en.MoveNext (); + + ResXDataNode returnedNode = ((DictionaryEntry) en.Current).Value as ResXDataNode; + + Assert.IsNotNull (node, "#A1"); + Assert.AreEqual ("c:\\file.name", returnedNode.FileRef.FileName, "#A2"); + } + } + [TearDown] protected override void TearDown () { @@ -420,111 +457,7 @@ namespace MonoTests.System.Resources { static string convertableResXWithoutAssemblyName = @"<?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> diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTests.cs index f1e0cd1ff55..5cbbb6cb331 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTests.cs @@ -36,101 +36,101 @@ namespace MonoTests.System.Resources { [TestFixture] public class ResXDataNodeTypeConverterGetValueTests : ResourcesTestHelper { - [Test] - public void ITRSNotUsedWhenCreatedNew () - { - // check supplying params to GetValue of the UseResXDataNode does not change the output - // of the method for an instance created manually - ResXDataNode node; - node = new ResXDataNode ("along", 34L); - - object obj = node.GetValue (new AlwaysReturnIntTypeResolutionService ()); - Assert.IsInstanceOfType (typeof (long), obj, "#A1"); - } - - [Test] - public void ITRSUsedEachTimeWithNodeFromReader () - { - // check GetValue uses ITRS param each time its called for a node from a ResXResourceReader - // for an object stored by means of a typeconverter, - ResXDataNode returnedNode, originalNode; - originalNode = new ResXDataNode ("aNumber", 23L); - returnedNode = GetNodeFromResXReader (originalNode); - - Assert.IsNotNull (returnedNode, "#A1"); - - object newVal = returnedNode.GetValue (new AlwaysReturnIntTypeResolutionService ()); - Assert.AreEqual (typeof (int).AssemblyQualifiedName, newVal.GetType ().AssemblyQualifiedName, "#A2"); - - object origVal = returnedNode.GetValue ((ITypeResolutionService) null); - Assert.AreEqual (typeof (long).AssemblyQualifiedName, origVal.GetType ().AssemblyQualifiedName, "#A3"); - } - - [Test, ExpectedException (typeof (NotImplementedException))] - public void GetValueParamIsTouchedWhenEmbeddedReturnedFromResXResourceReader () - { - // after running the enumerator of ResXResourceReader with UseResXDataNodes set - // to true, check params supplied to GetValue method - // of ResXDataNode are used to deserialise - // for now just throwing exception in param object to ensure its accessed - ResXDataNode originalNode, returnedNode; + [Test] + public void ITRSNotUsedWhenCreatedNew () + { + // check supplying params to GetValue of the UseResXDataNode does not change the output + // of the method for an instance created manually + ResXDataNode node; + node = new ResXDataNode ("along", 34L); + + object obj = node.GetValue (new AlwaysReturnIntTypeResolutionService ()); + Assert.IsInstanceOfType (typeof (long), obj, "#A1"); + } + + [Test] + public void ITRSUsedEachTimeWithNodeFromReader () + { + // check GetValue uses ITRS param each time its called for a node from a ResXResourceReader + // for an object stored by means of a typeconverter, + ResXDataNode returnedNode, originalNode; + originalNode = new ResXDataNode ("aNumber", 23L); + returnedNode = GetNodeFromResXReader (originalNode); + + Assert.IsNotNull (returnedNode, "#A1"); + + object newVal = returnedNode.GetValue (new AlwaysReturnIntTypeResolutionService ()); + Assert.AreEqual (typeof (int).AssemblyQualifiedName, newVal.GetType ().AssemblyQualifiedName, "#A2"); + + object origVal = returnedNode.GetValue ((ITypeResolutionService) null); + Assert.AreEqual (typeof (long).AssemblyQualifiedName, origVal.GetType ().AssemblyQualifiedName, "#A3"); + } + + [Test, ExpectedException (typeof (NotImplementedException))] + public void GetValueParamIsTouchedWhenEmbeddedReturnedFromResXResourceReader () + { + // after running the enumerator of ResXResourceReader with UseResXDataNodes set + // to true, check params supplied to GetValue method + // of ResXDataNode are used to deserialise + // for now just throwing exception in param object to ensure its accessed + ResXDataNode originalNode, returnedNode; - originalNode = GetNodeEmdeddedIcon (); - returnedNode = GetNodeFromResXReader (originalNode); - - Assert.IsNotNull (returnedNode, "#A1"); - // should raise error - Icon ico = (Icon)returnedNode.GetValue (new ExceptionalTypeResolutionService ()); - } - - #region initial - - [Test] - public void NullAssemblyNamesOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); - - Object ico = node.GetValue ((AssemblyName []) null); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void NullITypeResolutionServiceOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); - - Object ico = node.GetValue ((ITypeResolutionService) null); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void WrongITypeResolutionServiceOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); - - Object ico = node.GetValue (new DummyTypeResolutionService ()); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - [Test] - public void WrongAssemblyNamesOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); - AssemblyName [] ass = new AssemblyName [1]; - - ass [0] = new AssemblyName ("System.Design"); - - Object ico = node.GetValue (ass); - Assert.IsNotNull (ico, "#A1"); - Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); - } - - #endregion - - } + originalNode = GetNodeEmdeddedIcon (); + returnedNode = GetNodeFromResXReader (originalNode); + + Assert.IsNotNull (returnedNode, "#A1"); + // should raise error + Icon ico = (Icon)returnedNode.GetValue (new ExceptionalTypeResolutionService ()); + } + + #region initial + + [Test] + public void NullAssemblyNamesOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); + + Object ico = node.GetValue ((AssemblyName []) null); + Assert.IsNotNull (ico, "#A1"); + Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); + } + + [Test] + public void NullITypeResolutionServiceOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); + + Object ico = node.GetValue ((ITypeResolutionService) null); + Assert.IsNotNull (ico, "#A1"); + Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); + } + + [Test] + public void WrongITypeResolutionServiceOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); + + Object ico = node.GetValue (new DummyTypeResolutionService ()); + Assert.IsNotNull (ico, "#A1"); + Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); + } + + [Test] + public void WrongAssemblyNamesOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); + AssemblyName [] ass = new AssemblyName [1]; + + ass [0] = new AssemblyName ("System.Design"); + + Object ico = node.GetValue (ass); + Assert.IsNotNull (ico, "#A1"); + Assert.IsInstanceOfType (typeof (Icon), ico, "#A2"); + } + + #endregion + + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTypeNameTests.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTypeNameTests.cs index 36e13e73474..d94478dff74 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTypeNameTests.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeTypeConverterGetValueTypeNameTests.cs @@ -37,13 +37,13 @@ namespace MonoTests.System.Resources [TestFixture] public class ResXDataNodeTypeConverterGetValueTypeNameTests : ResourcesTestHelper { [Test] - public void ITRSUsedWithNodeFromReader () + public void ITRSUsedWithNodeFromReader () { // for node returned from ResXResourceReader for an object stored by means of a typeconverter, // check supplying ITRS changes output of method ResXDataNode returnedNode, originalNode; originalNode = new ResXDataNode ("aNumber", 23L); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string returnedType = returnedNode.GetValueTypeName (new AlwaysReturnIntTypeResolutionService ()); @@ -51,13 +51,13 @@ namespace MonoTests.System.Resources } [Test] - public void ITRSUsedEachTimeWhenNodeFromReader () + public void ITRSUsedEachTimeWhenNodeFromReader () { // for node returned from ResXResourceReader for an object stored by means of a typeconverter, // check supplied ITRS changes output each time ResXDataNode returnedNode, originalNode; originalNode = new ResXDataNode ("aNumber", 23L); - returnedNode = GetNodeFromResXReader (originalNode); + returnedNode = GetNodeFromResXReader (originalNode); Assert.IsNotNull (returnedNode, "#A1"); string newType = returnedNode.GetValueTypeName (new AlwaysReturnIntTypeResolutionService ()); @@ -68,7 +68,7 @@ namespace MonoTests.System.Resources } [Test] - public void ITRSNotUsedWhenNodeCreatedNew () + public void ITRSNotUsedWhenNodeCreatedNew () { // check supplying params to GetValueTypeName of the UseResXDataNode does not change the output // of the method for an instance created manually @@ -79,49 +79,49 @@ namespace MonoTests.System.Resources Assert.AreEqual ((typeof (long)).AssemblyQualifiedName, returnedType, "#A1"); } - #region initial + #region initial - [Test] - public void EmbeddedNullITypeResolutionServiceOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); + [Test] + public void EmbeddedNullITypeResolutionServiceOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); - string name = node.GetValueTypeName ((ITypeResolutionService) null); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } + string name = node.GetValueTypeName ((ITypeResolutionService) null); + Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); + } - [Test] - public void EmbeddedWrongITypeResolutionServiceOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); + [Test] + public void EmbeddedWrongITypeResolutionServiceOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); - string name = node.GetValueTypeName (new DummyTypeResolutionService ()); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } + string name = node.GetValueTypeName (new DummyTypeResolutionService ()); + Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); + } - [Test] - public void EmbeddedWrongAssemblyNamesOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); - AssemblyName [] ass = new AssemblyName [1]; + [Test] + public void EmbeddedWrongAssemblyNamesOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); + AssemblyName [] ass = new AssemblyName [1]; - ass [0] = new AssemblyName ("System.Design"); + ass [0] = new AssemblyName ("System.Design"); - string name = node.GetValueTypeName (ass); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } + string name = node.GetValueTypeName (ass); + Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); + } - [Test] - public void EmbeddedNullAssemblyNamesOK () - { - ResXDataNode node = GetNodeEmdeddedIcon (); + [Test] + public void EmbeddedNullAssemblyNamesOK () + { + ResXDataNode node = GetNodeEmdeddedIcon (); - string name = node.GetValueTypeName ((AssemblyName []) null); - Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); - } + string name = node.GetValueTypeName ((AssemblyName []) null); + Assert.AreEqual (typeof (Icon).AssemblyQualifiedName, name); + } - #endregion - } + #endregion + } } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeWriteBehavior.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeWriteBehavior.cs index 170e75a3af4..d9beddf8aa0 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeWriteBehavior.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXDataNodeWriteBehavior.cs @@ -29,150 +29,156 @@ using System.Reflection; using System.Resources; using System.Collections; using NUnit.Framework; +using System.Text; +using System.ComponentModel.Design; namespace MonoTests.System.Resources { - [TestFixture] - public class ResXDataNodeWriteBehavior : ResourcesTestHelper { - - [Test] - public void TypeConverterObjectNotLoaded () - { - string aName = "System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"; - AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; + [TestFixture] + public class ResXDataNodeWriteBehavior : ResourcesTestHelper { + + [Test] + public void TypeConverterObjectNotLoaded () + { + string aName = "System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"; + AssemblyName [] assemblyNames = new AssemblyName [] { new AssemblyName (aName) }; - ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); - Assert.IsNotNull (node, "#A1"); - // would cause error if object loaded - GetNodeFromResXReader (node); - } + ResXDataNode node = GetNodeFromResXReader (convertableResXWithoutAssemblyName); + Assert.IsNotNull (node, "#A1"); + // would cause error if object loaded + GetNodeFromResXReader (node); + } - [Test] - public void SerializedObjectNotLoaded () - { - ResXDataNode node = GetNodeFromResXReader (serializedResXCorruped); - Assert.IsNotNull (node, "#A1"); - // would cause error if object loaded - GetNodeFromResXReader (node); - } + [Test] + public void SerializedObjectNotLoaded () + { + ResXDataNode node = GetNodeFromResXReader (serializedResXCorruped); + Assert.IsNotNull (node, "#A1"); + // would cause error if object loaded + GetNodeFromResXReader (node); + } - [Test, ExpectedException (typeof (ArgumentException))] - public void FileRefIsLoaded () - { - // .NET does instantiate the encoding until the write, as exception not thrown until write - ResXDataNode node = GetNodeFromResXReader (fileRefResXCorrupted); - Assert.IsNotNull (node, "#A1"); - // would cause error if object loaded - GetNodeFromResXReader (node); - } + [Test, ExpectedException (typeof (ArgumentException))] + public void FileRefIsLoaded () + { + // .NET does instantiate the encoding until the write, as exception not thrown until write + ResXDataNode node = GetNodeFromResXReader (fileRefResXCorrupted); + Assert.IsNotNull (node, "#A1"); + // would cause error if object loaded + GetNodeFromResXReader (node); + } - static string fileRefResXCorrupted = + [Test] + public void ResXNullRef_WriteBack () + { + ResXDataNode node = new ResXDataNode ("NullRef", (object) null); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.AreEqual (null, returnedNode.GetValue ((AssemblyName[]) null), "#A1"); + ResXDataNode finalNode = GetNodeFromResXReader (returnedNode); + Assert.AreEqual (null, finalNode.GetValue ((AssemblyName []) null), "#A2"); + } + + [Test] + public void InvalidMimeType_WriteBack () + { + //FIXME: should check the ResX output to ensure mime type / value info still there + ResXDataNode node = GetNodeFromResXReader (serializedResXInvalidMimeType); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + + object obj = returnedNode.GetValue ((AssemblyName[]) null); + Assert.IsNull (obj, "#A1"); + } + + [Test] + public void BinTypeConverter_WriteBack () + { + MyBinType mb = new MyBinType ("contents"); + ResXDataNode node = new ResXDataNode ("aname", mb); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.IsNotNull (returnedNode, "#A1"); + ResXDataNode finalNode = GetNodeFromResXReader (returnedNode); + MyBinType returnedMb = (MyBinType) finalNode.GetValue ((AssemblyName []) null); + Assert.AreEqual ("contents", returnedMb.Value, "#A2"); + } + + [Test] + public void FileRefWithEncoding_WriteBack () + { + ResXFileRef fileRef = new ResXFileRef ("afilename", "A.Type.Name", Encoding.UTF7); + ResXDataNode node = GetNodeFromResXReader (new ResXDataNode ("aname", fileRef)); + Assert.IsNotNull (node, "#A1"); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.IsNotNull (returnedNode, "#A2"); + Assert.IsInstanceOfType (Encoding.UTF7.GetType (), returnedNode.FileRef.TextFileEncoding); + } + + [Test] + public void ByteArray_WriteBack () + { + byte [] testBytes = new byte [] { 1,2,3,4,5,6,7,8,9,10 }; + ResXDataNode node = new ResXDataNode ("aname", testBytes); + ResXDataNode returnedNode = GetNodeFromResXReader (node); + Assert.IsNotNull (returnedNode, "#A1"); + Assert.AreEqual (testBytes, returnedNode.GetValue ((AssemblyName []) null), "#A2"); + ResXDataNode finalNode = GetNodeFromResXReader (returnedNode); + Assert.IsNotNull (finalNode,"#A3"); + Assert.AreEqual (testBytes, finalNode.GetValue ((AssemblyName []) null), "#A4"); + } + + [Test] + public void BasePathSetOnResXReaderAffectsFileRef_WriteBack () + { + ResXDataNode returnedNode; + StringWriter sw = new StringWriter (); + sw.Write (fileRefResX); + + StringReader sr = new StringReader (sw.GetStringBuilder ().ToString ()); + + using (ResXResourceReader reader = new ResXResourceReader (sr)) { + reader.UseResXDataNodes = true; + reader.BasePath = "c:\\"; + IDictionaryEnumerator enumerator = reader.GetEnumerator (); + enumerator.MoveNext (); + + ResXDataNode node = ((DictionaryEntry) enumerator.Current).Value as ResXDataNode; + Assert.IsNotNull (node, "#A1"); + Assert.AreEqual ("c:\\file.name", node.FileRef.FileName, "#A2"); + returnedNode = GetNodeFromResXReader (node); + } + + Assert.AreEqual ("c:\\file.name", returnedNode.FileRef.FileName, "#A3"); + } + + [Test] + public void SerializedChangesToReturnedObjectNotLaterWrittenBack () + { + ResXDataNode originalNode, returnedNode, finalNode; + + originalNode = GetNodeEmdeddedSerializable (); + returnedNode = GetNodeFromResXReader (originalNode); + + Assert.IsNotNull (returnedNode, "#A1"); + object val = returnedNode.GetValue ((ITypeResolutionService) null); + Assert.IsInstanceOfType (typeof (serializable), val, "#A2"); + + serializable ser = (serializable) val; + + Assert.AreEqual ("testName", ser.name, "A3"); + ser.name = "changed"; + finalNode = GetNodeFromResXReader (returnedNode); + + Assert.IsNotNull (finalNode, "#A4"); + object finalVal = finalNode.GetValue ((ITypeResolutionService) null); + Assert.IsInstanceOfType (typeof (serializable), finalVal, "#A5"); + + serializable finalSer = (serializable) finalVal; + // would be "changed" if written back + Assert.AreEqual ("testName", finalSer.name, "A6"); + } + + + static string fileRefResX = @"<?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> @@ -186,249 +192,89 @@ namespace MonoTests.System.Resources { <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias=""System.Windows.Forms"" name=""System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" /> + <data name=""anode"" type=""System.Resources.ResXFileRef, System.Windows.Forms""> + <value>file.name;type.name</value> + </data> +</root>"; + + static string fileRefResXCorrupted = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <assembly alias=""System.Windows.Forms"" name=""System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" /> <data name=""test"" type=""System.Resources.ResXFileRef, System.Windows.Forms""> - <value>.\somethingthatdoesntexist.txt;System.String, System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;AValidCultureStringThisIsNot</value> + <value>.\somethingthatdoesntexist.txt;System.String, System.Windows.Forms_test_net_2_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;AValidCultureStringThisIsNot</value> </data> </root>"; - static string serializedResXCorruped = + static string serializedResXCorruped = @"<?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> + <value>text/microsoft-resx</value> </resheader> <resheader name=""version""> - <value>2.0</value> + <value>2.0</value> </resheader> <resheader name=""reader""> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name=""writer""> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name=""test"" mimetype=""application/x-microsoft.net.object.binary.base64""> - <value> - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + <value> + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA </value> </data> </root>"; - static string convertableResXWithoutAssemblyName = + static string serializedResXInvalidMimeType = @"<?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. + + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""test"" mimetype=""application/xxxx""> + <value> + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +</value> + </data> +</root>"; - 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> + static string convertableResXWithoutAssemblyName = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <resheader name=""resmimetype""> <value>text/microsoft-resx</value> </resheader> diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXResourceReaderTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXResourceReaderTest.cs index 837ed341632..13eab8670b5 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXResourceReaderTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResXResourceReaderTest.cs @@ -19,8 +19,7 @@ using System.Xml; using NUnit.Framework; using System.Reflection; -namespace MonoTests.System.Resources -{ +namespace MonoTests.System.Resources { [TestFixture] public class ResXResourceReaderTest : MonoTests.System.Windows.Forms.TestHelper { @@ -1301,6 +1300,72 @@ namespace MonoTests.System.Resources } } + static string resXWithEmptyName = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""""> + <value>a resource with no name</value> + </data> +</root>"; + + static string resxWithNullRef = +@"<?xml version=""1.0"" encoding=""utf-8""?> +<root> + <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name=""writer""> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name=""NullRef"" type=""System.Resources.ResXNullRef, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089""> + <value></value> + </data> +</root>"; + + [Test] + public void ResName_Empty () + { + using (StringReader sr = new StringReader (resXWithEmptyName)) { + using (ResXResourceReader r = new ResXResourceReader (sr)) { + IDictionaryEnumerator enumerator = r.GetEnumerator (); + enumerator.MoveNext (); + Assert.AreEqual ("", enumerator.Key, "#A1"); + Assert.AreEqual ("a resource with no name", (string) enumerator.Value, "#A2"); + } + } + } + + [Test] + public void ResXNullRef () + { + using (StringReader sr = new StringReader (resxWithNullRef)) { + using (ResXResourceReader r = new ResXResourceReader (sr)) { + IDictionaryEnumerator enumerator = r.GetEnumerator (); + enumerator.MoveNext (); + Assert.AreEqual ("NullRef", enumerator.Key, "#A1"); + Assert.IsNull (enumerator.Value, "#A2"); + } + } + } + [Test] public void ResValue () { diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResourcesTestHelper.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResourcesTestHelper.cs index be23d6c4554..338445114cb 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResourcesTestHelper.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ResourcesTestHelper.cs @@ -1,4 +1,28 @@ -#if NET_2_0 +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2012 Gary Barnett +// +// Authors: +// Gary Barnett + +#if NET_2_0 using System; using System.Collections.Generic; @@ -12,145 +36,145 @@ using System.Drawing; using System.Runtime.Serialization.Formatters.Binary; namespace MonoTests.System.Resources { - public class ResourcesTestHelper { - string tempFileWithIcon = null; - string tempFileWithSerializable = null; - - [SetUp] - protected virtual void SetUp () - { - - } - - protected ResXDataNode GetNodeFromResXReader (ResXDataNode node) - { - StringWriter sw = new StringWriter (); - using (ResXResourceWriter writer = new ResXResourceWriter (sw)) { - writer.AddResource (node); - } - - StringReader sr = new StringReader (sw.GetStringBuilder ().ToString ()); - - using (ResXResourceReader reader = new ResXResourceReader (sr)) { - reader.UseResXDataNodes = true; - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - - return ((DictionaryEntry) enumerator.Current).Value as ResXDataNode; - } - } - - protected ResXDataNode GetNodeFromResXReader (string contents) - { - StringReader sr = new StringReader (contents); - - using (ResXResourceReader reader = new ResXResourceReader (sr)) { - reader.UseResXDataNodes = true; - IDictionaryEnumerator enumerator = reader.GetEnumerator (); - enumerator.MoveNext (); - - return (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; - } - } - - public ResXDataNode GetNodeEmdeddedIcon () - { - Stream input = typeof (ResXDataNodeTest).Assembly. - GetManifestResourceStream ("32x32.ico"); - - Icon ico = new Icon (input); - ResXDataNode node = new ResXDataNode ("test", ico); - return node; - } - - public ResXDataNode GetNodeFileRefToIcon () - { - tempFileWithIcon = Path.GetTempFileName (); // remember to delete file in teardown - Path.ChangeExtension (tempFileWithIcon, "ico"); - - WriteEmbeddedResource ("32x32.ico", tempFileWithIcon); - ResXFileRef fileRef = new ResXFileRef (tempFileWithIcon, typeof (Icon).AssemblyQualifiedName); - ResXDataNode node = new ResXDataNode ("test", fileRef); - - return node; - } - - void WriteEmbeddedResource (string name, string filename) - { - const int size = 512; - byte [] buffer = new byte [size]; - int count = 0; - - Stream input = typeof (ResXDataNodeTest).Assembly. - GetManifestResourceStream (name); - Stream output = File.Open (filename, FileMode.Create); - - try { - while ((count = input.Read (buffer, 0, size)) > 0) { - output.Write (buffer, 0, count); - } - } finally { - output.Close (); - } - } - - public ResXDataNode GetNodeEmdeddedBytes1To10 () - { - byte [] someBytes = new byte [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - ResXDataNode node = new ResXDataNode ("test", someBytes); - return node; - } - - public ResXDataNode GetNodeEmdeddedSerializable () - { - serializable ser = new serializable ("testName", "testValue"); - ResXDataNode node = new ResXDataNode ("test", ser); - return node; - } - - public ResXDataNode GetNodeFileRefToSerializable (string filename, bool assemblyQualifiedName) - { - tempFileWithSerializable = Path.GetTempFileName (); // remember to delete file in teardown - serializable ser = new serializable ("name", "value"); - - SerializeToFile (tempFileWithSerializable, ser); - - string typeName; - - if (assemblyQualifiedName) - typeName = typeof (serializable).AssemblyQualifiedName; - else - typeName = typeof (serializable).FullName; - - ResXFileRef fileRef = new ResXFileRef (tempFileWithSerializable, typeName); - ResXDataNode node = new ResXDataNode ("test", fileRef); - - return node; - } - - static void SerializeToFile (string filepath, serializable ser) - { - Stream stream = File.Open (filepath, FileMode.Create); - BinaryFormatter bFormatter = new BinaryFormatter (); - bFormatter.Serialize (stream, ser); - stream.Close (); - } - - - [TearDown] - protected virtual void TearDown () - { - if (tempFileWithIcon != null) { - File.Delete (tempFileWithIcon); - tempFileWithIcon = null; - } - - if (tempFileWithSerializable != null) { - File.Delete (tempFileWithSerializable); - tempFileWithSerializable = null; - } - } - } + public class ResourcesTestHelper { + string tempFileWithIcon = null; + string tempFileWithSerializable = null; + + [SetUp] + protected virtual void SetUp () + { + + } + + protected ResXDataNode GetNodeFromResXReader (ResXDataNode node) + { + StringWriter sw = new StringWriter (); + using (ResXResourceWriter writer = new ResXResourceWriter (sw)) { + writer.AddResource (node); + } + + StringReader sr = new StringReader (sw.GetStringBuilder ().ToString ()); + + using (ResXResourceReader reader = new ResXResourceReader (sr)) { + reader.UseResXDataNodes = true; + IDictionaryEnumerator enumerator = reader.GetEnumerator (); + enumerator.MoveNext (); + + return ((DictionaryEntry) enumerator.Current).Value as ResXDataNode; + } + } + + protected ResXDataNode GetNodeFromResXReader (string contents) + { + StringReader sr = new StringReader (contents); + + using (ResXResourceReader reader = new ResXResourceReader (sr)) { + reader.UseResXDataNodes = true; + IDictionaryEnumerator enumerator = reader.GetEnumerator (); + enumerator.MoveNext (); + + return (ResXDataNode) ((DictionaryEntry) enumerator.Current).Value; + } + } + + public ResXDataNode GetNodeEmdeddedIcon () + { + Stream input = typeof (ResXDataNodeTest).Assembly. + GetManifestResourceStream ("32x32.ico"); + + Icon ico = new Icon (input); + ResXDataNode node = new ResXDataNode ("test", ico); + return node; + } + + public ResXDataNode GetNodeFileRefToIcon () + { + tempFileWithIcon = Path.GetTempFileName (); // remember to delete file in teardown + Path.ChangeExtension (tempFileWithIcon, "ico"); + + WriteEmbeddedResource ("32x32.ico", tempFileWithIcon); + ResXFileRef fileRef = new ResXFileRef (tempFileWithIcon, typeof (Icon).AssemblyQualifiedName); + ResXDataNode node = new ResXDataNode ("test", fileRef); + + return node; + } + + void WriteEmbeddedResource (string name, string filename) + { + const int size = 512; + byte [] buffer = new byte [size]; + int count = 0; + + Stream input = typeof (ResXDataNodeTest).Assembly. + GetManifestResourceStream (name); + Stream output = File.Open (filename, FileMode.Create); + + try { + while ((count = input.Read (buffer, 0, size)) > 0) { + output.Write (buffer, 0, count); + } + } finally { + output.Close (); + } + } + + public ResXDataNode GetNodeEmdeddedBytes1To10 () + { + byte [] someBytes = new byte [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + ResXDataNode node = new ResXDataNode ("test", someBytes); + return node; + } + + public ResXDataNode GetNodeEmdeddedSerializable () + { + serializable ser = new serializable ("testName", "testValue"); + ResXDataNode node = new ResXDataNode ("test", ser); + return node; + } + + public ResXDataNode GetNodeFileRefToSerializable (string filename, bool assemblyQualifiedName) + { + tempFileWithSerializable = Path.GetTempFileName (); // remember to delete file in teardown + serializable ser = new serializable ("name", "value"); + + SerializeToFile (tempFileWithSerializable, ser); + + string typeName; + + if (assemblyQualifiedName) + typeName = typeof (serializable).AssemblyQualifiedName; + else + typeName = typeof (serializable).FullName; + + ResXFileRef fileRef = new ResXFileRef (tempFileWithSerializable, typeName); + ResXDataNode node = new ResXDataNode ("test", fileRef); + + return node; + } + + static void SerializeToFile (string filepath, serializable ser) + { + Stream stream = File.Open (filepath, FileMode.Create); + BinaryFormatter bFormatter = new BinaryFormatter (); + bFormatter.Serialize (stream, ser); + stream.Close (); + } + + + [TearDown] + protected virtual void TearDown () + { + if (tempFileWithIcon != null) { + File.Delete (tempFileWithIcon); + tempFileWithIcon = null; + } + + if (tempFileWithSerializable != null) { + File.Delete (tempFileWithSerializable); + tempFileWithSerializable = null; + } + } + } } #endif |