Index: mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
===================================================================
--- mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs	(revision 65049)
+++ mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs	(working copy)
@@ -47,10 +47,6 @@
 
 	public interface ISourceMethod
 	{
-		string Name {
-			get;
-		}
-
 		int NamespaceID {
 			get;
 		}
@@ -67,6 +63,7 @@
 		protected ArrayList sources = null;
 		protected readonly MonoSymbolFile file;
 		private string filename = null;
+		SymbolWriterImpl sw;
 		
 		LineNumberEntry [] current_method_lines;
 		int current_method_lines_pos = 0;
@@ -104,11 +101,17 @@
 			current_method.AddLocal (index, name, signature);
 		}
 
-		public void MarkSequencePoint (int offset, int line, int column)
+		public void MarkSequencePoint (ISourceFile file, int offset, int line, int column)
 		{
 			if (current_method == null)
 				return;
 
+			if (current_method._file == null) {
+				current_method._file = file;
+				current_method._method = sw.GetSourceMethod (file);
+				methods.Add (current_method);
+			}
+
 			if (current_method_lines_pos == current_method_lines.Length) {
 				LineNumberEntry [] tmp = current_method_lines;
 				current_method_lines = new LineNumberEntry [current_method_lines.Length * 2];
@@ -118,19 +121,19 @@
 			current_method_lines [current_method_lines_pos++] = new LineNumberEntry (line, offset);
 		}
 
-		public void OpenMethod (ISourceFile file, ISourceMethod method,
-					int startRow, int startColumn,
-					int endRow, int endColumn)
+		public void OpenMethod (SymbolWriterImpl sw)
 		{
-			SourceMethod source = new SourceMethod (
-				file, method, startRow, startColumn, endRow, endColumn);
-
-			current_method = source;
-			methods.Add (current_method);
+			this.sw = sw;
+			current_method = new SourceMethod ();
 		}
 
 		public void CloseMethod ()
 		{
+			if (current_method_lines_pos > 0) {
+				current_method._start = current_method_lines [0];
+				current_method._end = current_method_lines [current_method_lines_pos - 1];
+			}
+
 			current_method.SetLineNumbers (
 				current_method_lines, current_method_lines_pos);
 			current_method_lines_pos = 0;
@@ -175,7 +178,7 @@
 		{
 			foreach (SourceMethod method in methods) {
 				method.SourceFile.Entry.DefineMethod (
-					method.Method.Name, method.Method.Token,
+					method.Method.Token,
 					method.Locals, method.Lines, method.Blocks,
 					method.Start.Row, method.End.Row,
 					method.Method.NamespaceID);
@@ -193,22 +196,14 @@
 			private ArrayList _blocks;
 			private Stack _block_stack;
 			private int next_block_id = 0;
-			private ISourceMethod _method;
-			private ISourceFile _file;
-			private LineNumberEntry _start, _end;
+			internal ISourceMethod _method;
+			internal ISourceFile _file;
+			internal LineNumberEntry _start, _end;
 
 			private LexicalBlockEntry _implicit_block;
 
-			public SourceMethod (ISourceFile file, ISourceMethod method,
-					     int startLine, int startColumn,
-					     int endLine, int endColumn)
+			public SourceMethod ()
 			{
-				this._file = file;
-				this._method = method;
-
-				this._start = new LineNumberEntry (startLine, 0);
-				this._end = new LineNumberEntry (endLine, 0);
-
 				this._implicit_block = new LexicalBlockEntry (0, 0);
 			}
 
Index: mcs/class/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs
===================================================================
--- mcs/class/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs	(revision 65049)
+++ mcs/class/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs	(working copy)
@@ -35,44 +35,34 @@
 using System.Collections;
 using System.IO;
 using System.Diagnostics.SymbolStore;
-	
+
 namespace Mono.CompilerServices.SymbolWriter
 {
 	public class SymbolWriterImpl: ISymbolWriter
 	{
 		MonoSymbolWriter msw;
-		ModuleBuilder mb;
 
-		delegate Guid GetGuidFunc (ModuleBuilder mb);
-		GetGuidFunc get_guid_func;
-		
 		int nextLocalIndex;
 		int currentToken;
-		string methodName;
 		Stack namespaceStack = new Stack ();
 		bool methodOpened;
 		
 		Hashtable documents = new Hashtable ();
-		
-		public SymbolWriterImpl (ModuleBuilder mb)
+
+		public SymbolWriterImpl ()
 		{
-			this.mb = mb;
 		}
-		
+
 		public void Close ()
 		{
-			MethodInfo mi = typeof (ModuleBuilder).GetMethod (
-				"Mono_GetGuid",
-				BindingFlags.Static | BindingFlags.NonPublic);
-			if (mi == null)
-				return;
+		}
 
-			get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
-				typeof (GetGuidFunc), mi);
-			
-			msw.WriteSymbolFile (get_guid_func (mb));
+		public void Close (Guid mvid)
+		{
+			msw.WriteSymbolFile (mvid);
 		}
 		
+		//called
 		public void CloseMethod ()
 		{
 			if (methodOpened) {
@@ -88,11 +78,13 @@
 			msw.CloseNamespace ();
 		}
 		
+		//called
 		public void CloseScope (int endOffset)
 		{
 			msw.CloseScope (endOffset);
 		}
 		
+		//called
 		public ISymbolDocumentWriter DefineDocument (
 			string url,
 			Guid language,
@@ -130,6 +122,7 @@
 		{
 		}
 		
+		//called
 		public void DefineLocalVariable (
 			string name,
 			FieldAttributes attributes,
@@ -155,6 +148,7 @@
 		{
 		}
 
+		//called
 		public void DefineSequencePoints (
 			ISymbolDocumentWriter document,
 			int[] offsets,
@@ -166,7 +160,7 @@
 			for (int n=0; n<offsets.Length; n++) {
 				if (n > 0 && offsets[n] == offsets[n-1] && lines[n] == lines[n-1] && columns[n] == columns[n-1])
 					continue;
-				msw.MarkSequencePoint (offsets[n], lines[n], columns[n]);
+				msw.MarkSequencePoint (document as ISourceFile, offsets [n], lines [n], columns [n]);
 			}
 		}
 		
@@ -175,11 +169,21 @@
 			msw = new MonoSymbolWriter (filename);
 		}
 		
+		// called
 		public void OpenMethod (SymbolToken method)
 		{
 			currentToken = method.GetToken ();
+
+			msw.OpenMethod (this);
+			methodOpened = true;
 		}
-		
+
+		public ISourceMethod GetSourceMethod (ISourceFile file)
+		{
+			return new SourceMethodImpl (currentToken, GetCurrentNamespace (file));
+		}
+
+		//called
 		public void OpenNamespace (string name)
 		{
 			NamespaceInfo n = new NamespaceInfo ();
@@ -188,6 +192,7 @@
 			namespaceStack.Push (n);
 		}
 		
+		//called
 		public int OpenScope (int startOffset)
 		{
 			return msw.OpenScope (startOffset);
@@ -201,9 +206,6 @@
 			int endLine,
 			int endColumn)
 		{
-			SourceMethodImpl sm = new SourceMethodImpl (methodName, currentToken, GetCurrentNamespace (startDoc));
-			msw.OpenMethod (startDoc as ISourceFile, sm, startLine, startColumn, endLine, endColumn);
-			methodOpened = true;
 		}
 		
 		public void SetScopeRange (int scopeID, int startOffset, int endOffset)
@@ -212,10 +214,6 @@
 		
 		public void SetSymAttribute (SymbolToken parent, string name, byte[] data)
 		{
-			// This is a hack! but MonoSymbolWriter needs the method name
-			// and ISymbolWriter does not have any method for providing it
-			if (name == "__name")
-				methodName = System.Text.Encoding.UTF8.GetString (data);
 		}
 		
 		public void SetUnderlyingWriter (IntPtr underlyingWriter)
@@ -243,7 +241,7 @@
 			ni.UsingClauses.Add (fullName);
 		}
 		
-		int GetCurrentNamespace (ISymbolDocumentWriter doc)
+		int GetCurrentNamespace (ISourceFile file)
 		{
 			if (namespaceStack.Count == 0) {
 				OpenNamespace ("");
@@ -261,7 +259,7 @@
 					namespaceStack.Push (ni);
 				}
 					
-				ni.NamespaceID = msw.DefineNamespace (ni.Name, ((ISourceFile)doc).Entry, usings, parentId);
+				ni.NamespaceID = msw.DefineNamespace (ni.Name, file.Entry, usings, parentId);
 			}
 			return ni.NamespaceID;
 		}
@@ -291,21 +289,15 @@
 	
 	class SourceMethodImpl: ISourceMethod
 	{
-		string name;
 		int token;
 		int namespaceID;
 		
-		public SourceMethodImpl (string name, int token, int namespaceID)
+		public SourceMethodImpl (int token, int namespaceID)
 		{
-			this.name = name;
 			this.token = token;
 			this.namespaceID = namespaceID;
 		}
 		
-		public string Name {
-			get { return name; }
-		}
-
 		public int NamespaceID {
 			get { return namespaceID; }
 		}
Index: mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
===================================================================
--- mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs	(revision 65049)
+++ mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs	(working copy)
@@ -304,7 +304,7 @@
 			namespaces = new ArrayList ();
 		}
 
-		public void DefineMethod (string name, int token, LocalVariableEntry[] locals,
+		public void DefineMethod (int token, LocalVariableEntry[] locals,
 					  LineNumberEntry[] lines, LexicalBlockEntry[] blocks,
 					  int start, int end, int namespace_id)
 		{
@@ -312,7 +312,7 @@
 				throw new InvalidOperationException ();
 
 			MethodEntry entry = new MethodEntry (
-				file, this, name, (int) token, locals, lines, blocks,
+				file, this, (int) token, locals, lines, blocks,
 				start, end, namespace_id);
 
 			methods.Add (entry);
@@ -628,7 +628,7 @@
 		}
 
 		internal MethodEntry (MonoSymbolFile file, SourceFileEntry source,
-				      string name, int token, LocalVariableEntry[] locals,
+				      int token, LocalVariableEntry[] locals,
 				      LineNumberEntry[] lines, LexicalBlockEntry[] blocks,
 				      int start_row, int end_row, int namespace_id)
 		{
