dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.88k stars 4.01k forks source link

Error when performing namespace adjust for solution or sync namespace context menu #73072

Open vsfeedback opened 4 months ago

vsfeedback commented 4 months ago

This issue has been moved from a ticket on Developer Community.


Whenever I try to sync namespaces by either clicking the context menu on the solution or by clicking the recommendation directly on the namespace I get a few different errors but the stack is pretty much the same (file attached).

It does not work, gets disabled and I can't sync all namespaces.

It usually works after restarting VS or when I run it with admin privileges but it is been happening more frequently after the last update (17.4.4)

It's not "NEW", it happened in older versions as well


Original Comments

Feedback Bot on 2/7/2023, 05:03 PM:

(private comment, text removed)

Wenwen Fan [MSFT] on 2/7/2023, 09:43 PM:

(private comment, text removed)

Murilo Almeida on 2/17/2023, 07:20 PM:

(private comment, text removed)

Feedback Bot on 2/14/2023, 10:14 PM:

(private comment, text removed)

Feedback Bot on 2/20/2023, 10:27 PM:

(private comment, text removed)

Feedback Bot on 2/21/2023, 06:38 AM:

(private comment, text removed)

Feedback Bot on 2/21/2023, 06:47 AM:

(private comment, text removed)


Original Solutions

(no solutions)

Excemption stack from feedback ticket:

<source>CSharpChangeNamespaceToMatchFolderCodeFixProvider</source>
<description>The solution does not contain the specified document.
at Microsoft.CodeAnalysis.Shared.Extensions.ISolutionExtensions.GetRequiredDocument(Solution solution, DocumentId documentId)
 at Microsoft.CodeAnalysis.ChangeNamespace.AbstractChangeNamespaceService`3.<>c__DisplayClass26_0.<ChangeNamespaceInSingleDocumentAsync>b__4(IGrouping`2 refInOneDocument
)
 at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
 at System.Threading.Tasks.Task.WhenAll[TResult](IEnumerable`1 tasks)
 at Microsoft.CodeAnalysis.ChangeNamespace.AbstractChangeNamespaceService`3.<ChangeNamespaceInSingleDocumentAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
)
at Microsoft.CodeAnalysis.ChangeNamespace.AbstractChangeNamespaceService`3.<ChangeNamespaceAsync>d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.CodeAnalysis.ChangeNamespace.AbstractChangeNamespaceService`3.<TryChangeTopLevelNamespacesAsync>d__15.MoveNext() --- 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 Microsoft.CodeAnalysis.Rename.Renamer.SyncNamespaceDocumentAction.<GetModifiedSolutionAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.CodeAnalysis.Rename.Renamer.RenameDocumentActionSet.<UpdateSolutionAsync>d__9.MoveNext() --- 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 Microsoft.CodeAnalysis.CodeFixes.MatchFolderAndNamespace.AbstractChangeNamespaceToMatchFolderCodeFixProvider.<FixAllInDocumentAsync>d__3.MoveNext() --- 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 Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__25.MoveNext() --- 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 Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetPreviewOperationsAsync>d__24.MoveNext() --- 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 Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.<GetPreviewResultAsync>d__26.MoveNext() --- 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 Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<<GetPreviewAsync>b__0>d.MoveNext() --- 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 Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.<PerformFunctionAsync>d__3`1.MoveNext()</description>
ryzngard commented 4 months ago

This comes from sync namespace attempting to apply to documents not in the solution.