Roslyn: UpgradeProject crashes IDE with "Unable to check out the files from source control"

Created on 27 Mar 2017  路  13Comments  路  Source: dotnet/roslyn

I鈥檓 getting a crash when using the UpgradeProject fixer.
It comes from void EnsureEditableDocuments(IEnumerable<DocumentId> documents)

The input is a single document, which apparently has a null path.

I see a few possible interpretations, but I don鈥檛 know what鈥檚 the proper expectations:

  1. We should not be checking this document in the first place
  2. We should check this document, but it should have a path
  3. It鈥檚 ok for the check to fail, but the exception should not blow up the IDE

I have a repro project and a minidump if needed.

[0] = (DocumentId, #15fef80d-55d3-442e-91f5-88ec51476497 - C:\Users\jcouv\AppData\Local\Temp\.NETFramework,Version=v4.6.AssemblyAttributes.cs)

The result from QueryEditFiles is-2147467261.

> Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.EnsureEditableDocuments(System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentId> documents) Line 1111    C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.EnsureEditableDocuments(Microsoft.CodeAnalysis.DocumentId[] documents) Line 1123    C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyDocumentTextChanged(Microsoft.CodeAnalysis.DocumentId documentId, Microsoft.CodeAnalysis.Text.SourceText newText) Line 855                C#
Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.ApplyChangedDocument(Microsoft.CodeAnalysis.ProjectChanges projectChanges, Microsoft.CodeAnalysis.DocumentId documentId) Line 1335       C#
Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(Microsoft.CodeAnalysis.ProjectChanges projectChanges) Line 1283           C#
Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Microsoft.CodeAnalysis.Solution newSolution, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker) Line 1075             C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.TryApplyChanges(Microsoft.CodeAnalysis.Solution newSolution, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker) Line 169               C#
Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation.TryApply(Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 44 C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ProcessOperations(Microsoft.CodeAnalysis.Workspace workspace, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeActions.CodeActionOperation> operations, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 258              C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ApplyAsync(Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Document fromDocument, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeActions.CodeActionOperation> operations, string title, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 164              C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorker(System.Func<Microsoft.CodeAnalysis.Document> getFromDocument, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 164              C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeCore.AnonymousMethod__0() Line 133                C#
Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformAction(Microsoft.CodeAnalysis.Extensions.IExtensionManager extensionManager, object extension, System.Action action) Line 22           C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeCore(System.Func<Microsoft.CodeAnalysis.Document> getFromDocument, Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 131              C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InnerInvoke(Microsoft.CodeAnalysis.Shared.Utilities.IProgressTracker progressTracker, System.Threading.CancellationToken cancellationToken) Line 121           C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.Invoke.AnonymousMethod__0(Microsoft.CodeAnalysis.Editor.Host.IWaitContext waitContext) Line 107     C#
Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.VisualStudioWaitIndicator.Wait(string title, string message, bool allowCancel, bool showProgress, System.Action<Microsoft.CodeAnalysis.Editor.Host.IWaitContext> action) Line 43               C#
Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.Invoke(System.Threading.CancellationToken cancellationToken) Line 103         C#
               [External Code] 

Area-IDE Bug Resolution-Fixed Tenet-Reliability

Most helpful comment

@StuartQ The fix should be available in 15.8 Preview 2

All 13 comments

@jcouv What edit is being made to that file? I wouldn't expect a change there.

I wouldn't expect that file to be editted in any way. I'm not even sure what that file is.
I just open the project (which has a few libraries, targeting different frameworks), use a C# 7.1 feature (default literal) and trigger the UpgradeProject fixer. I'd expect only the csproj files to be touched.

@jasonmalinowski - what are your thoughts here?

@Pilchie: I would think we shouldn't crash? :smile:

@jcouv: when you build a project the runtime wants to have an assembly level attribute defined that will say what framework you were targeting. This allows for various things to be done, like identifying if a given assembly can run on a given framework, maybe using it to know which backcompat shims to apply, etc. (This mechanism is less meaningful these days, but whatever.) Since frameworks are a figment of the imagination from the perspective of the compiler, there are MSBuild targets that generate these files that get included as an input to the compiler that you don't see in your project file. You'll see them on the command line though being passed in. They're files that are in temp and are never editable and should never be changed, so it's very odd you're seeing an effort to ensure they're editable in the first place.

@jcouv Can you start by looking at the new solution and seeing why it thinks there are edits to that file?

I wasn't able to repro live any more, so I looked at the dump. But I couldn't trace back further than the part that has new project and old project (I don't have dump information for the logic that produced the new project).
I'll re-open if I run into this again.

I just ran into this again (twice). I saved a new dump file on my share (jcouvdev look for this bug's number), in the EnsureEditableDocuments method.

I found this issue through Google so I'm not sure if this is the correct place to report, but I'm experiencing the exact same problem.

Trying to use default literal and upgrade all C# projects to latest via alt+enter.

Since the error mentions source control - the repo is in SVN and I use Ankh SVN as a Source Control plugin.

I would be happy to provide any extra info but I don't know where to look. ActivityLog.xml has nothing interesting (it's on Verbose).

I'm getting this every now and then when trying out #25875 but not consistently. The solution only has 1 project and is not in source control.

@ivanbasov I'd say there's a pretty good likelihood these are the same.

@JieCarolHu I'm currently seeing this in VS 15.7.2. Can you advise when this fix will be available?

@StuartQ The fix should be available in 15.8 Preview 2

Was this page helpful?
0 / 5 - 0 ratings