private static ExpressionSyntax GetParameterForInvocation(ParameterInfo arg, int argIndex) { var argIdentifier = arg.GetOrCreateName(argIndex).ToIdentifierName(); // Addressable arguments must be converted to references before passing. if (typeof(IAddressable).IsAssignableFrom(arg.ParameterType) && arg.ParameterType.GetTypeInfo().IsInterface) { return SF.ConditionalExpression( SF.BinaryExpression(SyntaxKind.IsExpression, argIdentifier, typeof(Grain).GetTypeSyntax()), SF.InvocationExpression(argIdentifier.Member("AsReference", arg.ParameterType)), argIdentifier); } return argIdentifier; }