private static void HandleAttribute(SyntaxNodeAnalysisContext context) { var attribute = (AttributeSyntax)context.Node; AttributeArgumentListSyntax argumentListSyntax = attribute.ArgumentList; if (argumentListSyntax == null) { return; } SeparatedSyntaxList <AttributeArgumentSyntax> arguments = argumentListSyntax.Arguments; if (arguments.Count < 3) { return; } AttributeArgumentSyntax previousParameter = arguments[1]; int firstParameterLine = arguments[0].GetLine(); int previousLine = previousParameter.GetLine(); Func <int, int, bool> lineCondition; if (firstParameterLine == previousLine) { // arguments must be on same line lineCondition = (param1Line, param2Line) => param1Line == param2Line; } else { // each argument must be on its own line lineCondition = (param1Line, param2Line) => param1Line != param2Line; } for (int i = 2; i < arguments.Count; ++i) { AttributeArgumentSyntax currentParameter = arguments[i]; int currentLine = currentParameter.GetLine(); if (lineCondition(previousLine, currentLine)) { previousLine = currentLine; continue; } context.ReportDiagnostic(Diagnostic.Create(Descriptor, currentParameter.GetLocation())); return; } }