static void AnalyzeParameterList(SyntaxNodeAnalysisContext nodeContext) { var node = nodeContext.Node as TypeParameterListSyntax; var member = node.Parent; if (member == null) return; var memberSymbol = nodeContext.SemanticModel.GetDeclaredSymbol(member); if (memberSymbol.IsAbstract || memberSymbol.IsVirtual || memberSymbol.IsOverride) return; if (memberSymbol.ExplicitInterfaceImplementations().Length > 0) return; var walker = new ReferenceFinder(nodeContext); walker.Visit(member); foreach (var param in node.Parameters) { var sym = nodeContext.SemanticModel.GetDeclaredSymbol(param); if (sym == null) continue; if (!walker.UsedTypeParameters.Contains(sym)) { var diagnostic = Diagnostic.Create(descriptor, param.Identifier.GetLocation(), sym.Name); nodeContext.ReportDiagnostic(diagnostic); } } }
static void AnalyzeParameterList(SyntaxNodeAnalysisContext nodeContext) { if (nodeContext.IsFromGeneratedCode()) { return; } var node = nodeContext.Node as TypeParameterListSyntax; var member = node.Parent; if (member == null) { return; } var memberSymbol = nodeContext.SemanticModel.GetDeclaredSymbol(member); if (memberSymbol.IsAbstract || memberSymbol.IsVirtual || memberSymbol.IsOverride) { return; } if (memberSymbol.ExplicitInterfaceImplementations().Length > 0) { return; } var walker = new ReferenceFinder(nodeContext); walker.Visit(member); foreach (var param in node.Parameters) { var sym = nodeContext.SemanticModel.GetDeclaredSymbol(param); if (sym == null) { continue; } if (!walker.UsedTypeParameters.Contains(sym)) { var diagnostic = Diagnostic.Create(descriptor, param.Identifier.GetLocation(), sym.Name); nodeContext.ReportDiagnostic(diagnostic); } } }