Skip to content

Commit

Permalink
fix: symbol comparison for vb actions
Browse files Browse the repository at this point in the history
instead of taking original definition, we parse out the details and create a key that matches what will come from the rule files.

also vb likes to capitalize so we make the string comparison ignore case
  • Loading branch information
cslong committed Jul 13, 2022
1 parent 8bc7e9d commit 06c5a81
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/CTA.Rules.Update/VisualBasicActionsRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,16 @@ public override SyntaxNode VisitExpressionStatement(ExpressionStatementSyntax no
return newNode;
}

var nodeKey = symbol.OriginalDefinition.ToString();
var methodSymbol = (IMethodSymbol)symbol;
var prefix = methodSymbol.IsExtensionMethod
? methodSymbol.ReceiverType?.ToString() ?? ""
: methodSymbol.ContainingType?.ToString() ?? "";
var nodeKey =
$"{prefix}.{symbol.Name}({string.Join(", ", methodSymbol.Parameters.Select(p => p.Type))})";

foreach (var action in _allActions.OfType<ExpressionAction>())
{
if (nodeKey == action.Key)
if (string.Equals(nodeKey, action.Key, StringComparison.OrdinalIgnoreCase))
{
var actionExecution = new GenericActionExecution(action, _filePath) { TimesRun = 1 };
try
Expand Down Expand Up @@ -325,7 +330,7 @@ public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax

foreach (var action in _allActions.OfType<InvocationExpressionAction<InvocationExpressionSyntax>>())
{
if (nodeKey == action.Key)
if (string.Equals(nodeKey,action.Key, StringComparison.OrdinalIgnoreCase))
{
var actionExecution = new GenericActionExecution(action, _filePath) { TimesRun = 1 };
try
Expand Down

0 comments on commit 06c5a81

Please sign in to comment.