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 d9e8b17
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 261 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

This file was deleted.

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
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
6 changes: 2 additions & 4 deletions src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if ROSLYN_4_7_ONLY
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

// <auto-generated>

Expand Down Expand Up @@ -5720,5 +5719,4 @@ protected virtual void VisitCollectionElement(CollectionElementSyntax node)
}
}
}
}
#endif
}

This file was deleted.

6 changes: 2 additions & 4 deletions src/Tools/CodeGeneration/CSharp/Symbols.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if ROSLYN_4_7_ONLY
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

// <auto-generated>

Expand Down Expand Up @@ -1535,5 +1534,4 @@ public static IEnumerable<SyntaxKind> GetKinds(INamedTypeSymbol syntaxSymbol)
}
}
}
}
#endif
}
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 d9e8b17

Please sign in to comment.