Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/runtime/Binding/Binders.cs (C#)

Code before:
                        // argument's type should match the parameter type, but sometimes it won't, e.g. with COM,
                        // the default can be System.Reflection.Missing.Value and this value is handled specially.
                        argExprs[i] = Expression.Constant(argValue);
                    }
                }
                else
                {
                    if (parameterType.IsByRef)
                    {
                        if (args[i].Value is not PSReference)
                        {
                            return Compiler.CreateThrow(typeof(object), typeof(MethodException),
                                     new[] { typeof(string), typeof(Exception), typeof(string), typeof(object[]) },
                                     "NonRefArgumentToRefParameterMsg", null, ExtendedTypeSystem.NonRefArgumentToRefParameter,
                                     new object[] { i + 1, typeof(PSReference).FullName, "[ref]" });
                        }

                        var temp = Expression.Variable(parameterType.GetElementType());
                        temps.Add(temp);
                        var psRefValue = Expression.Property(args[i].Expression.Cast(typeof(PSReference)), CachedReflectionInfo.PSReference_Value);
                        initTemps.Add(Expression.Assign(temp, psRefValue.Convert(temp.Type)));
                        copyOutTemps.Add(Expression.Assign(psRefValue, temp.Cast(typeof(object))));

                        argExprs[i] = temp;
                        // Log the PSReference type, or its actual value in this case?
                        argsToLog.Add(args[i].Expression);
                    }
                    else
                    {
                        var convertedArg = args[i].CastOrConvertMethodArgument(
                            parameterType,
                            paramName,
                            mi.Name,
                            allowCastingToByRefLikeType,
                            temps,
                            initTemps);

                        argExprs[i] = convertedArg;
                        // If the converted arg is a byref-like type, then we log the original arg.
                        argsToLog.Add(convertedArg.Type.IsByRefLike
                            ? args[i].Expression
                            : convertedArg);
                    }
                }
            }

            Expression call;
            if (constructorInfo != null)
            {
                if (invocationType == MethodInvocationType.BaseCtor)
                {

Review comment (suggestion):
@TravisEz13 @SeeminglyScience For by-ref parameters (`out` or `ref` parameters) that we pass in a `PSReference` instance, shall we simply log the `PSReference` type or the value the instance holds? For methods with `out` parameters, the value is usually `null`.

Code after:
                        // We don't specify the parameter type in the constant expression. Normally the default
                        // argument's type should match the parameter type, but sometimes it won't, e.g. with COM,
                        // the default can be System.Reflection.Missing.Value and this value is handled specially.
                        argExprs[i] = Expression.Constant(argValue);
                    }
                }
                else
                {
                    if (parameterType.IsByRef)
                    {
                        if (args[i].Value is not PSReference)
                        {
                            return Compiler.CreateThrow(typeof(object), typeof(MethodException),
                                     new[] { typeof(string), typeof(Exception), typeof(string), typeof(object[]) },
                                     "NonRefArgumentToRefParameterMsg", null, ExtendedTypeSystem.NonRefArgumentToRefParameter,
                                     new object[] { i + 1, typeof(PSReference).FullName, "[ref]" });
                        }

                        var temp = Expression.Variable(parameterType.GetElementType());
                        temps.Add(temp);
                        var psRefValue = Expression.Property(args[i].Expression.Cast(typeof(PSReference)), CachedReflectionInfo.PSReference_Value);
                        initTemps.Add(Expression.Assign(temp, psRefValue.Convert(temp.Type)));
                        copyOutTemps.Add(Expression.Assign(psRefValue, temp.Cast(typeof(object))));

                        argExprs[i] = temp;
                        argsToLog.Add(temp);
                    }
                    else
                    {
                        var convertedArg = args[i].CastOrConvertMethodArgument(
                            parameterType,
                            paramName,
                            mi.Name,
                            allowCastingToByRefLikeType,
                            temps,
                            initTemps);

                        argExprs[i] = convertedArg;
                        // If the converted arg is a byref-like type, then we log the original arg.
                        argsToLog.Add(convertedArg.Type.IsByRefLike
                            ? args[i].Expression
                            : convertedArg);
                    }
                }
            }

            Expression call;
            if (constructorInfo != null)
            {
                if (invocationType == MethodInvocationType.BaseCtor)
                {