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

SymReader.GetMethodFromDocumentPosition doesn't always return the best method #196

Open
KirillOsenkov opened this issue Feb 24, 2019 · 0 comments

Comments

@KirillOsenkov
Copy link
Member

KirillOsenkov commented Feb 24, 2019

This logic to pick a single method from a line doesn't always return the best method and depends on the order of methods in the metadata table.

foreach (var (methodId, version) in methods)
{
if (candidate.Id.IsDefault || methodId < candidate.Id)
{
candidate = (methodId, version);
}
}

Methods can overlap, for example lambda bodies inside methods. An interesting case is that all instance fields initializers are unified into the constructor method, and the span of that ctor method starts at the beginning of the first field to the end of the last field (or the actual constructor itself). Same for static ctor.

Because of the way the overlapping methods are split into "layers" by PartitionToNonOverlappingSubsequences the methods with a smaller span usually end up in higher layers.

The current logic seems to pick the method that appears higher in the metadata table. Instead, it should pick the method with the smaller span (distance between the first and the last line). I think this is always just the last method.

I know that the correct way to do this is to use the GetMethodsFromDocumentPosition and then select the best match yourself, but feels like GetMethodFromDocumentPosition could always reliably return the correct method and it currently doesn't.

Microsoft.DiaSymReader.PortablePdb.dll!Microsoft.DiaSymReader.PortablePdb.SymReader.GetMethodFromDocumentPosition Line 498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant