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

Support reading embedded pdbs #3454

Merged
merged 2 commits into from
Mar 9, 2022
Merged

Support reading embedded pdbs #3454

merged 2 commits into from
Mar 9, 2022

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented Mar 9, 2022

Description

Building with <DebugType>embedded</DebugType> embeds portable pdb into the dll. This change either takes the pdb that is next to the file, or falls back to trying to read the pdb information from the executable.

Related issue

Fix #1908

Fixes 1. and 2. from #1908 (comment) comment, but not 3. which is a perf improvement). Also keeps the current functionality of looking up the file next to the source in place for backwards compatibility.

If only I saw that comment before I went on to implement this. It spells out exactly what I ended up doing, minus 2 hours spent trying to find the right class and method that can read the embedded pdbs.

@nohwnd
Copy link
Member Author

nohwnd commented Mar 9, 2022

No tests because I could not find any existing tests for this functionality, but it worked just fine when trying it manually for, embdedded, portable and none types of pdbs. If it throws we swallow the error and don't provide the data, and I am only adding another fallback. So it is low risk.

{
using var stream = new FileHelper().GetStream(pdbFilePath, FileMode.Open, FileAccess.Read);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we're using File everywhere in this file maybe it's better use also here or create on top and reuse for future testability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the code that was here before. Are you talking about using System.IO.File to create the stream? Or about using FileHelper to improve testability?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant have all FileHelper or all File usage, but it's not mandatory I don't like the mix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File helper is used here to get the stream via platform abstractions. It is more correct to use FileHelper everywhere here, but that is a bigger change than what I am comfortable with without adding tests. And I don't want to give this more time right now.

@nohwnd nohwnd enabled auto-merge (squash) March 9, 2022 13:34
@nohwnd nohwnd merged commit cb3ebbc into microsoft:main Mar 9, 2022
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

Successfully merging this pull request may close these issues.

Support embedded PDBs in OM
2 participants