internal static ExpressionSyntax OnlyReturn(SyntaxNodeAnalysisContext context, string ident, AttributeSyntax att, SyntaxList <StatementSyntax> statements) { var only = statements.Only(); if (only == null) { Diagnostic(context, ident, att.GetLocation(), statements.Count + " statements"); return(null); } var ret = only as ReturnStatementSyntax; if (ret == null) { Diagnostic(context, ident, only.GetLocation(), "no return"); return(null); } if (ret.Expression == null) { Diagnostic(context, ident, only.GetLocation(), "no return expression"); return(null); } return(ret.Expression); }