Skip to content

Commit

Permalink
Fix RCS1197 (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Oct 19, 2023
1 parent 3c68a48 commit e4241f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static void Analyze(SyntaxNodeAnalysisContext context, in SimpleMemberInv

SimpleMemberInvocationExpressionInfo invocationInfo2 = SyntaxInfo.SimpleMemberInvocationExpressionInfo(invocationInfo.Expression);

if (!invocationInfo2.Success)
return;

if (invocationInfo2.NameText != "Append")
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,25 @@ void M()
var sb = new StringBuilder().Append($""{Foo}Bar"");
}
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.OptimizeStringBuilderAppendCall)]
public async Task TestNoDiagnostic_NoAppendMethodChain()
{
await VerifyNoDiagnosticAsync(@"
using System.Text;
class C
{
string M()
{
var sb = new StringBuilder();
_ = sb.AppendLine();
return sb.ToString();
}
}
");
}
}
4 changes: 4 additions & 0 deletions src/VisualStudioCode/package/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix [RCS1197](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1197) ([PR](https://github.com/dotnet/roslynator/pull/1226)).

## [4.6.0] - 2023-10-18

### Added
Expand Down

0 comments on commit e4241f7

Please sign in to comment.