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

Unclear whether EmbeddedText with empty filePath is allowed #31640

Closed
jcouv opened this issue Dec 8, 2018 · 3 comments
Closed

Unclear whether EmbeddedText with empty filePath is allowed #31640

jcouv opened this issue Dec 8, 2018 · 3 comments
Assignees
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Dec 8, 2018

The documentation on EmbeddedText says that empty file path is allowed. But there is no way to create an EmbeddedText with an empty file path.

In EmbeddedText:

        /// <summary>
        /// The path to the file to embed.
        /// </summary>
        /// <remarks>See remarks of <see cref="SyntaxTree.FilePath"/></remarks>
        public string FilePath { get; }

which refers to:

        /// <summary>
        /// The path of the source document file.
        /// </summary>
        /// <remarks>
        /// If this syntax tree is not associated with a file, this value can be empty.
        /// The path shall not be null.
...
        /// </remarks>
        public abstract string FilePath { get; }

But all the factory methods for EmbeddedText throw if the file path is empty:

        /// <exception cref="ArgumentNullException"><paramref name="filePath"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="filePath"/> is empty.</exception>
        private static void ValidateFilePath(string filePath)
 ...

And the private constructor for EmbeddedText asserts that the file path is not empty:

        private EmbeddedText(string filePath, ImmutableArray<byte> checksum, SourceHashAlgorithm checksumAlgorithm, ImmutableArray<byte> blob)
        {
            Debug.Assert(filePath?.Length > 0);

Tagging @tmat

For context, I am trying to modify our test helper CompileAndVerify to embed symbols and source into the produced assembly.

Relates to #12625 (Proposal: Embed sources in PDBs)

@jaredpar
Copy link
Member

jaredpar commented Jan 2, 2019

CC @nguerrera as well.

@jcouv
Copy link
Member Author

jcouv commented Jan 2, 2019

Note: in PR #31679, I'm relaxing this, so that EmbeddedText is consistent with SyntaxTree.FilePath.
I'm currently waiting on a new build of dev16 preview2 to validate end-to-end scenario (debugging with some embedded source that has a blank file name).

@jaredpar jaredpar added the Bug label Jan 2, 2019
@jaredpar jaredpar added this to the 16.0 milestone Jan 2, 2019
@jcouv
Copy link
Member Author

jcouv commented Jan 28, 2019

Confirmed that the file path in EmbeddedText should not be left blank. If it is blank, the debugger will not be able to find and display it (even if there is a match on the hash code).
The linked PR ended up just clarifying the comment.
Closed the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants