Not really a bug but:
|
private IEnumerable<Expression> CompileInvocationArguments(IEnumerable<ExpressionAst> arguments) |
|
{ |
|
return arguments == null ? Array.Empty<Expression>() : arguments.Select(CompileExpressionOperand); |
|
} |
And the method in the select:
|
internal Expression CompileExpressionOperand(ExpressionAst exprAst) |
|
{ |
|
var result = Compile(exprAst); |
|
if (result.Type == typeof(void)) |
|
{ |
|
result = Expression.Block(result, ExpressionCache.NullConstant); |
|
} |
|
|
|
return result; |
|
} |
That method is used to compile method arguments, the result is then enumerated twice (once in the first highlighted line, one is the last):
|
var callInfo = new CallInfo(args.Count()); |
|
var classScope = _memberFunctionType != null ? _memberFunctionType.Type : null; |
|
var binder = name.Equals("new", StringComparison.OrdinalIgnoreCase) && @static |
|
? (CallSiteBinder)PSCreateInstanceBinder.Get(callInfo, constraints, publicTypeOnly: true) |
|
: PSInvokeMemberBinder.Get(name, callInfo, @static, propertySet, constraints, classScope); |
|
|
|
var dynamicExprFromBinder = DynamicExpression.Dynamic(binder, typeof(object), args.Prepend(target)); |
This causes all method arguments to be compiled twice due to multiple enumeration. I'm not aware of any bugs due to this behavior, but it probably negatively impacts compile time for complicated member invocations. Also the method supplied to Select is not done in such a way that the delegate can be cached per instance by roslyn.
Not really a bug but:
PowerShell/src/System.Management.Automation/engine/parser/Compiler.cs
Lines 952 to 955 in 904e551
And the method in the select:
PowerShell/src/System.Management.Automation/engine/parser/Compiler.cs
Lines 941 to 950 in 904e551
That method is used to compile method arguments, the result is then enumerated twice (once in the first highlighted line, one is the last):
PowerShell/src/System.Management.Automation/engine/parser/Compiler.cs
Lines 6338 to 6344 in 904e551
This causes all method arguments to be compiled twice due to multiple enumeration. I'm not aware of any bugs due to this behavior, but it probably negatively impacts compile time for complicated member invocations. Also the method supplied to
Selectis not done in such a way that the delegate can be cached per instance by roslyn.