diff --git a/BepInEx.Analyzers/BepInEx.Analyzers.Package/BepInEx.Analyzers.Package.csproj b/BepInEx.Analyzers/BepInEx.Analyzers.Package/BepInEx.Analyzers.Package.csproj index 353d76c..8a10783 100644 --- a/BepInEx.Analyzers/BepInEx.Analyzers.Package/BepInEx.Analyzers.Package.csproj +++ b/BepInEx.Analyzers/BepInEx.Analyzers.Package/BepInEx.Analyzers.Package.csproj @@ -11,7 +11,7 @@ BepInEx.Analyzers - 1.0.8 + 1.0.9 BepInEx https://github.com/BepInEx/BepInEx.Analyzers https://avatars2.githubusercontent.com/u/39589027 diff --git a/BepInEx.Analyzers/BepInEx.Analyzers/HarmonyMethodRefParametersAnalyzer.cs b/BepInEx.Analyzers/BepInEx.Analyzers/HarmonyMethodRefParametersAnalyzer.cs index c562ebd..f872f10 100644 --- a/BepInEx.Analyzers/BepInEx.Analyzers/HarmonyMethodRefParametersAnalyzer.cs +++ b/BepInEx.Analyzers/BepInEx.Analyzers/HarmonyMethodRefParametersAnalyzer.cs @@ -40,17 +40,9 @@ private void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context) if (method.ParameterList?.Parameters.Count <= 0) return; - var memberAccesses = context.Node.DescendantNodes().OfType(); - var varNames = memberAccesses.Select(e => e.Expression.ToString()).ToList(); - CheckExpressionSyntaxes(context, method, varNames, memberAccesses.Cast().ToList()); - var assignments = context.Node.DescendantNodes().OfType(); - varNames = assignments.Select(e => e.Left.ToString()).ToList(); + var varNames = assignments.Select(e => e.Left.ToString()).ToList(); CheckExpressionSyntaxes(context, method, varNames, assignments.Cast().ToList()); - - var accessesByIndex = context.Node.DescendantNodes().OfType(); - varNames = accessesByIndex.Select(e => e.Expression.ToString()).ToList(); - CheckExpressionSyntaxes(context, method, varNames, accessesByIndex.Cast().ToList()); } private static void CheckExpressionSyntaxes(SyntaxNodeAnalysisContext context, MethodDeclarationSyntax method, @@ -60,15 +52,7 @@ private static void CheckExpressionSyntaxes(SyntaxNodeAnalysisContext context, M { foreach (var parameter in method.ParameterList.Parameters) { - // If parameter is a reference type and is not a literal assignment no warning needed var parameterSymbol = context.SemanticModel.GetDeclaredSymbol(parameter, context.CancellationToken); - if (parameterSymbol.Type.IsReferenceType) - { - if (!(expressionSyntaxes[i] is AssignmentExpressionSyntax assignment)) - { - continue; - } - } var parameterName = parameterSymbol.Name; if (parameterSymbol.RefKind == RefKind.None && parameterName == varNames[i])