Skip to content

Commit

Permalink
Fix build for changed code
Browse files Browse the repository at this point in the history
  • Loading branch information
ynsehoornenborg committed Mar 4, 2023
1 parent acda05c commit 26c1a2c
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ public class PreferReadOnlyParametersNodeAction : SyntaxNodeAction<MethodDeclara

public override void Analyze()
{
var parameters = Node.ParameterList.Parameters;
SeparatedSyntaxList<ParameterSyntax> parameters = Node.ParameterList.Parameters;
if (!parameters.Any())
{
return;
}

var aliases = Helper.GetUsingAliases(Node);
var collections = parameters.Where(p => IsReadWriteCollection(p.Type, aliases));
IReadOnlyDictionary<string, string> aliases = Helper.GetUsingAliases(Node);
IEnumerable<ParameterSyntax> collections = parameters.Where(p => IsReadWriteCollection(p.Type, aliases));
if (!collections.Any())
{
return;
}
var accesses = Node.DescendantNodes().OfType<MemberAccessExpressionSyntax>();
var setters = Node.DescendantNodes()
IEnumerable<MemberAccessExpressionSyntax> accesses = Node.DescendantNodes().OfType<MemberAccessExpressionSyntax>();
IEnumerable<ElementAccessExpressionSyntax> setters = Node.DescendantNodes()
.OfType<AssignmentExpressionSyntax>()
.Select(ass => ass.Left as ElementAccessExpressionSyntax);
var invocations = Node.DescendantNodes().OfType<InvocationExpressionSyntax>();
IEnumerable<InvocationExpressionSyntax> invocations = Node.DescendantNodes().OfType<InvocationExpressionSyntax>();
foreach (ParameterSyntax collectionParameter in collections)
{
var parameterName = collectionParameter.Identifier.Text;
Expand All @@ -57,7 +57,7 @@ public override void Analyze()
!setters.Any(element => element != null && IsCallingParameter(element.Expression, parameterName)) &&
!invocations.Any(voc => RequiresReadWrite(voc, parameterName)))
{
var location = collectionParameter.Type.GetLocation();
Location location = collectionParameter.Type.GetLocation();
ReportDiagnostic(location, collectionParameter.Identifier.Text);
}
}
Expand All @@ -82,13 +82,13 @@ private static bool IsModifyingMember(SimpleNameSyntax name)

private bool RequiresReadWrite(InvocationExpressionSyntax invocation, string parameterName)
{
var arguments = invocation.ArgumentList.Arguments.Where(arg => IsCallingParameter(arg.Expression, parameterName));
IEnumerable<ArgumentSyntax> arguments = invocation.ArgumentList.Arguments.Where(arg => IsCallingParameter(arg.Expression, parameterName));
if (!arguments.Any())
{
return false;
}
bool needsReadWrite = false;
var symbol = Context.SemanticModel.GetSymbolInfo(invocation).Symbol;
var needsReadWrite = false;
ISymbol symbol = Context.SemanticModel.GetSymbolInfo(invocation).Symbol;
foreach (ArgumentSyntax argument in arguments)
{
if (symbol != null)
Expand Down

0 comments on commit 26c1a2c

Please sign in to comment.