[system.windows.forms] Add AssemblyNamesTypeResolutionService to correctly fix 78b63f...
authorMarek Safar <marek.safar@gmail.com>
Tue, 24 Mar 2015 06:14:24 +0000 (07:14 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 24 Mar 2015 06:15:03 +0000 (07:15 +0100)
mcs/class/System.Windows.Forms/System.Resources/AssemblyNamesTypeResolutionService.cs [new file with mode: 0644]
mcs/class/System.Windows.Forms/System.Resources/SerializedFromResXHandler.cs
mcs/class/System.Windows.Forms/System.Windows.Forms.dll.sources
mcs/class/System.Windows.Forms/Test/System.Resources/ResXDataNodeSerializedGetValueTests.cs

diff --git a/mcs/class/System.Windows.Forms/System.Resources/AssemblyNamesTypeResolutionService.cs b/mcs/class/System.Windows.Forms/System.Resources/AssemblyNamesTypeResolutionService.cs
new file mode 100644 (file)
index 0000000..1c630a2
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// AssemblyNamesTypeResolutionService.cs
+//
+// Authors:
+//     Marek Safar  <marek.safar@gmail.com>
+//
+// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
+//
+// 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.
+//
+
+using System.Reflection;
+using System.ComponentModel.Design;
+
+namespace System.Resources
+{
+       sealed class AssemblyNamesTypeResolutionService : ITypeResolutionService
+       {
+               public AssemblyNamesTypeResolutionService (AssemblyName[] names)
+               {
+
+               }
+
+               #region ITypeResolutionService implementation
+
+               public Assembly GetAssembly (AssemblyName name)
+               {
+                       return GetAssembly (name, true);
+               }
+
+               public Assembly GetAssembly (AssemblyName name, bool throwOnError)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Type GetType (string name)
+               {
+                       return GetType (name, true);
+               }
+
+               public Type GetType (string name, bool throwOnError)
+               {
+                       return GetType (name, throwOnError, false);
+               }
+
+               public Type GetType (string name, bool throwOnError, bool ignoreCase)
+               {
+                       var type = Type.GetType (name, false, ignoreCase);
+                       if (type == null && throwOnError)
+                               throw new ArgumentException (string.Format ("Could not find a type for a name. The type name was `{0}'", name));
+
+                       return type;
+               }
+
+               public void ReferenceAssembly (AssemblyName name)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public string GetPathOfAssembly (AssemblyName name)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
index bd52553e0dad1863d8fb0a043bcceeeba39bf304..7eda150c9302d9716a86428eefbc0c5c8dd6ca63 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Resources {
 
                public override object GetValue (AssemblyName [] assemblyNames)
                {
-                       return DeserializeObject ((ITypeResolutionService) null);
+                       return DeserializeObject (new AssemblyNamesTypeResolutionService (assemblyNames));
                }
 
                public override string GetValueTypeName (ITypeResolutionService typeResolver)
index a908f6e9519ca81d717330a2381a79445b12a3ae..90e91d144e12ba407ecd5e9c6ea1a357532dc3d0 100644 (file)
@@ -2,6 +2,7 @@
 ../../build/common/MonoTODOAttribute.cs
 Assembly/AssemblyInfo.cs
 Assembly/Locale.cs
+System.Resources/AssemblyNamesTypeResolutionService.cs
 System.Resources/ByteArrayFromResXHandler.cs
 System.Resources/ResXNullRef.cs
 System.Resources/ResXResourceReader.cs
index 56f41c8a47dd4c1687ee5de77f78bfa774db0cc7..d27d4439bb680fdf7c9f9aa919c08de6694f3f3c 100644 (file)
@@ -141,7 +141,7 @@ namespace MonoTests.System.Resources {
                        Assert.AreEqual ("DummyAssembly.AnotherSerializable, DummyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", value.GetType ().AssemblyQualifiedName, "#A2");
                }
 
-               [Test, ExpectedException (typeof (SerializationException))]
+               [Test, ExpectedException (typeof (ArgumentException))]
                public void ErrorWhenAssemblyMissing ()
                {
                        ResXDataNode node = GetNodeFromResXReader (missingSerializableFromMissingAssembly);