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

[Proposal]: Enhanced #line directives #4747

Open
3 of 4 tasks
tmat opened this issue May 13, 2021 · 13 comments
Open
3 of 4 tasks

[Proposal]: Enhanced #line directives #4747

tmat opened this issue May 13, 2021 · 13 comments
Assignees
Labels
Implemented Needs ECMA Spec This feature has been implemented in C#, but still needs to be merged into the ECMA specification Proposal champion Proposal
Milestone

Comments

@tmat
Copy link
Member

tmat commented May 13, 2021

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

@tmat tmat changed the title [Proposal]: Column mapping #line directives [Proposal]: WIP - Column mapping #line directives May 13, 2021
@tmat tmat changed the title [Proposal]: WIP - Column mapping #line directives [Proposal]: Column mapping #line directives May 13, 2021
@tmat
Copy link
Member Author

tmat commented May 13, 2021

@NTaylorMullen @jinujoseph FYI

@KalleOlaviNiemitalo
Copy link

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.

@tmat
Copy link
Member Author

tmat commented May 17, 2021

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.

@CyrusNajmabadi
Copy link
Member

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.

@tmat
Copy link
Member Author

tmat commented May 17, 2021

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

@CyrusNajmabadi
Copy link
Member

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.

@tmat
Copy link
Member Author

tmat commented May 17, 2021

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

@CyrusNajmabadi
Copy link
Member

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.

@tmat
Copy link
Member Author

tmat commented May 17, 2021

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

@CyrusNajmabadi
Copy link
Member

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

@tmat
Copy link
Member Author

tmat commented May 17, 2021

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

@ufcpp
Copy link

ufcpp commented May 18, 2021

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

@333fred 333fred added this to the Working Set milestone May 20, 2021
@tmat tmat changed the title [Proposal]: Column mapping #line directives [Proposal]: Enhanced #line directives Jun 1, 2021
@tmat
Copy link
Member Author

tmat commented Jun 1, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implemented Needs ECMA Spec This feature has been implemented in C#, but still needs to be merged into the ECMA specification Proposal champion Proposal
Projects
None yet
Development

No branches or pull requests

7 participants