diff --git a/Philips.CodeAnalysis.MaintainabilityAnalyzers/Maintainability/PreferReadOnlyParametersAnalyzer.cs b/Philips.CodeAnalysis.MaintainabilityAnalyzers/Maintainability/PreferReadOnlyParametersAnalyzer.cs index 6b98dcf6f..ca1ddac9a 100644 --- a/Philips.CodeAnalysis.MaintainabilityAnalyzers/Maintainability/PreferReadOnlyParametersAnalyzer.cs +++ b/Philips.CodeAnalysis.MaintainabilityAnalyzers/Maintainability/PreferReadOnlyParametersAnalyzer.cs @@ -29,23 +29,23 @@ public class PreferReadOnlyParametersNodeAction : SyntaxNodeAction parameters = Node.ParameterList.Parameters; if (!parameters.Any()) { return; } - var aliases = Helper.GetUsingAliases(Node); - var collections = parameters.Where(p => IsReadWriteCollection(p.Type, aliases)); + IReadOnlyDictionary aliases = Helper.GetUsingAliases(Node); + IEnumerable collections = parameters.Where(p => IsReadWriteCollection(p.Type, aliases)); if (!collections.Any()) { return; } - var accesses = Node.DescendantNodes().OfType(); - var setters = Node.DescendantNodes() + IEnumerable accesses = Node.DescendantNodes().OfType(); + IEnumerable setters = Node.DescendantNodes() .OfType() .Select(ass => ass.Left as ElementAccessExpressionSyntax); - var invocations = Node.DescendantNodes().OfType(); + IEnumerable invocations = Node.DescendantNodes().OfType(); foreach (ParameterSyntax collectionParameter in collections) { var parameterName = collectionParameter.Identifier.Text; @@ -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); } } @@ -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 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)