csharpstandard icon indicating copy to clipboard operation
csharpstandard copied to clipboard

Correct 2 x grammar rules for compilation unit name in #line

Open RexJaeschke opened this issue 1 year ago • 3 comments

Good catch, @logeshkumars0604!

This PR addresses Issue #1118.

The " vs. # error was introduced in V6 when we converted to the ANTLR grammar notation.

The ability to have an empty filename was never tested, but as you point out, it does work, so I have made the name contents zero-or-more characters, instead of one-or-more. I tested this using #line 300 "" along with CallerFilePathAttribute.

RexJaeschke avatar May 25 '24 16:05 RexJaeschke

closing and reopening to rerun the CI builds.

BillWagner avatar May 28 '24 13:05 BillWagner

6.5.8 Line directives, states

Line directives may be used to alter the line numbers and compilation unit names that are reported by the compiler in output such as warnings and errors.

Note the presence of "reported": there is no requirement that such a reported name map to anything in a file system, so why not allow an empty string name?

RexJaeschke avatar Jun 11 '24 11:06 RexJaeschke

From the 2024-09-04 TG2 call:

There appear to be 2 issues:

  1. Conflicting text for the existing grammar.
  2. Whether we want to allow an empty string. Just because Roslyn allows it is not necessarily a reason for the spec to do so.

After a short discussion, Rex agreed to take another look.

RexJaeschke avatar Sep 05 '24 13:09 RexJaeschke

Having looked at this again, I don't have more to add, and I've re-added the "Meeting discuss" label.

RexJaeschke avatar Nov 04 '24 15:11 RexJaeschke

Roslyn crash reported as https://github.com/dotnet/msbuild/issues/11168

jskeet avatar Dec 12 '24 12:12 jskeet