Skip to content

Add support for renaming PowerShell class references #2293

Description

@MartinGC94

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.1PSEdition CoreGitCommitId 7.6.1OS Microsoft Windows 10.0.26200Platform Win32NTPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}PSRemotingProtocolVersion 2.4SerializationVersion 1.1.0.1WSManStackVersion 3.0

Editor Version

VS code:Version: 1.117.0 (system setup)Commit: 10c8e557c8b9f9ed0a87f61f1c9a44bde731c409Date: 2026-04-21T16:12:14-07:00Electron: 39.8.7ElectronBuildId: 13841579Chromium: 142.0.7444.265Node.js: 22.22.1V8: 14.2.231.22-electron.0OS: 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugA bug to squash.Needs: TriageMaintainer attention needed!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions