-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add support for embedding C# source in portable pdb #12353
Conversation
f88dee0
to
c044ec8
Compare
Reviewers: consider this PR a design proposal at this stage. I am scheduling a design review. All feedback is welcome, but you may want to hold off on reviewing the code details until that has taken place and been approved. |
Re-tagging as PR for personal review only. I will open a separate issue for the detailed proposal for design review and will be making updates to the proposal based on offline feedback. |
/// <summary> | ||
/// The source text to embed in the PDB. (If any, otherwise null.) | ||
/// </summary> | ||
public readonly SourceText EmbeddedText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name this EmbeddedTextOpt to emphasize it might be null.
dde8ac2
to
750d537
Compare
I've moved all design notes to #12625 and updated them. |
c8c374b
to
8a5619f
Compare
private void AddEmbeddedFilesToCommandLine(CommandLineBuilderExtension commandLine) | ||
{ | ||
// If there were no additional files passed in, don't add any /additionalfile: switches | ||
// on the command-line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this comment is trying to convey. Perhaps it's stale?
@@ -143,18 +153,15 @@ internal SourceText ReadFileContent(CommandLineSourceFile file, IList<Diagnostic | |||
/// <param name="diagnostics">Storage for diagnostics.</param> | |||
/// <param name="normalizedFilePath">If given <paramref name="file"/> opens successfully, set to normalized absolute path of the file, null otherwise.</param> | |||
/// <returns>File content or null on failure.</returns> | |||
internal SourceText ReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string normalizedFilePath) | |||
internal SourceText TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string normalizedFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was for consistency re: feeback to make analogous TryReadEmbeddedFileContent express it can fail and return null. But I neglected the overload without the normalizedFilePath. I will rename that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I have a couple of general questions that I was too lazy to search for answers myself.
|
(*) Caveat: if you spell source and /embed files differently on command line that happen to be the same physical file (e.g. casing difference, symbolic link, '.\foo' vs 'foo' etc. etc.), they will be processed as distinct files. We discussed that in design review quite a bit. I came to the review with a design that did not have this problem, but it had separate mechanisms for embedding-and-compiling a source file (such that path need not be repeated) vs. embedding an additional file. The room felt that we should have just one switch and one IEnumerable emit arg and it was worth the tradeoff of reading twice for the multiple spelling case. |
21fbf99
to
5264cfb
Compare
LGTM |
@@ -130,10 +140,10 @@ internal virtual MetadataReferenceResolver GetCommandLineMetadataReferenceResolv | |||
/// <param name="file">Source file information.</param> | |||
/// <param name="diagnostics">Storage for diagnostics.</param> | |||
/// <returns>File content or null on failure.</returns> | |||
internal SourceText ReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) | |||
internal SourceText TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TryReadFileContent [](start = 28, length = 18)
We sometimes use the Opt
suffix for methods that may return null
instead of using the Try
prefix (which is more common with the bool/out pattern). I don't have strong feelings about this, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's a precedent for this pattern and it was @tmat's suggestion from his earlier review, I'm going to stick with Try
Conflicts: src/Workspaces/Core/Portable/WorkspacesResources.resx
4148cb1
to
c5d42df
Compare
@@ -10,8 +10,11 @@ internal partial class SpecializedCollections | |||
private partial class Empty | |||
{ | |||
internal class Set<T> : Collection<T>, ISet<T> | |||
#if COMPILERCORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ifdefs are ugly but most expedient way to make progress against the feedback. I can fix it up by tweaking closed project to include IReadOnlySet.cs after this is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which feedback? In general we should avoid all #ifdef
in the compiler (and Roslyn in general). They contribute negatively to the maintenance and experience of the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize now that I don't need to wait for this to be merged to fix the issue. I can submit a PR ASAP to closed/ to pull in IReadOnlySet.cs, then remove these. Will do!
I fully agree about ifdefs!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR sent.
LGTM |
Hi, so finally it e.g. found, the all source path starts with e.g. c:\users\my_private_account\some_other_private_ifnfo\project\src I can imagine, that the feature can be introduced by a new MSBuild property EmbedAllSourcesShrinkPath, or even as an default behavior in this case the EmbedAllSources property is I should note it is not a critical thing - as a kind of workaround I can use subst of the path, so I can get rid off some parts of path I would like to not expose. |
We actually have such feature. Add
and compile with Note: you should only build with I'd also recommend checking out Source Link. It does the SourceRoot mapping (and more) for you. |
@tmat
and it is pretty working for me for now (some of them might not bee needed but i haven't time to check properly one by one) |
Glad it works for you.
Issue and a workaround is tracked by dotnet/msbuild#1479
Tracked here: dotnet/sdk#1458 |
Implement #12625 for C# and portable PDBs. Native PDB and VB implementation to follow as separate change once this is approved.
Also fix #12814