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
124
124
SyntaxFactory . AssignmentExpression (
125
125
SyntaxKind . SimpleAssignmentExpression ,
126
126
SyntaxFactory . ElementAccessExpression (
127
- memberAccessExpression . Expression ,
127
+ memberAccessExpression . Expression . WithoutTrailingTrivia ( ) ,
128
128
SyntaxFactory . BracketedArgumentList (
129
129
SyntaxFactory . SeparatedList ( new [ ] { arguments [ 0 ] } ) ) ) ,
130
130
arguments [ 1 ] . Expression ) ;
Original file line number Diff line number Diff line change @@ -232,6 +232,27 @@ await VerifyCS.VerifyCodeFixAsync(
232
232
@"
233
233
using Microsoft.AspNetCore.Http;
234
234
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
+
235
256
var context = new DefaultHttpContext();
236
257
context.Request.Headers[""Accept""] = ""text/html""{|CS1002:|}"
237
258
}
You can’t perform that action at this time.
0 commit comments