Skip to content

Request for Clarification: What is the behavior of relative paths for the purposes of a #line directive? #71202

@otac0n

Description

@otac0n

Version Used:
All Versions (and all VS versions)

Steps to Reproduce:

  1. Create a Source Generator that emits relative paths using a #line directive.
  2. Enable outputting generated files (set EmitCompilerGeneratedFiles to true).
  3. Using Source Generators as the primary build and also use the generated files as a fall-back.

Diagnostic Id:

n/a

Expected Behavior:

Relative paths should be supported and well defined to avoid leaking full path information to SourceLink. Full paths are generally unhelpful and just leak private information.

Actual Behavior:
The documentation here provides no guidance on relative paths:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#error-and-warning-information

It's unclear how to get VS and CSC to agree on what relative paths mean. They currently don't agree depending on whether you are running from command line or from VS. Double-click to navigate to error behavior seems to be inconsistent between versions of Visual Studio.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions