Lines unaffected from sytax errors get formatted wrong on PowerShell 5

Đang mở
#1,813 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
powershell
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện trường hợp PowerShell 5 với Invoke-Formatter và đoạn snippet lỗi cú pháp được cung cấp, sau đó lần theo đường đi của formatter xử lý các dòng không bị ảnh hưởng sau lỗi parse. Hoàn thành khi PowerShell 5 vẫn giữ dấu gạch chéo gắn với parameter, khớp với output mong đợi, mà không thay đổi hành vi hiện có của PowerShell 7.

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

Mô tả

Area - Formatter Issue-Bug Up for Grabs

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

  1. Open a PowerShell 5 window
  2. Type the following code with intentional syntax errors:
$code = @"
@(
  @{
    ""
  }
  ""
)
test /parameter
"@

Invoke-Formatter $code

Expected behavior

Slash should not be seperated from parameter since it isn't affected from the syntax error.

@(
    @{
        ""
    }
    ""
)
test /parameter

Actual behavior

Slash is treated as an operator and is seperated from parameter. This behavior is unique to PowerShell 5 and does not occur in v7.

@(
    @{
        ""
    }
    ""
)
test / parameter

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.20.0

Ngôn ngữ chính
C#
Star
2.2k
Fork
415
Merge trung bình
13 giờ 1 phút
Pull request đã merge (30 ngày)
2

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/PSScriptAnalyzer

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

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.