The method calls should succeed (it produces no output).
The method call fails with the error below.
Exception :
Type : System.ArgumentException
Message : Expression of type 'System.Int32' cannot be used for parameter of type 'System.IntPtr' of method 'Void Bar(IntPtr)' (Parameter 'arg0')
ParamName : arg0
TargetSite :
Name : ValidateOneArgument
DeclaringType : System.Dynamic.Utils.ExpressionUtils, System.Linq.Expressions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
MemberType : Method
Module : System.Linq.Expressions.dll
Data : System.Collections.ListDictionaryInternal
Source : System.Linq.Expressions
HResult : -2147024809
StackTrace :
at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeMethod(MethodBase mi, DynamicMetaObject target, DynamicMetaObject[] args, Boolean expandParameters, MethodInvocationType invocationType)
at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeDotNetMethod(CallInfo callInfo, String name, PSMethodInvocationConstraints psMethodInvocationConstraints, MethodInvocationType methodInvocationType, DynamicMetaObject target, DynamicMetaObject[] args, BindingRestrictions restrictions, MethodInformation[] mi, Type errorExceptionType)
at System.Management.Automation.Language.PSInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
at System.Management.Automation.PSObject.PSDynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : OperationStopped: (:) [], ArgumentException
FullyQualifiedErrorId : System.ArgumentException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 2
Line : (Add-Type -PassThru -Name Foo1 -MemberDefinition @'
Statement : (Add-Type -PassThru -Name Foo1 -MemberDefinition @'
public static void Bar(IntPtr p = default(IntPtr)) { }
'@)::Bar()
PositionMessage : At line:1 char:1
+ (Add-Type -PassThru -Name Foo1 -MemberDefinition @'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Prerequisites
Steps to reproduce
Expected behavior
The method calls should succeed (it produces no output).
Actual behavior
The method call fails with the error below.
Error details
Environment data
Visuals
No response