roslyn: Adding .editorconfig as a `` item results in Roslyn exceptions that propagate through the project system

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


VS goldbar: “Visual Studio ran into an unexpected problem with one or more projects. …”

Log contents:

=====================
9/25/2023 5:51:26 PM
LimitedFunctionality
System.AggregateException: Project system data flow 'Workspace update handler 17344132' closed because of an exception: This program location is thought to be unreachable. File='/_/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentStates.cs' Line=76.
---> (Inner Exception #0) System.InvalidOperationException: This program location is thought to be unreachable. File='/_/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentStates.cs' Line=76
   at Microsoft.CodeAnalysis.SolutionState.WithDocumentContentsFrom(DocumentId documentId, DocumentState documentState)
   at Microsoft.CodeAnalysis.Solution.WithDocumentContentsFrom(DocumentId documentId, DocumentState documentState)
   at Microsoft.CodeAnalysis.Workspace.<SetCurrentSolutionAsync>g__UpdateExistingDocumentsToChangedDocumentContents|27_2(Solution solution, DocumentId changedDocumentId, HashSet`1 processedDocuments)
   at Microsoft.CodeAnalysis.Workspace.<SetCurrentSolutionAsync>g__UnifyLinkedDocumentContents|27_0(Solution oldSolution, Solution newSolution)
   at Microsoft.CodeAnalysis.Workspace.<>c.<SetCurrentSolutionAsync>b__27_3(Solution oldSolution, ValueTuple`5 data)
   at Microsoft.CodeAnalysis.Workspace.<SetCurrentSolutionAsync>d__29`1.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.Workspace.<SetCurrentSolutionAsync>d__27.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.Workspaces.ProjectSystem.ProjectSystemProjectFactory.<ApplyBatchChangeToWorkspaceMaybeAsync>d__46.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.Workspaces.ProjectSystem.ProjectSystemProject.<OnBatchScopeDisposedMaybeAsync>d__102.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.Workspaces.ProjectSystem.ProjectSystemProject.BatchScope.<DisposeAsync>d__4.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.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass43_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>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.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>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.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<ExecuteAsync>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.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.<ExecuteUnderLockCoreAsync>d__7.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.VisualStudio.ProjectSystem.LanguageServices.Workspace.<OnBuildUpdateAsync>d__41.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.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnWorkspaceUpdateAsync>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.VisualStudio.ProjectSystem.LanguageServices.Workspace.<OnWorkspaceUpdateAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
<--- (Inner Exception #0) 
===================

See attached traces.


Original Comments

Black Elijah (ST-IN ENG3-TW) on 9/25/2023, 09:30 PM:

(private comment, text removed)

Black Elijah (ST-IN ENG3-TW) on 9/25/2023, 09:33 PM:

(private comment, text removed)

Feedback Bot on 9/25/2023, 09:56 PM:

(private comment, text removed)


Original Solutions

(no solutions)

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Possibly what happens is:

  1. You copy the .cs file.
  2. The project system sees this as a new <Compile> item due to the standard globs for .cs files.
  3. You rename the item to .editorconfig.
  4. The project system notices that the <Compile> item is no longer covered by the globs for .cs files (since it no longer ends in .cs).
  5. It “helpfully” adds an explicit <Compile> item to the project file to preserve the item type.

In which case this is a case of a series of more-or-less reasonable steps leading to an absurd outcome. I can’t really say this is intentional, but it isn’t really a bug either.