GitTools / GitLink

Making .NET open source accessible!
MIT License
554 stars 86 forks source link

Embed source files that do not belong to the git repo #115

Open AArnott opened 7 years ago

AArnott commented 7 years ago

When the build itself generates code, that code won't be in the git repo but may still be valuable to step through. This code can be embedded in the PDB such that (a future version of) the VS debugger can display it.

@tmat: any pointers to docs on how we can add sources files to the PDB?

Project owners: I'm willing to fix this.

tmat commented 7 years ago

csc task/command line:

 /embed                    Embed all source files in the PDB.
 /embed:<file list>        Embed specfic files the PDB
AArnott commented 7 years ago

@nguerrera

AArnott commented 7 years ago

@tmat that switch approach works if your code generators participate and prepare the msbuild items before the compiler is invoked. Does the Csc task accept a parameter for this, and do the msbuild C# targets pass that parameter in from an item list already?

For the person building the PDB, I guess post-compilation adding source files to it is possible, but perhaps we can settle on unadvisable if there is a preferred path which is the above approach. But I'd love to learn how to do that.

AArnott commented 7 years ago

Also, what is this /sourcelink: switch I see? I can't find docs on it. Does it obsolete post-compilation PDB tools such as this one?

nguerrera commented 7 years ago

@(EmbeddedFiles) get passed to /embed

tmat commented 7 years ago

@AArnott Yes, it does. https://github.com/dotnet/roslyn/issues/12759

nguerrera commented 7 years ago

Just pointing out again (see also https://github.com/dotnet/roslyn/pull/15256#discussion_r88746143) that /embed is currently only supported if the pdb being produced is portable.

The design for embedded source accounted for Windows PDBs as well, but due to some funding changes, the testing was not completed for VS 2017 RC. Getting it to work with Windows PDBs is tracked by https://github.com/dotnet/roslyn/issues/13707, which is pushed out passed VS 2017 RTM.

https://github.com/dotnet/roslyn/pull/13138 has a code complete implementation of /embed working for Windows PDBs if you want to play with it sooner.

AArnott commented 7 years ago

/embed is currently only supported if the pdb being produced is portable.

Can you educate me on the downside to that? What prevents everyone from compiling portable pdb's? Is it that only certain debuggers support them? Which ones?

GeertvanHorrik commented 7 years ago

A bit late to join the party, but this is for after the changes by @AArnott , right?

AArnott commented 7 years ago

That's how I'm seeing it, yes. And in fact, the way the discussion is going, it may not really be a gitlink 'feature'. Rather, simply emitting warnings for files that aren't in the git repo with a recommendation that they arrange to add their generated files to the @(EmbeddedFiles) item list.