File tree Expand file tree Collapse file tree
StyleCop.Analyzers.Test/ReadabilityRules
StyleCop.Analyzers/ReadabilityRules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ public async Task VerifyInvalidValueTypeCreationAsync()
9090 public void TestMethod()
9191 {
9292 var v1 = new TestStruct();
93+
94+ System.Console.WriteLine(new TestStruct());
9395 }
9496
9597 private struct TestStruct
@@ -104,6 +106,8 @@ private struct TestStruct
104106 public void TestMethod()
105107 {
106108 var v1 = default(TestStruct);
109+
110+ System.Console.WriteLine(default(TestStruct));
107111 }
108112
109113 private struct TestStruct
@@ -115,7 +119,8 @@ private struct TestStruct
115119
116120 DiagnosticResult [ ] expected =
117121 {
118- this . CSharpDiagnostic ( ) . WithLocation ( 5 , 18 )
122+ this . CSharpDiagnostic ( ) . WithLocation ( 5 , 18 ) ,
123+ this . CSharpDiagnostic ( ) . WithLocation ( 7 , 34 ) ,
119124 } ;
120125
121126 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
5050 {
5151 var syntaxRoot = await document . GetSyntaxRootAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
5252
53- var newExpression = syntaxRoot . FindNode ( diagnostic . Location . SourceSpan ) ;
53+ var newExpression = syntaxRoot . FindNode ( diagnostic . Location . SourceSpan , getInnermostNodeForTie : true ) ;
5454 var newSyntaxRoot = syntaxRoot . ReplaceNode ( newExpression , GetReplacementNode ( newExpression ) ) ;
5555 return document . WithSyntaxRoot ( newSyntaxRoot ) ;
5656 }
@@ -82,7 +82,7 @@ protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fi
8282
8383 var syntaxRoot = await document . GetSyntaxRootAsync ( fixAllContext . CancellationToken ) . ConfigureAwait ( false ) ;
8484
85- var nodes = diagnostics . Select ( diagnostic => syntaxRoot . FindNode ( diagnostic . Location . SourceSpan ) ) ;
85+ var nodes = diagnostics . Select ( diagnostic => syntaxRoot . FindNode ( diagnostic . Location . SourceSpan , getInnermostNodeForTie : true ) ) ;
8686
8787 return syntaxRoot . ReplaceNodes ( nodes , ( originalNode , rewrittenNode ) => GetReplacementNode ( rewrittenNode ) ) ;
8888 }
You can’t perform that action at this time.
0 commit comments