File tree Expand file tree Collapse file tree
AspNetCoreAnalyzers/Helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,20 +84,43 @@ internal Span Substring(int index)
8484
8585 private static Location GetLocation ( LiteralExpressionSyntax literal , TextSpan textSpan )
8686 {
87- var text = literal . Token . ValueText ;
88- return Location . Create ( literal . SyntaxTree , TextSpan . FromBounds ( GetIndex ( textSpan . Start ) , GetIndex ( textSpan . End ) ) ) ;
87+ var text = literal . Token . Text ;
88+ var start = 0 ;
89+ var verbatim = false ;
90+ while ( start < 3 )
91+ {
92+ if ( text [ start ] == '"' )
93+ {
94+ start ++ ;
95+ break ;
96+ }
97+
98+ if ( text [ start ] == '@' )
99+ {
100+ verbatim = true ;
101+ }
102+
103+ start ++ ;
104+ }
105+
106+ return Location . Create (
107+ literal . SyntaxTree ,
108+ verbatim
109+ ? new TextSpan ( literal . SpanStart + start + textSpan . Start , textSpan . Length )
110+ : TextSpan . FromBounds ( GetIndex ( textSpan . Start ) , GetIndex ( textSpan . End ) ) ) ;
89111
90112 int GetIndex ( int pos )
91113 {
92- var index = literal . SpanStart + 1 ;
93- for ( var j = 0 ; j < pos ; j ++ )
114+ var index = literal . SpanStart + start ;
115+ for ( var i = start ; i < pos + start ; i ++ )
94116 {
95- if ( text [ j ] == '\\ ' )
117+ index ++ ;
118+ if ( text [ i ] == '\\ ' &&
119+ text [ i + 1 ] == '\\ ' )
96120 {
97- index ++ ;
121+ i ++ ;
122+ index += 2 ;
98123 }
99-
100- index ++ ;
101124 }
102125
103126 return index ;
You can’t perform that action at this time.
0 commit comments