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

Crash on applying an analyzer fixer across a large solution #23973

Open
ivanbasov opened this issue Dec 30, 2017 · 18 comments
Open

Crash on applying an analyzer fixer across a large solution #23973

ivanbasov opened this issue Dec 30, 2017 · 18 comments
Assignees
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com
Milestone

Comments

@ivanbasov
Copy link
Contributor

  1. Opened Compliers.sln from roslyn repo.
  2. Tried to apply an analyzer fixer for CA1801 (Port FxCop rule CA1801: ReviewUnusedParameters roslyn-analyzers#459) for the whole solution. There were 470+ issues of the type.
  3. Failed with the following exception:
System.AggregateException : One or more errors occurred. ---> Error HRESULT E_FAIL has been returned from a call to a COM component.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorker(Func`1 getFromDocument,IProgressTracker progressTracker,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.<>c__DisplayClass18_0.<InvokeCore>b__0()
   at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformAction(IExtensionManager extensionManager,Object extension,Action action)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
---> (Inner Exception #0) System.Runtime.InteropServices.COMException : Error HRESULT E_FAIL has been returned from a call to a COM component.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode,IntPtr errorInfo)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor..ctor(IServiceProvider serviceProvider,String filePath,IVisualStudioHostProject projectOpt,Boolean needsSave,Boolean needsUndoDisabled)
   at Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace.OpenInvisibleEditor(IVisualStudioHostDocument hostDocument)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DocumentProvider.StandardTextDocument.UpdateText(SourceText newText)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyDocumentTextChanged(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 Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation.TryApply(Workspace workspace,IProgressTracker progressTracker,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ProcessOperations(Workspace workspace,ImmutableArray`1 operations,IProgressTracker progressTracker,CancellationToken cancellationToken)
   at async Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ApplyAsync(<Unknown Parameters>)<---

@jinujoseph
Copy link
Contributor

potential dupe of #17265

@jinujoseph jinujoseph modified the milestones: 15.6, 15.7 Jan 23, 2018
@jinujoseph jinujoseph modified the milestones: 15.7, 15.8 Mar 7, 2018
@jinujoseph jinujoseph modified the milestones: 15.8, Unknown May 29, 2018
@jinujoseph jinujoseph added the Developer Community The issue was originally reported on https://developercommunity.visualstudio.com label Nov 11, 2018
@jinujoseph
Copy link
Contributor

jinujoseph commented Nov 11, 2018

also reported link
also reported link

@mavasani
Copy link
Member

This seems to repro consistently when attempting to run FixAll on project/solution for IDE0055 (Fix formatting) on roslyn-analyzers solution.

  1. Sync to https://github.com/mavasani/roslyn-analyzers/tree/CodeStyle
  2. Restore on command line and open RoslynAnalyzers.sln
  3. Attempt to apply FixAll for IDE0055 on project/solution

Crash is in Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor..ctor

Tagging @sharwell

@mavasani
Copy link
Member

Actually, closing and re-opening the solution and doing a project by project FixAll in project seems to work fine. Likely FixAll in solution causes this issue, which leads to unsaved modified files showing up in Team Explorer and from then on each FixAll in project/solution fails with the same stack.

@jasonmalinowski
Copy link
Member

@mavasani This is on our backlog w/o any assignee, do you think we need to prioritize this?

@mavasani
Copy link
Member

Assigning to @sharwell who wanted to take the first look.

@mavasani mavasani modified the milestones: Backlog, 16.0.P4 Jan 31, 2019
@mavasani
Copy link
Member

@sharwell @jinujoseph Feel free to move to a different milestone or assign to someone else, as appropriate.

@mavasani
Copy link
Member

Also reported at #39915

@davkean
Copy link
Member

davkean commented Nov 22, 2019

This is blocking me from changing severity of a code fix in project-system.

@davkean
Copy link
Member

davkean commented Nov 22, 2019

@mavasani @jinujoseph This is on backlog with no milestone, yet this is preventing a new feature that was just added from working in my repo, probably want to move it forward.

@mavasani
Copy link
Member

@davkean Does it repro consistently for you on project-system repo?

@davkean
Copy link
Member

davkean commented Nov 22, 2019

Yes,

@mavasani mavasani modified the milestones: Backlog, 16.5 Nov 22, 2019
@mavasani mavasani self-assigned this Nov 22, 2019
@mavasani
Copy link
Member

@davkean I am unable to repro this on the latest internal dogfood build with the steps mentioned in #39915. I did find an internal Watson for this, which shows that InvisibleEditor creation failed when invoking the VS API GetDocData here. We use the invisible editor to perform undoable edits, something that we probably want to ensure for all code fix applications, so I am not sure we have a good enough alternative path we can take when this fails - @jasonmalinowski might know more about InvisibleEditor and our alternatives when its creation fails.

@davkean
Copy link
Member

davkean commented Nov 26, 2019

Yes I cannot repro using the latest master that those steps either.

@mavasani
Copy link
Member

mavasani commented Nov 26, 2019

VS implementation of IVsInvisibleEditor.GetDocData API makes me feel it can return a failed status in multiple cases. I think we should think about gracefully handling failure of InvisibleEditor creation for creating undoable edits instead of throwing.

@jasonmalinowski
Copy link
Member

So yeah, we could gracefully handle the failure, but it's unclear to me exactly what we'd do: we could write to the file system directly, but that opens up other cans of worms around encoding. Is there something we can do to make this more diagnosable?

@davkean
Copy link
Member

davkean commented Nov 26, 2019

You might be able to repro this failing by turn Team Foundation Source Control as default source control, change the following:

image

And make the file read-only, and cancel prompt to edit it.

@mavasani mavasani modified the milestones: 16.5, Backlog Jan 15, 2020
@EzeKees
Copy link

EzeKees commented Jul 10, 2022

Same problem here during years....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com
Projects
None yet
Development

No branches or pull requests

7 participants