Skip to content

[Proposal]: Enhanced #line directivesΒ #4747

Open

Description

@tmat

Enhanced #line directives

  • Proposed
  • Prototype: Done
  • Implementation: Done
  • Specification: Not Started

Summary

The compiler applies the mapping defined by #line directives to diagnostic locations and sequence points emitted to the PDB.

Currently only the line number and file path can be mapped while the starting character is inferred from the source code. The proposal is to allow specifying full span mapping.

#line (startLine, startChar) - (endLine, endChar) charOffset "fileName"

Spec: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-10.0/enhanced-line-directives.md

Drawbacks

Alternatives

Unresolved questions

Design meetings

Activity

  1. changed the title [-][Proposal]: Column mapping #line directives[/-] [+][Proposal]: WIP - Column mapping #line directives[/+] on May 13, 2021
  2. changed the title [-][Proposal]: WIP - Column mapping #line directives[/-] [+][Proposal]: Column mapping #line directives[/+] on May 13, 2021
  3. tmat commented on May 13, 2021

    @tmat
    MemberAuthor
  4. KalleOlaviNiemitalo commented on May 17, 2021

    @KalleOlaviNiemitalo

    Is there a specification of how tab characters, fullwidth characters, and combining characters affect the column numbers? ECMA-334 5th ed. does not mention "column" at all.

  5. tmat commented on May 17, 2021

    @tmat
    MemberAuthor

    The column information is used to generate sequence points as specified here and column for compiler diagnostics (implementation detail). They have no meaning to the language.

  6. CyrusNajmabadi commented on May 17, 2021

    @CyrusNajmabadi
    Contributor

    I would recomment avoiding the term 'column' and use the term 'character' instead. This matches all our other terminology, and means it doesn't sound related to the 'view'. As an example 'column' is ambiguous when it comes to characters like 'tab'. But 'character' is not.

  7. tmat commented on May 17, 2021

    @tmat
    MemberAuthor

    Sure, let's define column = number of characters from the start of the line.

  8. CyrusNajmabadi commented on May 17, 2021

    @CyrusNajmabadi
    Contributor

    I guess i'm saying: just dont' call it 'column' then. We already use 'character' for that purpose. line/character is a very common idiom used elsewhere just for this purpose and to avoid the confusion here. The recommendation is to not use 'column' unless your feature is literally view oriented, and you are tryign to say: it should show up in this column and should be affected by things like tab-width.

  9. tmat commented on May 17, 2021

    @tmat
    MemberAuthor

    The PDB specification uses column, so we need to map it to that. The compiler already does that mapping.

  10. CyrusNajmabadi commented on May 17, 2021

    @CyrusNajmabadi
    Contributor

    Sure. But this is at the C# language level. I'd prefer it not use that. We could use 'character' or 'start'. Both of which are widespread and clearly avoid this. The mapping to the pdb spec can happen under the covers, with a clear message that the PDB spec here doesn't mean 'column' in any sort of tab-centric manner.

    There's no reason to leak this concept from taht lower layer directly to the c# spec level with that same name. If it helps though, we can have normative text that just clarifies that these are effectively teh same.

  11. tmat commented on May 17, 2021

    @tmat
    MemberAuthor

    As I said the column has no meaning to the language. We can call it foo. Character works too :)

  12. CyrusNajmabadi commented on May 17, 2021

    @CyrusNajmabadi
    Contributor

    Alright. I recommend 'Character' or 'Start' then :)

  13. tmat commented on May 17, 2021

    @tmat
    MemberAuthor

    Character then. End start and start start doesn't work well.

  14. ufcpp commented on May 18, 2021

    @ufcpp

    What is 'character'?

    In VS for Win, Ch = the number of UTF-16 code units, Col = N times wider than a monospace ASCII character?
    image

    In VS Code, Col = the number of UTF-32 codepoints?
    image

  15. added this to the Working Set milestone on May 20, 2021
  16. changed the title [-][Proposal]: Column mapping #line directives[/-] [+][Proposal]: Enhanced #line directives[/+] on Jun 1, 2021
  17. tmat commented on Jun 1, 2021

    @tmat
    MemberAuthor

    Multiple updates and cleanup: removed reference to "column", fixed the formulas to account for empty lines after #line directive, clarified rules and character offset, added more Razor examples.

  18. modified the milestones: Working Set, 10.0 on Jul 9, 2021
  19. added
    Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specification
    on Jan 11, 2022
  20. locked as resolved and limited conversation to collaborators on Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions