From 1ed8ce12d6adcaa2a974c1d997666922353aa87d Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Thu, 25 Jan 2024 18:21:57 +0100 Subject: [PATCH] update --- .../InvocationExpressionCodeFixProvider.cs | 2 +- ...rtStringConcatToInterpolatedStringTests.cs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/InvocationExpressionCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/InvocationExpressionCodeFixProvider.cs index 0b7ffb0075..12aef8d2b2 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/InvocationExpressionCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/InvocationExpressionCodeFixProvider.cs @@ -122,7 +122,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) case DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString: { CodeAction codeAction = CodeAction.Create( - "Use interpolated string", + "Use string interpolation", ct => ConvertStringConcatToInterpolatedStringAsync(context.Document, invocation, ct), GetEquivalenceKey(diagnostic)); diff --git a/src/Tests/Analyzers.Tests/RCS1267ConvertStringConcatToInterpolatedStringTests.cs b/src/Tests/Analyzers.Tests/RCS1267ConvertStringConcatToInterpolatedStringTests.cs index 5dd83a2b61..96b890ec21 100644 --- a/src/Tests/Analyzers.Tests/RCS1267ConvertStringConcatToInterpolatedStringTests.cs +++ b/src/Tests/Analyzers.Tests/RCS1267ConvertStringConcatToInterpolatedStringTests.cs @@ -39,6 +39,33 @@ void M() ); } + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)] + public async Task Test_Verbatim() + { + await VerifyDiagnosticAndFixAsync(""" +using System; + +class C +{ + void M() + { + string s = [|string.Concat(@"Now: ", DateTime.Now, @", Now UTC: ", DateTime.UtcNow)|]; + } +} +""", """ +using System; + +class C +{ + void M() + { + string s = @$"Now: {DateTime.Now}, Now UTC: {DateTime.UtcNow}"; + } +} +""" + ); + } + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)] public async Task TestNoDiagnostic_SingleArgument() {