Overriding .NETs ToString() method can cause unexpected behaviour when using Transcripts #23804
Open
5 tasks done
Labels
Needs-Triage
The issue is new and needs to be triaged by a work group.
Prerequisites
Steps to reproduce
When PowerShell Transcripting is enabled, this code is invoked, which calls ToString() against any parameter passed to a cmdlet, regardless of type.
If the ToString() method which is called also calls a cmdlet with $this, this creates infinite recursion as the linked code keeps calling ToString(), which calls a cmdlet, which calls ToString() etc.
The issue is not observed when transcription is disabled.
This recursion causes the script to slow dramatically - I assume it is exhausting the stack, throwing a handled exception, which then allows everything to unwind and continue execution.
The below is a contrived/minimal example to demonstrate the issue:
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: