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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=78586 --- shadow/78586 2006-06-05 16:06:59.000000000 -0400 +++ shadow/78586.tmp.14770 2006-06-05 16:06:59.000000000 -0400 @@ -0,0 +1,94 @@ +Bug#: 78586 +Product: Mono: Runtime +Version: 1.1 +OS: +OS Details: Windows XP +Status: NEW +Resolution: +Severity: +Priority: Wishlist +Component: debug +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Wrong line numbers in stack traces + +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 = "/temp/test.cs"; + + static void Main(string[] args) + { + IFoo foo = EmitFoo(); + try + { + foo.Bar(); + } + catch (Exception x) + { + //Console.WriteLine(x); + Assert(x.StackTrace.IndexOf(DocumentPath + ":10") != -1); + } + } + + static void Assert(bool condition) + { + if (!condition) throw new ApplicationException(); + } + + 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 foo = module.DefineType("Foo", +TypeAttributes.Public | 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)); + // MONO uses the next sequence point as the line number for the + // exception above, it should use the previous one + il.MarkSequencePoint(document, 11, 0, 12, 0); + il.Emit(OpCodes.Ret); + + foo.CreateType(); + + builder.Save(Path.GetFileName(fname)); + return +(IFoo)Activator.CreateInstance(Assembly.LoadFrom(fname).GetType("Foo")); + } + } +} _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
