`Trace-Command -Name TypeConversion` might not unwind the tracing scope stack after a failed cast

Đang mở
#28,035 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
67/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, powershell
Lĩnh vực
cli

Hướng nghiên cứu

Start by running the four Trace-Command -Name TypeConversion examples from the issue and compare indentation before and after the failed cast. Read the Trace-Command TypeConversion tracing and scope-stack handling, then verify that a failed conversion unwinds its scope so the final successful conversion has normal indentation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Needs-Triage
Prerequisites
Steps to reproduce
Trace-Command -Name TypeConversion -PSHost -Expression { [int]'123' };
Trace-Command -Name TypeConversion -PSHost -Expression { [int]'123' };

Trace-Command -Name TypeConversion -PSHost -Expression { [int]'Hello' };
Trace-Command -Name TypeConversion -PSHost -Expression { [int]'Hello' };

Expected behavior
DEBUG: 2026-09-19 19:37:39.6858 TypeConversion Information: 0 : Converting to integer.
123
DEBUG: 2026-09-19 19:37:39.6900 TypeConversion Information: 0 : Converting to integer.
123
DEBUG: 2026-09-19 19:37:39.6912 TypeConversion Information: 0 : Converting to integer.
DEBUG: 2026-09-19 19:37:39.6918 TypeConversion Information: 0 : Exception converting to integer: "The input string 'Hello' was not in a correct format.".

<...>

InvalidArgument:
Line |
   4 |  … ce-Command -Name TypeConversion -PSHost -Expression { [int]'Hello' };
     |                                                          ~~~~~~~~~~~~
     | Cannot convert value "Hello" to type "System.Int32". Error: "The input string 'Hello' was not in a correct format."

DEBUG: 2026-09-19 19:37:39.7870 TypeConversion Information: 0 : Converting to integer.

<...>
Actual behavior

The last tracing output starts with high indentation.

<...>

DEBUG: 2026-09-19 19:37:39.7870 TypeConversion Information: 0 :                         Converting to integer.

<...>
Error details

No response

Environment data
Name                           Value
----                           -----
PSVersion                      7.6.6
PSEdition                      Core
GitCommitId                    7.6.6
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

Note how after the error, the messages are highly indented.

Image
Ngôn ngữ chính
C#
Star
55.5k
Fork
8.5k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
97

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PowerShell/PowerShell

Tất cả issue của PowerShell/PowerShell

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.