question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editor not updating reference when class file moved to new folder

See original GitHub issue

Environment data

dotnet --info output: .NET Core SDK (reflecting any global.json): Version: 2.1.402 Commit: 3599f217f4

Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.13-x64 Base Path: /usr/local/share/dotnet/sdk/2.1.402/

Host (useful for support): Version: 2.1.4 Commit: 85255dde3e

.NET Core SDKs installed: 1.0.1 [/usr/local/share/dotnet/sdk] 2.1.402 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

VS Code version: Version 1.29.1 (1.29.1) bc24f98b5f70467bc689abf41cc5550ca637088e

C# Extension version: 1.17.1

MacOS 10.13.6 (17G3025)

Steps to reproduce

See also animated GIF below

  1. dotnet new console
  2. Open VS Code
  3. Create root-level folders “Tests” and “Payroll”
  4. Move Program.cs to Tests folder
  5. Update Program.cs namespace to new folder
  6. Create declaration and instantiation to a variable of a new type
  7. Use CMD-. fix to generate new class in new file
  8. Move newly created file to Payroll folder
  9. Update namespace in new file
  10. Add using statement in Program.cs to reference Payroll namespace
  11. Save all files
  12. Hover over declaration statement in Program.cs. Note type can’t be found and is referred to as being in Tests namespace

omnisharp

Expected behavior

New type should be found in correct namespace

Actual behavior

New type is not found in correct namespace

Other info

Restarting OmniSharp via command palate corrects issue Related to Issue 2040?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
rchandecommented, Dec 19, 2018

@delroh You can use the “Restart OmniSharp” command instead of restarting Code

0reactions
rchandecommented, Dec 19, 2018

@jimholmes I believe a simple version of this bug is:

  • dotnet new console
  • create a directory next to the csproj
  • move Program.cs into the new directory
  • intellisense doesn’t work in Program.cs

Addressing this with https://github.com/OmniSharp/omnisharp-roslyn/pull/1368

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Class move refactoring does not change references to ...
So doing the class rename as 2 steps: first rename file to the new name then rename the class to the same name...
Read more >
Troubleshoot broken references - Visual Studio - Microsoft Learn
Here are two options to fix a broken project reference for a deleted file that no longer exists on your drive: Delete the...
Read more >
Designer.cs not updating when new controls added to .aspx
cs files and rename them, but neglect to update the references inside the file. I came across this question trying to find the...
Read more >
C# not recognizing moving of class file : r/csharp - Reddit
You have to update the namespace of the class you moved. Suppose the project has the following structure: MyApplication Folder1 FooBar.cs ...
Read more >
JavaScript Programming with Visual Studio Code
While jsconfig.json files are not required, you will want to create one in ... Code can automatically update all import paths that reference...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found