Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Test-Connection -BufferSize 0 reports buffer size of 32

Đang mở Phù hợp với người mới
#27,656 2 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu trong TestConnectionCommand.cs và kiểm tra logic báo cáo kích thước bộ đệm được mô tả trong issue. Tái hiện bằng Test-Connection -TargetName localhost -Count 1 -BufferSize 0, sau đó xác minh rằng đầu ra và PingStatus.BufferSize báo cáo 0 trong khi bộ đệm phản hồi vẫn trống. Hoàn tất khi các yêu cầu có kích thước 0 byte không còn báo cáo kích thước mặc định.

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

Mô tả

Issue-Bug Up-for-Grabs WG-Reviewed
Steps to reproduce

Run the Test-Connection cmdlet specifying a buffer size of 0, then inspect the BufferSize property of the output PingStatus object, or check the returned table:

$result = Test-Connection -TargetName localhost -Count 1 -BufferSize 0
Write-Host "Result BufferSize property: $($result.BufferSize)"
Write-Host "Actual Reply.Buffer.Length: $($result.Reply.Buffer.Length)"
Expected behavior

The cmdlet output and the BufferSize property should correctly reflect the requested buffer size of 0:

Result BufferSize property: 0
Actual Reply.Buffer.Length: 0
Actual behavior

The cmdlet output and the BufferSize property incorrectly report 32:

Result BufferSize property: 32
Actual Reply.Buffer.Length: 0

The console output table also reports the BufferSize (B) as 32:

Ping Source           Address                   Latency BufferSize Status
                                                   (ms)        (B)
---- ------           -------                   ------- ---------- ------
   1 localhost        ::1                             0         32 Success
Error details

No exception is thrown. The ping completes successfully but outputs incorrect metadata.

Environment data
Name                           Value
----                           -----
PSVersion                      7.6.3
PSEdition                      Core
GitCommitId                    7.6.3
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
Additional Context

This is caused by the following logic in TestConnectionCommand.cs:

buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length

When -BufferSize 0 is passed, GetSendBuffer(0) allocates a 0-length array (new byte[0]). Since buffer.Length is 0, the expression evaluates to DefaultSendBufferSize (32), misreporting the buffer size as 32 bytes even though a 0-byte payload was actually sent.

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.