You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@ -42,6 +42,7 @@ using System.Threading;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
|
||||
namespace MonoTests.System.Reflection
|
||||
{
|
||||
@ -122,6 +123,7 @@ namespace MonoTests.System.Reflection
|
||||
// note: only available in default appdomain
|
||||
// http://weblogs.asp.net/asanto/archive/2003/09/08/26710.aspx
|
||||
// Not sure we should emulate this behavior.
|
||||
#if !MONODROID
|
||||
string fname = AppDomain.CurrentDomain.FriendlyName;
|
||||
if (fname.EndsWith (".dll")) { // nunit-console
|
||||
Assert.IsNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
|
||||
@ -130,10 +132,15 @@ namespace MonoTests.System.Reflection
|
||||
Assert.IsNotNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
|
||||
Assert.IsTrue (AppDomain.CurrentDomain.IsDefaultAppDomain (), "!default appdomain");
|
||||
}
|
||||
#else
|
||||
Assert.IsNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
|
||||
Assert.IsTrue (AppDomain.CurrentDomain.IsDefaultAppDomain (), "!default appdomain");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !MONOTOUCH // Reflection.Emit is not supported.
|
||||
[Test]
|
||||
[Category("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter
|
||||
public void GetModules_MissingFile ()
|
||||
{
|
||||
AssemblyName newName = new AssemblyName ();
|
||||
@ -183,7 +190,10 @@ namespace MonoTests.System.Reflection
|
||||
public void Corlib_test ()
|
||||
{
|
||||
Assembly corlib_test = Assembly.GetExecutingAssembly ();
|
||||
#if MOBILE
|
||||
#if MONODROID
|
||||
Assert.IsNull (corlib_test.EntryPoint, "EntryPoint");
|
||||
Assert.IsNull (corlib_test.Evidence, "Evidence");
|
||||
#elif MOBILE
|
||||
Assert.IsNotNull (corlib_test.EntryPoint, "EntryPoint");
|
||||
Assert.IsNull (corlib_test.Evidence, "Evidence");
|
||||
#else
|
||||
@ -194,11 +204,7 @@ namespace MonoTests.System.Reflection
|
||||
|
||||
Assert.IsTrue (corlib_test.GetReferencedAssemblies ().Length > 0, "GetReferencedAssemblies");
|
||||
Assert.AreEqual (0, corlib_test.HostContext, "HostContext");
|
||||
#if NET_4_0 && !MOBILE
|
||||
Assert.AreEqual ("v4.0.30319", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
|
||||
#else
|
||||
Assert.AreEqual ("v2.0.50727", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
|
||||
#endif
|
||||
|
||||
Assert.IsNotNull (corlib_test.ManifestModule, "ManifestModule");
|
||||
Assert.IsFalse (corlib_test.ReflectionOnly, "ReflectionOnly");
|
||||
@ -241,6 +247,7 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be accessed as FileStream
|
||||
public void GetFiles_False ()
|
||||
{
|
||||
Assembly corlib = typeof (int).Assembly;
|
||||
@ -253,6 +260,7 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be accessed as FileStream
|
||||
public void GetFiles_True ()
|
||||
{
|
||||
Assembly corlib = typeof (int).Assembly;
|
||||
@ -390,7 +398,7 @@ namespace MonoTests.System.Reflection
|
||||
[Test]
|
||||
public void LoadWithPartialName ()
|
||||
{
|
||||
string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_test_net_4_5", "corlib_plattest", "mscorlibtests" };
|
||||
string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_test_net_4_5", "corlib_plattest", "mscorlibtests", "BclTests" };
|
||||
|
||||
foreach (string s in names)
|
||||
if (Assembly.LoadWithPartialName (s) != null)
|
||||
@ -464,6 +472,63 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SateliteAssemblyForInMemoryAssembly ()
|
||||
{
|
||||
string assemblyFileName = Path.Combine (
|
||||
Path.GetTempPath (), "AssemblyLocation1.dll");
|
||||
|
||||
try {
|
||||
AssemblyName assemblyName = new AssemblyName ();
|
||||
assemblyName.Name = "AssemblyLocation1";
|
||||
|
||||
AssemblyBuilder ab = AppDomain.CurrentDomain
|
||||
.DefineDynamicAssembly (assemblyName,
|
||||
AssemblyBuilderAccess.Save,
|
||||
Path.GetTempPath ());
|
||||
|
||||
ModuleBuilder moduleBuilder = ab.DefineDynamicModule (assemblyName.Name, assemblyName.Name + ".dll");
|
||||
TypeBuilder typeBuilder = moduleBuilder.DefineType ("Program", TypeAttributes.Public);
|
||||
|
||||
MethodBuilder methodBuilder = typeBuilder.DefineMethod ("TestCall", MethodAttributes.Public | MethodAttributes.Static, typeof(void), Type.EmptyTypes);
|
||||
ILGenerator gen = methodBuilder.GetILGenerator ();
|
||||
|
||||
//
|
||||
// var resourceManager = new ResourceManager (typeof (Program));
|
||||
// resourceManager.GetString ("test");
|
||||
//
|
||||
gen.Emit (OpCodes.Ldtoken, typeBuilder);
|
||||
gen.Emit (OpCodes.Call, typeof(Type).GetMethod ("GetTypeFromHandle"));
|
||||
gen.Emit (OpCodes.Newobj, typeof(ResourceManager).GetConstructor (new Type[] { typeof(Type) }));
|
||||
gen.Emit (OpCodes.Ldstr, "test");
|
||||
gen.Emit (OpCodes.Callvirt, typeof(ResourceManager).GetMethod ("GetString", new Type[] { typeof(string) }));
|
||||
gen.Emit (OpCodes.Pop);
|
||||
gen.Emit (OpCodes.Ret);
|
||||
|
||||
typeBuilder.CreateType ();
|
||||
|
||||
ab.Save (Path.GetFileName (assemblyFileName));
|
||||
|
||||
using (FileStream fs = File.OpenRead (assemblyFileName)) {
|
||||
byte[] buffer = new byte[fs.Length];
|
||||
fs.Read (buffer, 0, buffer.Length);
|
||||
Assembly assembly = Assembly.Load (buffer);
|
||||
|
||||
var mm = assembly.GetType ("Program").GetMethod ("TestCall");
|
||||
try {
|
||||
mm.Invoke (null, null);
|
||||
Assert.Fail ();
|
||||
} catch (TargetInvocationException e) {
|
||||
Assert.IsTrue (e.InnerException is MissingManifestResourceException);
|
||||
}
|
||||
|
||||
fs.Close ();
|
||||
}
|
||||
} finally {
|
||||
File.Delete (assemblyFileName);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void bug78464 ()
|
||||
@ -486,6 +551,7 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("MobileNotWorking")]
|
||||
public void bug78465 ()
|
||||
{
|
||||
string assemblyFileName = Path.Combine (
|
||||
@ -523,6 +589,7 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("MobileNotWorking")]
|
||||
public void bug78468 ()
|
||||
{
|
||||
string assemblyFileNameA = Path.Combine (Path.GetTempPath (),
|
||||
@ -605,6 +672,7 @@ namespace MonoTests.System.Reflection
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be directly as files
|
||||
public void ReflectionOnlyLoadFrom ()
|
||||
{
|
||||
string loc = typeof (AssemblyTest).Assembly.Location;
|
||||
@ -776,6 +844,7 @@ namespace MonoTests.System.Reflection
|
||||
|
||||
|
||||
[Test] // bug #79715
|
||||
[Category("MobileNotWorking")]
|
||||
public void Load_PartialVersion ()
|
||||
{
|
||||
string tempDir = Path.Combine (Path.GetTempPath (),
|
||||
|
Reference in New Issue
Block a user