Skip to content

Commit 257759f

Browse files
committed
Fix wrong local variable symbol
1 parent 3fd3e6b commit 257759f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

core/RoslynMdbWriter/MdbWriter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Mono.CompilerServices.SymbolWriter
1212
class MdbWriter : ISymUnmanagedWriter5, IPdbWriter
1313
{
1414
MonoSymbolWriter msw;
15-
int nextLocalIndex;
15+
// int nextLocalIndex;
1616

1717
Dictionary<string,SymbolDocumentWriterImpl> documents = new Dictionary<string, SymbolDocumentWriterImpl> ();
1818

@@ -48,7 +48,7 @@ public ISymUnmanagedDocumentWriter DefineDocument (string url, ref Guid language
4848

4949
public void CloseMethod ()
5050
{
51-
nextLocalIndex = 0;
51+
// nextLocalIndex = 0;
5252
msw.CloseMethod ();
5353
}
5454

@@ -136,7 +136,8 @@ public void DefineSequencePoints (ISymUnmanagedDocumentWriter document, uint cou
136136

137137
public void DefineLocalVariable2 (string name, uint attributes, uint sigToken, uint addrKind, uint addr1, uint addr2, uint addr3, uint startOffset, uint endOffset)
138138
{
139-
msw.DefineLocalVariable (nextLocalIndex++, name);
139+
// msw.DefineLocalVariable (nextLocalIndex++, name);
140+
msw.DefineLocalVariable ((int)addr1, name);
140141
}
141142

142143
#endregion

core/RoslynMdbWriter/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ for handling changes of Roslyn.
1818
- MetadataWriter.guidIndex -> MetadataWriter.heaps.\_guids
1919
- Implment dummy MdbWriter.GetDebugInfo instead of returning nothing.
2020
- Make MdbWriter implement IPdbWriter.
21+
- MdbWriter.DefineLocalVariable2 uses addr1 as a local variable index rather than
22+
counting index with nextLocalIndex.

samples/Basic/Assets/Scripts/Test02.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ public class Test02 : MonoBehaviour
66
void Start()
77
{
88
Debug.Log("Test02.Start");
9-
GetComponent<Text>().text = "02";
9+
GetComponent<Text>().text = "02:" + Test(-1, 3.5f);
10+
}
11+
12+
string Test(int param_a, float param_b)
13+
{
14+
int local_c = (int)(param_a + param_b);
15+
if (param_a > 0)
16+
{
17+
string local_d = "A+" + param_b;
18+
return local_d;
19+
}
20+
else
21+
{
22+
string local_e = "A-" + param_b;
23+
return local_e;
24+
}
1025
}
1126
}

0 commit comments

Comments
 (0)