private static void AnalyzeInvocation(SyntaxNodeAnalysisContext context) { var invocation = (InvocationExpressionSyntax)context.Node; var symbol = context.SemanticModel.GetSymbolInfo(invocation); if (symbol.Symbol == null) { return; } if (!(symbol.Symbol is IMethodSymbol method)) { return; } if (!KnownMethods.IsGetComponent(method)) { return; } if (!HasInvalidTypeArgument(method, out var identifier)) { return; } context.ReportDiagnostic(Diagnostic.Create(Rule, invocation.GetLocation(), identifier)); }
private static bool IsNonGenericGetComponent(ISymbol symbol, out string methodName) { methodName = null; if (!(symbol is IMethodSymbol method)) { return(false); } if (!KnownMethods.IsGetComponent(method)) { return(false); } if (method.Parameters.Length == 0 || !method.Parameters[0].Type.Matches(typeof(Type))) { return(false); } methodName = method.Name; return(true); }