@@ -508,7 +508,7 @@ static int getTextPosition(TextLineCollection lines, LinePosition position)
508508 }
509509
510510 [ Fact ]
511- public void Diagnostics ( )
511+ public void Diagnostics_01 ( )
512512 {
513513 var source =
514514@"class Program
@@ -536,6 +536,53 @@ static void Main()
536536 Diagnostic ( ErrorCode . ERR_NameNotInContext , "B" ) . WithArguments ( "B" ) . WithLocation ( 8 , 9 ) ) ;
537537 }
538538
539+ [ Fact ]
540+ public void Diagnostics_02 ( )
541+ {
542+ var source =
543+ @"class Program
544+ {
545+ static void Main()
546+ {
547+ #line (100, 1) - (100, ) 1 ""a.txt""
548+ A();
549+ #line (200, 1) - (200, 100) 2 ""b.txt""
550+ B();
551+ #line (300, 1) - (300, 100) x ""c.txt""
552+ C();
553+ }
554+ }" . NormalizeLineEndings ( ) ;
555+
556+ var comp = CreateCompilation ( source ) ;
557+ comp . VerifyDiagnostics (
558+ // (5,24): error CS8938: The #line directive value is missing or out of range
559+ // #line (100, 1) - (100, ) 1 "a.txt"
560+ Diagnostic ( ErrorCode . ERR_LineSpanDirectiveInvalidValue , ")" ) . WithLocation ( 5 , 24 ) ,
561+ // (6,9): error CS0103: The name 'A' does not exist in the current context
562+ // A();
563+ Diagnostic ( ErrorCode . ERR_NameNotInContext , "A" ) . WithArguments ( "A" ) . WithLocation ( 6 , 9 ) ,
564+ // (10,9): error CS0103: The name 'C' does not exist in the current context
565+ // C();
566+ Diagnostic ( ErrorCode . ERR_NameNotInContext , "C" ) . WithArguments ( "C" ) . WithLocation ( 10 , 9 ) ,
567+ // b.txt(200,8): error CS0103: The name 'B' does not exist in the current context
568+ // B();
569+ Diagnostic ( ErrorCode . ERR_NameNotInContext , "B" ) . WithArguments ( "B" ) . WithLocation ( 200 , 8 ) ,
570+ // b.txt(201,29): error CS1578: Quoted file name, single-line comment or end-of-line expected
571+ // #line (300, 1) - (300, 100) x "c.txt"
572+ Diagnostic ( ErrorCode . ERR_MissingPPFile , "x" ) . WithLocation ( 201 , 29 ) ) ;
573+
574+ var tree = comp . SyntaxTrees [ 0 ] ;
575+ var actualLineMappings = GetLineMappings ( tree ) ;
576+ var expectedLineMappings = new [ ]
577+ {
578+ "(0,0)-(3,7) -> : (0,0)-(3,7)" ,
579+ "(5,0)-(5,14) -> : (5,0)-(5,14)" ,
580+ "(7,0)-(7,14),1 -> b.txt: (199,0)-(199,100)" ,
581+ "(9,0)-(11,1) -> : (9,0)-(11,1)"
582+ } ;
583+ AssertEx . Equal ( expectedLineMappings , actualLineMappings ) ;
584+ }
585+
539586 [ Fact ]
540587 public void SequencePoints ( )
541588 {
0 commit comments