File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/Framework/AspNetCoreAnalyzers Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ private static bool CanReplaceWithIndexer(Diagnostic diagnostic, SyntaxNode root
124124 SyntaxFactory . AssignmentExpression (
125125 SyntaxKind . SimpleAssignmentExpression ,
126126 SyntaxFactory . ElementAccessExpression (
127- memberAccessExpression . Expression ,
127+ memberAccessExpression . Expression . WithoutTrailingTrivia ( ) ,
128128 SyntaxFactory . BracketedArgumentList (
129129 SyntaxFactory . SeparatedList ( new [ ] { arguments [ 0 ] } ) ) ) ,
130130 arguments [ 1 ] . Expression ) ;
Original file line number Diff line number Diff line change @@ -232,6 +232,27 @@ await VerifyCS.VerifyCodeFixAsync(
232232 @"
233233using Microsoft.AspNetCore.Http;
234234
235+ var context = new DefaultHttpContext();
236+ context.Request.Headers[""Accept""] = ""text/html""{|CS1002:|}"
237+ } ,
238+
239+ // With trailing trivia
240+ {
241+ @"
242+ using Microsoft.AspNetCore.Http;
243+
244+ var context = new DefaultHttpContext();
245+ {|#0:context.Request.Headers
246+ .Add(""Accept"", ""text/html"")|}{|CS1002:|}" ,
247+ new [ ]
248+ {
249+ new DiagnosticResult ( DiagnosticDescriptors . DoNotUseIHeaderDictionaryAdd )
250+ . WithLocation ( 0 )
251+ . WithMessage ( Resources . Analyzer_HeaderDictionaryAdd_Message )
252+ } ,
253+ @"
254+ using Microsoft.AspNetCore.Http;
255+
235256var context = new DefaultHttpContext();
236257context.Request.Headers[""Accept""] = ""text/html""{|CS1002:|}"
237258 }
You can’t perform that action at this time.
0 commit comments