5

After I rename my file name (lower case to upper case) in VS Code, example card.cs to Card.cs, I got this error: The type of namespace could not be found are you missing a using directive or an assembly

How should I fix this issue?

Secondly, should I rename it at VS code locally, then push to my Git or should I rename it at Git and then pull it from Git?

5
  • 1
    Where does the error show?
    – Tan Dat
    Feb 28, 2019 at 3:15
  • in visual studio code under "Problems" tab.
    – Steve
    Feb 28, 2019 at 3:15
  • example, this line now got error: private List<Card> cards;
    – Steve
    Feb 28, 2019 at 3:16
  • Search for lowercase card because there are some places where it is still not changed to uppercase. Feb 28, 2019 at 3:32
  • Ctrl+Shift+B build your code again. Feb 28, 2019 at 4:10

5 Answers 5

8

Somehow after restart my VS Code, the error no more already. Solution is to rename in VS Code using 'rename' function and if file name is different I rename it using Git command

4

It also happens to me when changing uppercase to lowercase or vice versa. If it gets stuck like this and VS Code still requires the old name, it helps me to change the name to something else entirely and then rename it to what I want.

2
  • This one + the one with 'restart VSC' should be the accepted answers.
    – Natacha
    Apr 5 at 16:40
  • for me not enough to only restart vscode BUT renaming to something else entirely and then rename it perfectly worked, thanks Nov 3 at 10:50
0

FWIW I had same issue, renamed a class lower case to uppercase by clicking Rename inside VS Code (Mac). Terminal shows a file name mismatch error displaying lower case name. Git Desktop showed lower case name. VS Code shows new name in files panel. My solution: Disable git extensions, delete the classes from my org, shut down git desktop and vs code. Restart vs code. Trying again it failed but only when I use cmd-p to deploy source for the visible window. If I right click on the filename in the files panel and deploy from there, it worked.

0

This was happening to me when I renamed from PascalCase case to snake_case, but for some reason the IntelliSense in VS Code was still adding imports at the top of the file with the old name.

So make sure all imports of the old name have been changed to their new case. And if you want to stop code completion adding the old case in the import declarations then restart VS Code.

0

Had lower case, changed to Uppercase. VSCode Restart worked for me.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    May 24 at 5:46

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.