Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThays Grazia <thaystg@gmail.com>2020-09-16 01:59:29 +0300
committerGitHub <noreply@github.com>2020-09-16 01:59:29 +0300
commit191f9fc0a79a138fdb634fbb51cf836a86b4e565 (patch)
tree3e8d72c57acf4649fe294b0841d09e873c194a77
parent9276c6d931b191df38af0859166b798689e22381 (diff)
Fix ReadSymbols in a Module that is already created (#686)
* When I try to use ReadSymbols in a Module that is already created, for example: var symbolReader = portablePdbReaderProvider.GetSymbolReader(asm.image, stream); asm.image.ReadSymbols(symbolReader); method.debug_info has a list, but it's empty, so it wasn't entering in the if, but it should, maybe we should change de if to method.debug_info == null || method.debug_info.count = 0. * Adding test. * Fix styling. * Typo Co-authored-by: Jb Evain <jb@evain.net>
-rw-r--r--Mono.Cecil/AssemblyReader.cs2
-rw-r--r--Test/Mono.Cecil.Tests/PortablePdbTests.cs22
-rw-r--r--Test/Resources/assemblies/Microsoft.AspNetCore.Components.dllbin0 -> 145280 bytes
-rw-r--r--Test/Resources/assemblies/Microsoft.AspNetCore.Components.pdbbin0 -> 402944 bytes
4 files changed, 23 insertions, 1 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index d18a51e..ffefbcc 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -419,7 +419,7 @@ namespace Mono.Cecil {
for (int i = 0; i < methods.Count; i++) {
var method = methods [i];
- if (method.HasBody && method.token.RID != 0 && method.debug_info == null)
+ if (method.HasBody && method.token.RID != 0 && (method.debug_info == null || !method.debug_info.HasSequencePoints))
method.debug_info = symbol_reader.Read (method);
}
}
diff --git a/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
index fe60dc8..45b0333 100644
--- a/Test/Mono.Cecil.Tests/PortablePdbTests.cs
+++ b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
@@ -748,5 +748,27 @@ class Program
Assert.AreNotEqual (mvid1_in, mvid2_in);
Assert.AreNotEqual (mvid1_out, mvid2_out);
}
+
+ [Test]
+ public void LoadPdbOnDemand ()
+ {
+ var assembly = File.ReadAllBytes (GetAssemblyResourcePath ("Microsoft.AspNetCore.Components.dll"));
+ var pdb = File.ReadAllBytes (GetAssemblyResourcePath ("Microsoft.AspNetCore.Components.pdb"));
+
+ var module = ModuleDefinition.ReadModule (new MemoryStream (assembly), new ReaderParameters (ReadingMode.Immediate));
+
+ var type = module.GetType ("Microsoft.AspNetCore.Components.Rendering.ComponentState");
+ var main = type.GetMethod ("RenderIntoBatch");
+ var debug_info = main.DebugInformation;
+
+ var pdbReaderProvider = new PdbReaderProvider ();
+ var symbolReader = pdbReaderProvider.GetSymbolReader (module, new MemoryStream (pdb));
+ module.ReadSymbols (symbolReader);
+ type = module.GetType ("Microsoft.AspNetCore.Components.Rendering.ComponentState");
+ main = type.GetMethod ("RenderIntoBatch");
+ debug_info = main.DebugInformation;
+ Assert.AreEqual (9, debug_info.SequencePoints.Count);
+ }
+
}
}
diff --git a/Test/Resources/assemblies/Microsoft.AspNetCore.Components.dll b/Test/Resources/assemblies/Microsoft.AspNetCore.Components.dll
new file mode 100644
index 0000000..dc82ce8
--- /dev/null
+++ b/Test/Resources/assemblies/Microsoft.AspNetCore.Components.dll
Binary files differ
diff --git a/Test/Resources/assemblies/Microsoft.AspNetCore.Components.pdb b/Test/Resources/assemblies/Microsoft.AspNetCore.Components.pdb
new file mode 100644
index 0000000..927bc90
--- /dev/null
+++ b/Test/Resources/assemblies/Microsoft.AspNetCore.Components.pdb
Binary files differ