KEMBAR78
MemberwiseClone is missing after upgrade to powershell 7.5.0 · Issue #24898 · PowerShell/PowerShell · GitHub
Skip to content

MemberwiseClone is missing after upgrade to powershell 7.5.0 #24898

@jxballack333

Description

@jxballack333

Prerequisites

Steps to reproduce

After i upgrade to powershell 7.5.0 yesterday i starts to notice my code base throw error: Method invocation failed because [#ClassName] does not contain a method named 'MemberwiseClone'. Also find the issue mentioned here: #24139

Expected behavior

class MyClass {
     [string]$Name

     [object] CloneProblem() {
         return $this.MemberwiseClone()
    }
}

$obj = [MyClass]::new()
$obj.CloneProblem()

Actual behavior

InvalidOperation:
Line |
   6 |          return $this.MemberwiseClone()  # Fails with "does not contai …
     |                 ~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [MyClass] does not contain a method named 'MemberwiseClone'.

Error details

Exception             : System.Management.Automation.RuntimeException: Method invocation failed because [MyClass]
                        does not contain a method named 'MemberwiseClone'.
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
                        funcContext, Exception exception)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
                           at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke
                        clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1
                        variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object
                        input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope,
                        ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object
                        scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean
                        propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine,
                        Object[] args)
                           at System.Management.Automation.ScriptBlock.InvokeAsMemberFunctionT[T](Object instance,
                        Object[] args)
                           at
                        System.Management.Automation.Internal.ScriptBlockMemberMethodWrapper.InvokeHelperT[T](Object
                        instance, Object sessionStateInternal, 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)

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Ubuntu 22.04.5 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    7.5-regressionThe issue is a regressionIssue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions