`dotnet-suggest list` truncates dotted global tool names

Đang mở Phù hợp với người mới
#2,887 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

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
76/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 với FileEnumerator.EnumerateFilesWithoutExtension trong FileEnumerator.cs và SuggestionDispatcher.ShellPrefixesToMatch trong SuggestionDispatcher.cs; theo dõi cách mỗi phần xử lý tên tệp thực thi Linux và kiểm tra các bài kiểm thử liên quan. Chạy các bài kiểm thử phù hợp, sau đó xác minh rằng dotnet-suggest list giữ nguyên tên đầy đủ có dấu chấm của các công cụ để shim PowerShell có thể đăng ký bộ hoàn tất cho chúng.

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

Mô tả

The tool names below are anonymized. They retain the same number of dotted segments as the original names.

Environment
  • OS: Linux
  • dotnet-suggest: 3.0.0
  • Shell: PowerShell
Steps to reproduce
  1. Install a .NET global tool with a dotted command name, for example Example.Tools.StatusMonitor.Console.
  2. Verify that dotnet tool list -g shows the full name in the Commands column.
  3. Run dotnet-suggest list.
Expected behavior

The list contains Example.Tools.StatusMonitor.Console, so the PowerShell shim can register a completer for the full command name.

Actual behavior

The list shows Example.Tools. A second tool, SampleUi.Automation.TestClient, appears as SampleUi.

Tab completion for the full name fails with the standard PowerShell shim. Passing the full executable path directly returns the expected options:

$name = 'Example.Tools.StatusMonitor.Console'
$exe = (Get-Command $name -CommandType Application).Source
$line = "$name --"
dotnet-suggest get -e $exe --position $line.Length -- $line

Explicitly registering the full name with Register-ArgumentCompleter -Native restores tab completion.

Likely cause

In v3.0.0, global-tool discovery calls Path.GetFileNameWithoutExtension in FileEnumerator.EnumerateFilesWithoutExtension, removing .Console from the Linux executable name. SuggestionDispatcher.ShellPrefixesToMatch calls the same method again when producing list output, removing .StatusMonitor. The PowerShell shim uses the resulting name to register the completer.

Background

We use the same name for a C# project, its assembly, and its installed command. This makes it easier to trace a command in a deployment script or log back to the project that builds it. Our project names follow the dotted naming convention we use across our C# codebase, so preserving the dots in the command name is important to us.

Ngôn ngữ chính
C#
Star
3.7k
Fork
439
Merge trung bình
4 ngày 8 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

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 dotnet/command-line-api

Tất cả issue của dotnet/command-line-api

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.