Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ReadSymbols in a Module that is already created #686

Merged
merged 4 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mono.Cecil/AssemblyReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void ReadMethodsSymbols (TypeDefinition type, ISymbolReader symbol_reader)
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);
}
}
Expand Down
22 changes: 22 additions & 0 deletions Test/Mono.Cecil.Tests/PortablePdbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -748,5 +748,27 @@ public void DoubleWriteAndReadAgainModuleWithDeterministicMvid ()
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);
}

}
}
Binary file not shown.
Binary file not shown.