Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Jan 25, 2024
1 parent 3908b3d commit c60e221
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override ImmutableArray<string> FixableDiagnosticIds
DiagnosticIdentifiers.CombineEnumerableWhereMethodChain,
DiagnosticIdentifiers.CallExtensionMethodAsInstanceMethod,
DiagnosticIdentifiers.CallThenByInsteadOfOrderBy,
DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString);
DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat);
}
}

Expand Down Expand Up @@ -119,11 +119,11 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
context.RegisterCodeFix(codeAction, diagnostic);
break;
}
case DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString:
case DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat:
{
CodeAction codeAction = CodeAction.Create(
"Use string interpolation",
ct => ConvertStringConcatToInterpolatedStringAsync(context.Document, invocation, ct),
ct => UseStringInterpolationInsteadOfStringConcatAsync(context.Document, invocation, ct),
GetEquivalenceKey(diagnostic));

context.RegisterCodeFix(codeAction, diagnostic);
Expand Down Expand Up @@ -163,7 +163,7 @@ private static Task<Document> CallThenByInsteadOfOrderByAsync(
return document.ReplaceNodeAsync(invocationExpression, newInvocationExpression, cancellationToken);
}

private static Task<Document> ConvertStringConcatToInterpolatedStringAsync(
private static Task<Document> UseStringInterpolationInsteadOfStringConcatAsync(
Document document,
InvocationExpressionSyntax invocationExpression,
CancellationToken cancellationToken)
Expand Down
4 changes: 2 additions & 2 deletions src/Analyzers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7693,8 +7693,8 @@ finally
</Analyzer>
<Analyzer>
<Id>RCS1267</Id>
<Identifier>ConvertStringConcatToInterpolatedString</Identifier>
<Title>Convert 'string.Concat' to interpolated string</Title>
<Identifier>UseStringInterpolationInsteadOfStringConcat</Identifier>
<Title>Use string interpolation instead of 'string.Concat'</Title>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>true</IsEnabledByDefault>
<Samples>
Expand Down
6 changes: 3 additions & 3 deletions src/Analyzers/CSharp/Analysis/InvocationExpressionAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
DiagnosticRules.SimplifyLogicalNegation,
DiagnosticRules.UseCoalesceExpression,
DiagnosticRules.OptimizeMethodCall,
DiagnosticRules.ConvertStringConcatToInterpolatedString);
DiagnosticRules.UseStringInterpolationInsteadOfStringConcat);
}

return _supportedDiagnostics;
Expand Down Expand Up @@ -456,10 +456,10 @@ private static void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext contex
}
case "Concat":
{
if (DiagnosticRules.ConvertStringConcatToInterpolatedString.IsEffective(context)
if (DiagnosticRules.UseStringInterpolationInsteadOfStringConcat.IsEffective(context)
&& argumentCount > 1)
{
ConvertStringConcatToInterpolatedStringAnalysis.Analyze(context, invocationInfo);
UseStringInterpolationInsteadOfStringConcatAnalysis.Analyze(context, invocationInfo);
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Roslynator.CSharp.Analysis;

internal static class ConvertStringConcatToInterpolatedStringAnalysis
internal static class UseStringInterpolationInsteadOfStringConcatAnalysis
{
internal static void Analyze(SyntaxNodeAnalysisContext context, SimpleMemberInvocationExpressionInfo invocationInfo)
{
Expand Down Expand Up @@ -56,7 +56,7 @@ internal static void Analyze(SyntaxNodeAnalysisContext context, SimpleMemberInvo
if (isVerbatim is not null
&& invocationInfo.ArgumentList.IsSingleLine())
{
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.ConvertStringConcatToInterpolatedString, invocationInfo.InvocationExpression);
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.UseStringInterpolationInsteadOfStringConcat, invocationInfo.InvocationExpression);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Analyzers/CSharp/DiagnosticIdentifiers.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,6 @@ public static partial class DiagnosticIdentifiers
public const string InvalidReferenceInDocumentationComment = "RCS1263";
public const string UseVarOrExplicitType = "RCS1264";
public const string RemoveRedundantCatchBlock = "RCS1265";
public const string ConvertStringConcatToInterpolatedString = "RCS1267";
public const string UseStringInterpolationInsteadOfStringConcat = "RCS1267";
}
}
10 changes: 5 additions & 5 deletions src/Analyzers/CSharp/DiagnosticRules.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2628,15 +2628,15 @@ public static partial class DiagnosticRules
customTags: Array.Empty<string>());

/// <summary>RCS1267</summary>
public static readonly DiagnosticDescriptor ConvertStringConcatToInterpolatedString = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString,
title: "Convert 'string.Concat' to interpolated string",
messageFormat: "Convert 'string.Concat' to interpolated string",
public static readonly DiagnosticDescriptor UseStringInterpolationInsteadOfStringConcat = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat,
title: "Use string interpolation instead of 'string.Concat'",
messageFormat: "Use string interpolation instead of 'string.Concat'",
category: DiagnosticCategories.Roslynator,
defaultSeverity: DiagnosticSeverity.Info,
isEnabledByDefault: true,
description: null,
helpLinkUri: DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString,
helpLinkUri: DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat,
customTags: Array.Empty<string>());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace Roslynator.CSharp.Analysis.Tests;

public class RCS1267ConvertStringConcatToInterpolatedStringTests : AbstractCSharpDiagnosticVerifier<InvocationExpressionAnalyzer, InvocationExpressionCodeFixProvider>
public class RCS1267UseStringInterpolationInsteadOfStringConcatTests : AbstractCSharpDiagnosticVerifier<InvocationExpressionAnalyzer, InvocationExpressionCodeFixProvider>
{
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.ConvertStringConcatToInterpolatedString;
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.UseStringInterpolationInsteadOfStringConcat;

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task Test()
{
await VerifyDiagnosticAndFixAsync("""
Expand All @@ -39,7 +39,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task Test_Verbatim()
{
await VerifyDiagnosticAndFixAsync("""
Expand All @@ -66,7 +66,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_SingleArgument()
{
await VerifyNoDiagnosticAsync("""
Expand All @@ -83,7 +83,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_NoStringLiteral()
{
await VerifyNoDiagnosticAsync("""
Expand All @@ -100,7 +100,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_ContainsInterpolatedString()
{
await VerifyNoDiagnosticAsync("""
Expand All @@ -117,7 +117,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_ContainsVerbatimAndNonVerbatimLiterals()
{
await VerifyNoDiagnosticAsync("""
Expand All @@ -134,7 +134,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_ContainsVerbatimAndNonVerbatimLiterals2()
{
await VerifyNoDiagnosticAsync("""
Expand All @@ -151,7 +151,7 @@ void M()
);
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertStringConcatToInterpolatedString)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseStringInterpolationInsteadOfStringConcat)]
public async Task TestNoDiagnostic_SpansOverMultipleLines()
{
await VerifyNoDiagnosticAsync("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ roslynator_analyzers.enabled_by_default = true|false
# Remove redundant catch block
#dotnet_diagnostic.rcs1265.severity = suggestion
# Convert 'string.Concat' to interpolated string
# Use string interpolation instead of 'string.Concat'
#dotnet_diagnostic.rcs1267.severity = suggestion
# Use pattern matching
Expand Down

0 comments on commit c60e221

Please sign in to comment.