project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Renaming a file to a .cs file causes extra items in the project file

Open davidwengier opened this issue 6 years ago • 6 comments

From @NickCraver on twitter: https://twitter.com/Nick_Craver/status/1150201135095066624

Repro:

  1. Right click, add a class
  2. File.Test as the name, enter
  3. Because of the . in there, .cs wasn't appending, so F2 on file and change to File.Test.cs
  4. This is in the .csproj: image

This is probably just None globbing (#4534) but maybe there is a small fix to be made in CPS to specifically improve the rename scenario.

davidwengier avatar Jul 14 '19 01:07 davidwengier

On second thought, this isn't None globbing at all. The issue here is that the user is renaming something that has an ItemType of None and CPS is trying to keep that same ItemType, even though the new name means the item is picked up by the Compile glob. This is a good thing in general, but specifically when its done straight after a New Item template its annoying.

davidwengier avatar Jul 14 '19 01:07 davidwengier

Perhaps maybe the improvement to be made here is in the detection of when to add .cs on the end of a file when adding a class? If I'm selecting class in the menu, I'm trying to add a class, and every period in a filename I've ever come across doesn't end in a valid language extension.

It seems like perhaps improving the logic from "does it have a dot?" to "does it have a known file extension?" could work. But maybe that breaks some crazy workflows, I dunno - just tossing out the idea!

NickCraver avatar Jul 14 '19 01:07 NickCraver

Yeah, agreed, the new item dialog would be a great place to fix this too if possible.

davidwengier avatar Jul 14 '19 01:07 davidwengier

The fix could live in 2 different components. CPS or New file dialog. There needs to be an investigation on where is the right place for the fix.

jjmew avatar Feb 03 '20 23:02 jjmew

Sending back to triage as Osvaldo is on parental leave for the remainder of 17.2.

drewnoakes avatar Mar 14 '22 23:03 drewnoakes

@ocallesp?

adamint avatar Aug 19 '22 16:08 adamint