public bool IsExpression (string expr) { if (expr == null) return false; using (ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser (SupportedLanguage.CSharp, new StringReader (expr))) { var parsedExpr = parser.ParseExpression (); if (parsedExpr == null) return false; var visitor = new ICSharpCode.NRefactory.PrettyPrinter.CSharpOutputVisitor (); parsedExpr.AcceptVisitor (visitor, null); return Strip (expr) == Strip (visitor.Text); } }