dotnet / dotnet/project-system

Error when renaming an unsaved C# WinForms form.

Open
#9,040 0 comments 0 reactions 1 assignee Claimed by @melytc View on GitHub
Feature-WinForms Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

## Visual Studio Version
Visual Studio 2022 17.7 Preview 1
(Reported since Visual Studio 2019 in this [feedback ticket](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1297172))

## Summary
While having a form open with some unsaved changes in place, renaming the file will cause a "catastrophic" error to occur.

## Steps to Reproduce

1. Download the project attached in the feedback ticket.
2. Open and add a button into the form designer.
3. Don't save the project, right click Form1.cs in Solution Explorer, rename it to Form2.cs
4. Try to save the project.

## Expected Behavior
This is what _I think_ should happen, but might not be accurate: the form is saved and then renamed to Form2.cs.

## Actual Behavior
An error dialog pops up when saving the .NET Framework project that is based on the new SDK style after renaming Form1.cs.
![image](https://github.com/dotnet/project-system/assets/8518253/9bc8f21a-6396-4107-810b-d2312fed0de0)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.