Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename file code fix doesn't work #1195

Closed
jchannon opened this issue Feb 7, 2017 · 10 comments
Closed

Rename file code fix doesn't work #1195

jchannon opened this issue Feb 7, 2017 · 10 comments

Comments

@jchannon
Copy link
Contributor

jchannon commented Feb 7, 2017

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004706)

Product Information:
 Version:            1.0.0-rc4-004706
 Commit SHA-1 hash:  e38bc4950c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.0-rc4-004706

VS Code version:1.9.0
C# Extension version:1.7.0-beta4

Steps to reproduce

Have a file called Foo.cs and a class declaration inside called Bar. In the context menu choose Rename file to Bar.cs

Expected behavior

The file is renamed

Actual behavior

Nothing happens. Omnisharp logs contains the below but no file is renamed.

       ************ Request ************
POST - /v2/getcodeactions
************ Headers ************
Content-Type - application/json
************  Body ************
{
  "Filename": "/Users/jonathan/Projects/twittermw/tests/Fred.cs",
  "Selection": {
    "Start": {
      "Line": 3,
      "Column": 18
    },
    "End": {
      "Line": 3,
      "Column": 21
    }
  }
}
[dbug]: OmniSharp.Middleware.LoggingMiddleware
        ************  Response ************ 
{"CodeActions":[{"Identifier":"Rename type to Fred","Name":"Rename type to Fred"},{"Identifier":"Rename file to fff.cs","Name":"Rename file to fff.cs"}]}
[dbug]: OmniSharp.Middleware.LoggingMiddleware
        ************ Request ************
POST - /v2/runcodeaction
************ Headers ************
Content-Type - application/json
************  Body ************
{
  "Filename": "/Users/jonathan/Projects/twittermw/tests/Fred.cs",
  "Selection": {
    "Start": {
      "Line": 3,
      "Column": 18
    },
    "End": {
      "Line": 3,
      "Column": 21
    }
  },
  "Identifier": "Rename file to fff.cs",
  "WantsTextChanges": true
}
[trce]: OmniSharp.Host.Loader.AssemblyLoader
        Assembly loaded: Microsoft.CodeAnalysis.Features, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[trce]: OmniSharp.Host.Loader.AssemblyLoader
        Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[info]: OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.RunCodeActionService
        Applying code action: Rename file to fff.cs
[dbug]: OmniSharp.Middleware.LoggingMiddleware
        ************  Response ************ 
{"Changes":[]}

@DustinCampbell
Copy link
Member

Thanks for the report @jchannon

@DustinCampbell
Copy link
Member

I can imagine why this would fail. Essentially, the service in omnisharp-roslyn gathers up all of the text changes and sends them back to the editor host (in this case, C# for VS Code) to apply. However, in this case, there aren't any text changes, just a file rename. This is something we'll need to handle in omnisharp-roslyn.

@DustinCampbell DustinCampbell added this to the 1.8 milestone Feb 7, 2017
@DustinCampbell DustinCampbell modified the milestones: 1.8, 1.9 Mar 10, 2017
@DustinCampbell DustinCampbell modified the milestones: 1.9, 1.10 Apr 20, 2017
@DustinCampbell DustinCampbell modified the milestones: 1.10, 1.11 May 25, 2017
@DustinCampbell DustinCampbell modified the milestones: 1.11, 1.12 Jun 27, 2017
@DustinCampbell DustinCampbell modified the milestones: 1.12, 1.13 Aug 9, 2017
@rchande
Copy link

rchande commented Oct 30, 2017

This should be fixed as of #1805

@rchande rchande closed this as completed Oct 30, 2017
@DustinCampbell
Copy link
Member

Unless we've added code to tell VS Code to apply a file rename, I wouldn't expect this to be fixed.

@DustinCampbell
Copy link
Member

@rchande : Please check the repro. This is about the Rename File code fix, which still does not work.

@DustinCampbell DustinCampbell changed the title Rename file doesn't work Rename file code fix doesn't work Oct 30, 2017
@rchande
Copy link

rchande commented Oct 30, 2017

@DustinCampbell You're right, this is a different bug. Thanks for noticing :)

@chtenb
Copy link

chtenb commented Aug 4, 2021

The error message it gives me in a toaster is

Unable to open 'INewName.cs': Unable to read file 'c:\Users\...\INewName.cs' 
(Error: Unable to resolve non-existing file 'c:\Users\...\INewName.cs').

It's a pretty weird error, since the INewName.cs indeed is supposed not to exist. It's the one that should be written.

@jptissot
Copy link

The error message it gives me in a toaster is

Unable to open 'INewName.cs': Unable to read file 'c:\Users\...\INewName.cs' 
(Error: Unable to resolve non-existing file 'c:\Users\...\INewName.cs').

It's a pretty weird error, since the INewName.cs indeed is supposed not to exist. It's the one that should be written.

I am having this exact same issue.

@hahn-kev
Copy link

This is very strange. I decided I wanted to fix this issue, I started by reproducing with the current release version which I was able to do easily. Next I got the code running on my machine, however when I try to reproduce the bug it doesn't happen even if I do a prod build with the current release version v1.24.4 checked out. I'm not really sure how to properly debug the production version of the extension so idk what's going on.

I did see this error in the dev tools console.

rejected promise not handled within 1 second: "System.ArgumentException: 'A.cs' is not open.
   at Microsoft.CodeAnalysis.Workspace.CheckDocumentIsOpen(DocumentId documentId)
   at Microsoft.CodeAnalysis.Workspace.OnDocumentClosed(DocumentId documentId, TextLoader reloader, Boolean updateActiveContext)
   at OmniSharp.OmniSharpWorkspace.CloseDocument(DocumentId documentId) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\OmniSharpWorkspace.cs:line 102
   at OmniSharp.Roslyn.CSharp.Services.Files.FileCloseService.Handle(FileCloseRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Files\\FileCloseService.cs:line 23
   at OmniSharp.Endpoint.EndpointHandler`2.<AggregateResponsesFromLanguageHandlers>d__18.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 164
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 227
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 131
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Stdio.Host.<HandleRequest>d__14.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 218"

this shows up a few seconds after vscode tries to open the file C.cs which is what the new file would have been called.

@JoeRobich
Copy link
Member

Unable to reproduce in the current release.

@JoeRobich JoeRobich closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants