mail-archives/mono-bugs/2004-June/017656.html

143 строки
4.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 60474][Blo] New - TypeBuilder.SetParent doesnt work for in memory assemblies
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:bugzilla-daemon%40bugzilla.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="017655.html">
<LINK REL="Next" HREF="017657.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 60474][Blo] New - TypeBuilder.SetParent doesnt work for in memory assemblies
</H1>
<B>bugzilla-daemon@bugzilla.ximian.com
</B>
<A HREF="mailto:bugzilla-daemon%40bugzilla.ximian.com"
TITLE="[Mono-bugs] [Bug 60474][Blo] New - TypeBuilder.SetParent doesnt work for in memory assemblies">bugzilla-daemon@bugzilla.ximian.com
</A><BR>
<I>Sat, 19 Jun 2004 21:48:32 -0400 (EDT)</I>
<P><UL>
<LI> Previous message: <A HREF="017655.html">[Mono-bugs] [Bug 60471][Nor] Changed - decimal parsing is locale dependent
</A></li>
<LI> Next message: <A HREF="017657.html">[Mono-bugs] [Bug 60320][Nor] Changed - Mono.Data.SybaseClient: SybaseConnection.Open() doesn't work.
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#17656">[ date ]</a>
<a href="thread.html#17656">[ thread ]</a>
<a href="subject.html#17656">[ subject ]</a>
<a href="author.html#17656">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by <A HREF="mailto:rbo@acm.org.">rbo@acm.org.</A>
<A HREF="http://bugzilla.ximian.com/show_bug.cgi?id=60474">http://bugzilla.ximian.com/show_bug.cgi?id=60474</A>
--- shadow/60474 2004-06-19 21:48:32.000000000 -0400
+++ shadow/60474.tmp.18906 2004-06-19 21:48:32.000000000 -0400
@@ -0,0 +1,79 @@
+Bug#: 60474
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Blocker
+Component: CORLIB
+AssignedTo: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+ReportedBy: <A HREF="mailto:rbo@acm.org">rbo@acm.org</A>
+QAContact: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+TargetMilestone: ---
+URL:
+Cc:
+Summary: TypeBuilder.SetParent doesnt work for in memory assemblies
+
+&lt;snip&gt;
+namespace MonoTestFixtures
+{
+ using System;
+ using System.Reflection;
+ using System.Reflection.Emit;
+ using NUnit.Framework;
+
+ public class ScriptBase
+ {
+ public virtual object Eval()
+ {
+ return null;
+ }
+ }
+
+ [TestFixture]
+ public class TypeBuilderFixture
+ {
+ Type _type;
+
+ [SetUp]
+ public void SetUp()
+ {
+ AssemblyName assemblyName = new AssemblyName();
+ assemblyName.Name = &quot;Temp&quot;;
+
+ AssemblyBuilder assemblyBuilder =
+AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,
+AssemblyBuilderAccess.Run);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(&quot;Temp&quot;);
+ TypeBuilder builder = moduleBuilder.DefineType(&quot;Script&quot;);
+ builder.SetParent(typeof(ScriptBase));
+
+ MethodBuilder method = builder.DefineMethod(&quot;Eval&quot;,
+MethodAttributes.Public|MethodAttributes.Virtual, typeof(object), new Type[0]);
+ ILGenerator il = method.GetILGenerator();
+ il.Emit(OpCodes.Ldstr, &quot;Hello, world!&quot;);
+ il.Emit(OpCodes.Ret);
+
+ _type = builder.CreateType();
+ }
+
+ [Test]
+ public void TestBaseType()
+ {
+ Assert.AreSame(typeof(ScriptBase), _type.BaseType);
+ }
+
+ [Test]
+ public void TestCastToBaseType()
+ {
+ ScriptBase script = (ScriptBase)Activator.CreateInstance(_type);
+ Assert.AreEqual(&quot;Hello, world!&quot;, script.Eval());
+ }
+ }
+}
+&lt;/snip&gt;
+
+How often does this happen?
+Always.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="017655.html">[Mono-bugs] [Bug 60471][Nor] Changed - decimal parsing is locale dependent
</A></li>
<LI> Next message: <A HREF="017657.html">[Mono-bugs] [Bug 60320][Nor] Changed - Mono.Data.SybaseClient: SybaseConnection.Open() doesn't work.
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#17656">[ date ]</a>
<a href="thread.html#17656">[ thread ]</a>
<a href="subject.html#17656">[ subject ]</a>
<a href="author.html#17656">[ author ]</a>
</LI>
</UL>
</body></html>