Skip to content

Prevent type rename from renaming ordinary Finalize methods - #85126

Merged
akhera99 merged 1 commit into
dotnet:mainfrom
akhera99:renaming_interface_bug
Sep 2, 2026
Merged

Prevent type rename from renaming ordinary Finalize methods#85126
akhera99 merged 1 commit into
dotnet:mainfrom
akhera99:renaming_interface_bug

Conversation

@akhera99

@akhera99 akhera99 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Fixes #84976

Named type reference discovery treated every member named Finalize as a destructor. This caused renaming an interface or type to also rename an unrelated ordinary Finalize method.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 1, 2026 20:00
@akhera99
akhera99 requested a review from a team as a code owner September 1, 2026 20:00
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Review tier: Lite
Findings: None

What changed in this PR

This PR fixes named type reference discovery so it only cascades to actual destructors (method kind Destructor) rather than any member named Finalize, preventing type/interface renames from incorrectly renaming ordinary Finalize methods.

Changes:

  • Filter cascaded “destructor” symbols to IMethodSymbol with MethodKind.Destructor instead of all Finalize-named members.
  • Add rename regression test ensuring a C# interface rename does not rename an ordinary Finalize method.
  • Add find-references regression test ensuring ordinary Finalize methods are not treated as destructors when finding references for a named type.
File Description
src/​Workspaces/​Core/​Portable/​FindSymbols/​FindReferences/​Finders/​NamedTypeSymbolReferenceFinder.cs Restricts destructor cascading to real destructors (by MethodKind).
src/​EditorFeatures/​Test2/​Rename/​RenameEngineTests.vb Adds rename regression test covering interface + ordinary Finalize method scenario.
src/​EditorFeatures/​Test2/​FindReferences/​FindReferencesTests.NamedTypeSymbols.vb Adds find-references regression test for ordinary Finalize method not being treated as a destructor.

@akhera99
akhera99 merged commit 204bf7e into dotnet:main Sep 2, 2026
24 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue when renaming interface with "Finalize" method (C#)

3 participants