* Type.cs : implemented ReflectionOnlyGetType().
* TypeTest.cs : tests for ReflectionOnlyGetType().
svn path=/trunk/mcs/; revision=88053
+2007-10-24 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Type.cs : implemented ReflectionOnlyGetType().
+
2007-10-19 Zoltan Varga <vargaz@gmail.com>
* AppDomain.cs: Add NET 3.5 DefineDynamicAssembly () overloads.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern virtual Type MakePointerType ();
- [MonoTODO("Not implemented")]
public static Type ReflectionOnlyGetType (string typeName,
bool throwIfNotFound,
bool ignoreCase)
{
- throw new NotImplementedException ();
+ if (typeName == null)
+ throw new ArgumentNullException ("typeName");
+ int idx = typeName.IndexOf (',');
+ if (idx < 0 || idx == 0 || idx == typeName.Length - 1)
+ throw new ArgumentException ("Assembly qualifed type name is required", "typeName");
+ string an = typeName.Substring (idx + 1);
+ Assembly a;
+ try {
+ a = Assembly.ReflectionOnlyLoad (an);
+ } catch (Exception ex) {
+ if (throwIfNotFound)
+ throw;
+ return null;
+ }
+ return a.GetType (typeName.Substring (0, idx), throwIfNotFound, ignoreCase);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
+2007-10-24 Atsushi Enomoto <atsushi@ximian.com>
+
+ * TypeTest.cs : tests for ReflectionOnlyGetType().
+
2007-10-15 Gert Driesen <drieseng@users.sourceforge.net>
* EnvironmentTest.cs: Added test for bug #333740. Made names of some
Assert.IsNotNull (members, "#1");
Assert.AreEqual (4, members.Length, "#2");
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ReflectionOnlyGetTypeNullTypeName ()
+ {
+ Type.ReflectionOnlyGetType (null, false, false);
+ }
+
+ [Test]
+ public void ReflectionOnlyGetTypeDoNotThrow ()
+ {
+ Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
+ }
+
+ [Test]
+ [ExpectedException (typeof (FileNotFoundException))]
+ public void ReflectionOnlyGetTypeThrow ()
+ {
+ Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
+ }
+
+ [Test]
+ public void ReflectionOnlyGetType ()
+ {
+ Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
+ Assert.AreEqual ("System.Int32", t.FullName);
+ }
#endif
public class NemerleAttribute : Attribute