Skip to content

Commit d8ce204

Browse files
nohwndCopilot
andcommitted
Fix #2474: DirectoryInfo/FileInfo display property map prevents infinite loop
Copilot-generated fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d5f7c87 commit d8ce204

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Format2.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ function Get-DisplayProperty2 ([Type]$Type) {
157157
# and for types that do not exist
158158

159159
$propertyMap = @{
160-
'System.Diagnostics.Process' = 'Id', 'Name'
160+
'System.Diagnostics.Process' = 'Id', 'Name'
161+
# DirectoryInfo and FileInfo have circular references (Root, Directory) that cause infinite recursion
162+
'System.IO.DirectoryInfo' = 'Name', 'FullName'
163+
'System.IO.FileInfo' = 'Name', 'FullName', 'Length'
161164
}
162165

163166
$propertyMap[$Type.FullName]

0 commit comments

Comments
 (0)