public void ExpressionTupletizer_IsTuple() { AssertEx.ThrowsException <ArgumentNullException>(() => ExpressionTupletizer.IsTuple(type: null), ex => Assert.AreEqual("type", ex.ParamName)); foreach (var t in new[] { typeof(Tuple <int>), typeof(Tuple <int, int>), typeof(Tuple <int, int, int>), typeof(Tuple <int, int, int, int>), typeof(Tuple <int, int, int, int, int>), typeof(Tuple <int, int, int, int, int, int>), typeof(Tuple <int, int, int, int, int, int, int>), typeof(Tuple <int, int, int, int, int, int, int, Tuple <int> >), typeof(Tuple <int, int, int, int, int, int, int, Tuple <int, int> >), typeof(Tuple <int, int, int, int, int, int, int, Tuple <int, int, int, int, int, int, int, Tuple <int, int, int> > >), }) { Assert.IsTrue(IsTuple(t)); } foreach (var t in new[] { typeof(int), typeof(List <int>), typeof(Tuple <>), typeof(Tuple <,>), typeof(Tuple <int, int, int, int, int, int, int, /*TRest*/ int>), }) { Assert.IsFalse(IsTuple(t)); } }
private static bool IsTuple(Expression expression) { if (expression.NodeType == ExpressionType.New) { // TODO: All of this code really should move up, closer to where we know we're using tuples. if (ExpressionTupletizer.IsTuple(expression.Type)) { return(true); } } return(false); }
private static bool IsTuple(Type type) { return(ExpressionTupletizer.IsTuple(type)); }