private static void GetFakeExpressions(IReadOnlyList <TypeSymbol> types, List <Expression> expressions) { foreach (var type in types) { expressions.Add(FakeExpression.Create(type)); } }
/// <summary> /// Gets the set of possible parameters for an argument that would follow after the specified set of existing arguments. /// </summary> public virtual void GetNextPossibleParameters(Signature signature, IReadOnlyList <Expression> arguments, List <Parameter> possibleParameters) { // default implementation asks for the layout given an additional parameter with type Unknown var newArguments = s_expressionListPool.AllocateFromPool(); var argumentParameters = s_parameterListPool.AllocateFromPool(); try { // add fake argument w/ unknown type to end of arguments newArguments.AddRange(arguments); newArguments.Add(FakeExpression.Create(ScalarTypes.Unknown)); // try to get parameter layout for this extended list of arguments GetArgumentParameters(signature, newArguments, argumentParameters); // use last parameter in this layout possibleParameters.Add(argumentParameters[argumentParameters.Count - 1]); } finally { s_expressionListPool.ReturnToPool(newArguments); s_parameterListPool.ReturnToPool(argumentParameters); } }
public static void Right_InvalidType_ThrowsArgumentException(Type type) { Expression right = new FakeExpression(ExpressionType.Parameter, type); Assert.Throws<ArgumentException>("right", () => Expression.Assign(Expression.Variable(typeof(object)), right)); }
public static void Left_InvalidType_ThrowsArgumentException(Type type) { Expression left = new FakeExpression(ExpressionType.Parameter, type); Assert.Throws<ArgumentException>("left", () => Expression.Assign(left, Expression.Parameter(typeof(int)))); }