Permalink
Browse files

Workaround a bug in a old Mono C# compiler for debug symbols in itera…

…tors
  • Loading branch information...
1 parent cd45fe4 commit 9bd6d39da40eaf2da2f5d29c817af3fd669b52ac @jbevain committed Apr 18, 2013
Showing with 7 additions and 0 deletions.
  1. +7 −0 symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
@@ -82,7 +82,11 @@ public void Read (MethodBody body, InstructionMapper mapper)
static void ReadLocalVariables (MethodEntry entry, MethodBody body, Scope [] scopes)
{
var locals = entry.GetLocals ();
+
foreach (var local in locals) {
+ if (local.Index < 0 || local.Index >= body.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = body.Variables [local.Index];
variable.Name = local.Name;
@@ -202,6 +206,9 @@ void ReadLineNumbers (MethodEntry entry, MethodSymbols symbols)
static void ReadLocalVariables (MethodEntry entry, MethodSymbols symbols)
{
foreach (var local in entry.GetLocals ()) {
+ if (local.Index < 0 || local.Index >= symbols.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = symbols.Variables [local.Index];
variable.Name = local.Name;
}

0 comments on commit 9bd6d39

Please sign in to comment.