Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Add support for renaming PowerShell class references

未關閉
#2,293 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
csharp, powershell
領域
devtools, tooling

研究方向

首先重現兩個類別範例,並在類別名稱參照上按下 F2。追蹤 PowerShell Editor Services 中現有的重新命名處理,包括同一檔案中的類別參照,以及可選 Attribute 後綴的行為。完成的標準是:重新命名會一致地更新宣告、建構函式、型別參照和屬性使用方式。

由索引模型根據 Issue 內容生成。

描述

Issue-Bug Needs: Triage
Prerequisites
  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
  • I have verified that I am using the latest version of PowerShell Editor Services.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

This is not a bug, but the README says that rename scenarios should be filed as bug reports, so that's what I'm doing.
I think it should be fairly trivial to add renaming support for PowerShell classes defined in the same script file.
Expected:

class DemoClass
{
    [string] $SomeProperty

    DemoClass ([string] $SomeArg)
    {
        $this.SomeProperty = $SomeArg
    }
}

[DemoClass]

Actual:

class NewName
{
    [string] $SomeProperty

    NewName ([string] $SomeArg)
    {
        $this.SomeProperty = $SomeArg
    }
}

[NewName]

One thing to keep in mind during implementation is that a PowerShell class can also be used to define an attribute, and an attribute type can drop the optional Attribute suffix in an attribute context as seen here:

class ValidateSomethingAttribute : System.Management.Automation.ValidateArgumentsAttribute
{
    [void]Validate([System.Object]$arguments, [System.Management.Automation.EngineIntrinsics]$engineIntrinsics)
    {
    }
}
[ValidateSomething()][string]$Path = "c:\windows"
PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.6.1
PSEdition                      Core
GitCommitId                    7.6.1
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
Editor Version
VS code:

Version: 1.117.0 (system setup)
Commit: 10c8e557c8b9f9ed0a87f61f1c9a44bde731c409
Date: 2026-04-21T16:12:14-07:00
Electron: 39.8.7
ElectronBuildId: 13841579
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200
PowerShell Editor Services Version
Major  Minor  Build  Revision
-----  -----  -----  --------
4      6      0      0
Steps to Reproduce

Use the code blocks from before and press F2 on the class name references.

Visuals

No response

Logs

No response

主要語言
C#
星號
767
分支
266
平均合併
3 天 16 小時
30 天內合併 PR
1

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

PowerShell/PowerShellEditorServices 的其他 Issue

查看 PowerShell/PowerShellEditorServices 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。