Author: gert
Date: 2008-01-27 04:34:24 -0500 (Sun, 27 Jan 2008)
New Revision: 94041
Added:
trunk/gert/standalone/bug356316/
trunk/gert/standalone/bug356316/default.build
trunk/gert/standalone/bug356316/test.cs
Log:
Added test for bug #356316.
Added: trunk/gert/standalone/bug356316/default.build
===================================================================
--- trunk/gert/standalone/bug356316/default.build 2008-01-27 09:25:59 UTC
(rev 94040)
+++ trunk/gert/standalone/bug356316/default.build 2008-01-27 09:34:24 UTC
(rev 94041)
@@ -0,0 +1,29 @@
+<project name="bug356316" default="rebuild">
+ <include buildfile="../../build/common.build" />
+
+ <property name="frameworks" value="mono-1.0,mono-2.0,net-2.0" />
+
+ <target name="clean">
+ <delete>
+ <fileset>
+ <include name="bugged.*" />
+ <include name="out" />
+ <include name="test.exe" />
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="compile" depends="init">
+ <csc target="exe" define="${csc.defines}" output="test.exe"
warnaserror="true" warninglevel="4">
+ <sources>
+ <include name="../../build/common/Assert.cs" />
+ <include name="test.cs" />
+ </sources>
+ </csc>
+ </target>
+
+ <target name="run-test" depends="compile">
+ <exec program="test.exe" managed="true" output="out" />
+ <fail if="${file::exists('out')}" />
+ </target>
+</project>
Property changes on: trunk/gert/standalone/bug356316/default.build
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/gert/standalone/bug356316/test.cs
===================================================================
--- trunk/gert/standalone/bug356316/test.cs 2008-01-27 09:25:59 UTC (rev
94040)
+++ trunk/gert/standalone/bug356316/test.cs 2008-01-27 09:34:24 UTC (rev
94041)
@@ -0,0 +1,65 @@
+using System;
+using System.IO;
+using System.Reflection.Emit;
+using System.Reflection;
+using System.Diagnostics.SymbolStore;
+
+namespace BugReport
+{
+ public interface IFoo
+ {
+ void Bar ();
+ }
+
+ class Program
+ {
+ const string DocumentPath = "test.cs";
+
+ static int Main (string [] args)
+ {
+ IFoo foo = EmitFoo ();
+ try {
+ foo.Bar ();
+ return 1;
+ } catch (Exception ex) {
+#if MONO
+ Assert.IsTrue (ex.StackTrace.IndexOf
(DocumentPath + ":10") != -1, ex.StackTrace);
+#else
+ Assert.IsTrue (ex.StackTrace.IndexOf
(DocumentPath + ":line 10") != -1, ex.StackTrace);
+#endif
+ return 0;
+ }
+ }
+
+ static IFoo EmitFoo ()
+ {
+ AppDomain currentDomain = AppDomain.CurrentDomain;
+ string fname = Path.Combine
(currentDomain.BaseDirectory, "bugged.dll");
+
+ AssemblyName name = new AssemblyName ();
+ name.Name = Path.GetFileNameWithoutExtension (fname);
+
+ AssemblyBuilder builder =
currentDomain.DefineDynamicAssembly (name, AssemblyBuilderAccess.Save,
Path.GetDirectoryName (fname), null);
+ ModuleBuilder module = builder.DefineDynamicModule
(Path.GetFileName (fname), true);
+ ISymbolDocumentWriter document = module.DefineDocument
(DocumentPath, SymDocumentType.Text, SymLanguageType.CSharp, Guid.Empty);
+
+ TypeBuilder container = module.DefineType ("Container",
TypeAttributes.Public | TypeAttributes.Class);
+
+ //TypeBuilder foo = module.DefineType("Foo",
TypeAttributes.Public | TypeAttributes.Class, typeof(object));
+ TypeBuilder foo = container.DefineNestedType ("Foo",
TypeAttributes.NestedPublic | TypeAttributes.Class, typeof (object));
+ foo.AddInterfaceImplementation (typeof (IFoo));
+
+ MethodBuilder bar = foo.DefineMethod ("Bar",
MethodAttributes.Public | MethodAttributes.Virtual, typeof (void), new Type
[0]);
+ ILGenerator il = bar.GetILGenerator ();
+ il.MarkSequencePoint (document, 10, 0, 11, 0);
+ il.ThrowException (typeof (ApplicationException));
+ il.Emit (OpCodes.Ret);
+
+ container.CreateType ();
+ Type emittedTypeName = foo.CreateType ();
+
+ builder.Save (Path.GetFileName (fname));
+ return (IFoo) Activator.CreateInstance
(Assembly.LoadFrom (fname).GetType (emittedTypeName.FullName));
+ }
+ }
+}
Property changes on: trunk/gert/standalone/bug356316/test.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches