Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

Hit this while trying to actually do fix-all in roslyn. i'd like us to not block changes while also getting NFWs to help track down what causes this.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 21, 2025 21:52
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 21, 2025
using var invisibleEditor = OpenInvisibleEditor(documentId);
TextEditApplication.UpdateText(newText, invisibleEditor.TextBuffer, EditOptions.None);
}
catch (System.Runtime.InteropServices.COMException ex) when (FatalError.ReportAndCatch(ex))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this may not do much for us to diagnose this -- the COMException usually means the native stack has already unwound and returned to us an HRESULT.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't hurt to merge this, it just might not be as useful as you're hoping.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old version of this code will cause an entire Fix All to fail to apply, and show an error to the user. I'm concerned the new code allows the Fix All to silently fail to apply part of a change and not present anything to the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old version just silently fails, without a message. Furthermore, I can't do anything.

This version at least succeeds, tells is there is an issue, and let's me fix the remaining files manually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to take this through. THe cons of hte current system are that it fails, and you have no recourse.

This approach allows most of hte operation to succeed and gives us information in the form of NFWs that we can use to justify investigations into fixing this. e.g. how many hits we're getting of this underlying problem. Right now, we've had ethe problem for years, with no movement. So this seems strictly better for customers, and mildly better for us.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I had missed this was report and catch and not report and propagate.

My worry with blindly catching is we're going to get some number of bugs where a fix applies part way, and the user will report that something didn't update, and we won't really know if this was the cause or not. How hard would it be to have a boolean that we clear at the start of TryApplyChanges, set if that catch triggers, and at the end of TryApplyChanges just pop a dialog that says "due to an internal error, the change partially applied"? Assuming users will at least say "hey I got that error message" we know what happened for them versus there being a bug in the refactoring that meant it missed a place to update in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we get no message today when things partially apply (existing files remain edited, we don't roll them back), or fail to apply. So it seems like we're already bad.

But i can try to add some message. But this really feels like overkill when we're already in a bad state. This just gets us marginally better for users (some more changes, instead of less), and gets us information on the problem.

@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski ptal.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice, and I like this applies to all failures, not just the invisible editor path specifically if something else goes wrong.

private bool _isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents;

/// <summary>
/// Only read/written on hte UI thread.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Only read/written on hte UI thread.
/// Only read/written on the UI thread.

Comment on lines +1273 to +1275
// All info bar actions (except for 'show stack trace') dismiss the info bar, putting us back in the
// "we're not showing the user anything" state.
_isShowingDocumentChangeErrorInfoBar = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too bad there's not a generic way for us just to pass a handler for "any way this goes away".... :-/

@CyrusNajmabadi CyrusNajmabadi merged commit 0cc8235 into dotnet:main Apr 23, 2025
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the invisibleCrash branch April 23, 2025 22:11
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 23, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants