Closed vsfeedback closed 8 months ago
Here's a stack trace from a similar report:
Error performing rename: ''(DocumentId, #916597c6-1f55-4685-88e6-6bcf270f0d16 - D:\...\LoadProgressInfo.cs)' is not part of the workspace.'
System.InvalidOperationException : '(DocumentId, #916597c6-1f55-4685-88e6-6bcf270f0d16 - D:\...\LoadProgressInfo.cs)' is not part of the workspace.
at Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace.OpenInvisibleEditor(DocumentId documentId)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyTextDocumentChange(DocumentId documentId,SourceText newText)
at Microsoft.CodeAnalysis.Workspace.ApplyChangedDocument(ProjectChanges projectChanges,DocumentId documentId)
at Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(ProjectChanges projectChanges)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.TryApplyRenameAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.<>c__DisplayClass88_0.<CommitCoreAsync>b__0(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.DismissUIAndRollbackEditsAndEndRenameSessionAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitCoreAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitWorkerAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitWorker(Boolean previewChanges)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.Commit(InlineRenameSession activeSession,ITextView textView)
I really want to enjoy programming in a fresh created Blazor Hybrid App project that targets by default multiple platforms via TargetFramework, but how can I enjoy it when I cannot rename the first ever created class I accidentally misspelled!?
Guys, I really cannot rename any class wihtout the newline inserted and the old class name reappearing when "Rename symbol's file" is enabled. Am I the only individual working with multi-target framework and renames classes why this problem is such a low priority?
When this gets finally fixed!? I really want to have fun time in my free time and not facing such frustrating issues, what about you?
@teneko We'd def take a contribution here to help out. Thanks! :)
I add that a likely workaround is to uncheck the "Rename symbol's file", as I'm willing to bet that's what is causing the issue
Edit: and can also help indicate where the fix would be :)
@ryzngard that and reducing the TargetFramework's to one. Multiple TargetFramework's leads to this misbehaviour in the first place. First I try to get VS running up and try to get a debugging breakpoint to work. I think the stacktrace from sharwell is a good hint. Any tips to get familiar with the concept of "workspace"? In my head I can only draw the picture that each TargetFramework has its own "workspace"? One idea is, that changing the file leads to a rename of the same file in all workspaces but once the file has been changed in one workspace, the file cannot be renamed twice in the second workspace, thus "\<not-existing-file-anymore> is not part of the workspace". My definition of a workspace is a "file tree" of one of the targeted frameworks. Any comments?
https://github.com/dotnet/roslyn/tree/main/docs/wiki will always be a good location for docs on all the things. There's a section for the workspace in there. If you need help, definitely feel free to keep asking here or on discord
the file cannot be renamed twice in the second workspace, thus "
is not part of the workspace
You're definitely on the right track :) One nuance here to keep in mind is that a "Project" for our representation is a single TFM. So each project doing multiple TFMs has multiple "Projects", one for each TFM.
Considering I definitely wrote this bug, it'd be my pleasure to guide you through the fix
Something is broken with the discord channel your provided. 😄 Is it invite only? It seems I can "access" the link, but then discord itself tells me that something is "wrong" by telling me that either no text channels are existing or I do not have access to the server.
I believe it is fixed in https://github.com/dotnet/roslyn/pull/71220 @teneko Could you try the 17.9 public preview (17.9 preview 5) and see if the problem get resolved?
Something is broken with the discord channel your provided. 😄 Is it invite only?
I don't know, probably user error on my end. Here's the link from the top level readme in roslyn http://aka.ms/discord-csharp-roslyn
@Cosifne This seems to have fixed it.. -*.*- - thanks !
Thanks everyone for verifying!
This issue has been moved from a ticket on Developer Community.
This bug exists for years. It is one of the most annoying bugs regarding renaming files next to this bug I already submitted.
This bug is simple: when you use more than two framework targets via
TargetFrameworks
(MSBuild), then you simply cannot rename classes while "Rename symbol’s file’ is enabled.Instead of renaming the class when pressing the enter-key, a new line is inserted. The most ugly bug I ever encountered in earlier versions of Visual Studio was, when not only a new line was inserted but the hole document was malformed and undoing performed so wrong, that I had to rewrite the hole file.
Whatsoever, I hope you can fix this bug.
This bug is reproducible in Visual Studio Version 17.4.0 Preview 6.0.
In Visual Studio 17.2.4 there was always a “nice” error, telling something like “the document is not part of the workspace”, or something like this.
Workaround: Use temporally only one framework target.
Original Comments
Feedback Bot on 11/19/2022, 08:49 PM:
(private comment, text removed)
Feedback Bot on 11/21/2022, 07:09 AM:
(private comment, text removed)
Original Solutions
(no solutions)