diff options
author | Jb Evain <jbevain@gmail.com> | 2011-10-27 16:53:07 +0400 |
---|---|---|
committer | Jb Evain <jbevain@gmail.com> | 2011-10-27 16:53:07 +0400 |
commit | 8771de6415d3fa5e34b12fd90519a5405c02e8b2 (patch) | |
tree | 0a1707ab3fc77c49d3f5f6f51628089ccffb1d19 /Test/Mono.Cecil.Tests/ImportReflectionTests.cs | |
parent | ecdd7454b53a4d6b57c9eb2a500b91025a63b401 (diff) |
First pass at a branch with reduced memory usage; Keeps an open handle on the file, dispose your modules
Diffstat (limited to 'Test/Mono.Cecil.Tests/ImportReflectionTests.cs')
-rw-r--r-- | Test/Mono.Cecil.Tests/ImportReflectionTests.cs | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/Test/Mono.Cecil.Tests/ImportReflectionTests.cs b/Test/Mono.Cecil.Tests/ImportReflectionTests.cs index dd1d28a..ffb2619 100644 --- a/Test/Mono.Cecil.Tests/ImportReflectionTests.cs +++ b/Test/Mono.Cecil.Tests/ImportReflectionTests.cs @@ -209,13 +209,13 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericTypeDefOrOpen () { - var module = typeof (Foo<>).ToDefinition ().Module; + using (var module = typeof (Foo<>).ToDefinition ().Module) { + var foo_def = module.Import (typeof (Foo<>)); + var foo_open = module.Import (typeof (Foo<>), foo_def); - var foo_def = module.Import (typeof (Foo<>)); - var foo_open = module.Import (typeof (Foo<>), foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1", foo_def.FullName); - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>", foo_open.FullName); + Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1", foo_def.FullName); + Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>", foo_open.FullName); + } } [Test] @@ -225,12 +225,12 @@ namespace Mono.Cecil.Tests { var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); var foo_def = typeof (Foo<>).ToDefinition (); - var module = foo_def.Module; + using (var module = foo_def.Module) { + var generic_foo = module.Import (generic_list_foo_open, foo_def); - var generic_foo = module.Import (generic_list_foo_open, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>", - generic_foo.FullName); + Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>", + generic_foo.FullName); + } } [Test] @@ -240,12 +240,12 @@ namespace Mono.Cecil.Tests { var generic_foo_open = typeof (Generic<>).MakeGenericType (foo_open); var foo_def = typeof (Foo<>).ToDefinition (); - var module = foo_def.Module; + using (var module = foo_def.Module) { + var generic_foo = module.Import (generic_foo_open, foo_def); - var generic_foo = module.Import (generic_foo_open, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1<Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>>", - generic_foo.FullName); + Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1<Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>>", + generic_foo.FullName); + } } [Test] @@ -255,12 +255,12 @@ namespace Mono.Cecil.Tests { var foo_open_array = foo_open.MakeArrayType (); var foo_def = typeof (Foo<>).ToDefinition (); - var module = foo_def.Module; + using (var module = foo_def.Module) { + var array_foo = module.Import (foo_open_array, foo_def); - var array_foo = module.Import (foo_open_array, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>[]", - array_foo.FullName); + Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1<TFoo>[]", + array_foo.FullName); + } } [Test] @@ -271,12 +271,12 @@ namespace Mono.Cecil.Tests { var generic_list_foo_open_field = generic_list_foo_open.GetField ("Field"); var foo_def = typeof (Foo<>).ToDefinition (); - var module = foo_def.Module; + using (var module = foo_def.Module) { + var generic_field = module.Import (generic_list_foo_open_field, foo_def); - var generic_field = module.Import (generic_list_foo_open_field, foo_def); - - Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Field", - generic_field.FullName); + Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Field", + generic_field.FullName); + } } [Test] @@ -287,36 +287,36 @@ namespace Mono.Cecil.Tests { var generic_list_foo_open_method = generic_list_foo_open.GetMethod ("Method"); var foo_def = typeof (Foo<>).ToDefinition (); - var module = foo_def.Module; + using (var module = foo_def.Module) { + var generic_method = module.Import (generic_list_foo_open_method, foo_def); - var generic_method = module.Import (generic_list_foo_open_method, foo_def); - - Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Method(TFoo)", - generic_method.FullName); + Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Method(TFoo)", + generic_method.FullName); + } } [Test] public void ImportMethodOnOpenGenericType () { - var module = typeof (Generic<>).ToDefinition ().Module; + using (var module = typeof (Generic<>).ToDefinition ().Module) { + var method = module.Import (typeof (Generic<>).GetMethod ("Method")); - var method = module.Import (typeof (Generic<>).GetMethod ("Method")); - - Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::Method(T)", method.FullName); + Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::Method(T)", method.FullName); + } } [Test] public void ImportGenericMethodOnOpenGenericType () { - var module = typeof (Generic<>).ToDefinition ().Module; + using (var module = typeof (Generic<>).ToDefinition ().Module) { + var generic_method = module.Import (typeof (Generic<>).GetMethod ("GenericMethod")); - var generic_method = module.Import (typeof (Generic<>).GetMethod ("GenericMethod")); + Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::GenericMethod(T,TS)", generic_method.FullName); - Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::GenericMethod(T,TS)", generic_method.FullName); + generic_method = module.Import (typeof (Generic<>).GetMethod ("GenericMethod"), generic_method); - generic_method = module.Import (typeof (Generic<>).GetMethod ("GenericMethod"), generic_method); - - Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::GenericMethod<TS>(T,TS)", generic_method.FullName); + Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1<T>::GenericMethod<TS>(T,TS)", generic_method.FullName); + } } delegate void Emitter (ModuleDefinition module, MethodBody body); |