-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture file content on open instead of save (#54643)
- Loading branch information
Showing
3 changed files
with
57 additions
and
63 deletions.
There are no files selected for viewing
62 changes: 0 additions & 62 deletions
62
...itorFeatures/Core/Implementation/EditAndContinue/EditAndContinueSaveFileCommandHandler.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...o/Core/Def/Implementation/EditAndContinue/VisualStudioWorkspaceEditAndContinueListener.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Composition; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.EditAndContinue; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.VisualStudio.LanguageServices.EditAndContinue | ||
{ | ||
/// <summary> | ||
/// Connects <see cref="VisualStudioWorkspace"/> to the ServiceHub services. | ||
/// Launches ServiceHub if it is not running yet and starts services that push information from <see cref="VisualStudioWorkspace"/> to the ServiceHub process. | ||
/// </summary> | ||
[ExportEventListener(WellKnownEventListeners.Workspace, WorkspaceKind.Host), Shared] | ||
internal sealed class VisualStudioWorkspaceEditAndContinueListener : IEventListener<object>, IEventListenerStoppable | ||
{ | ||
[ImportingConstructor] | ||
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
public VisualStudioWorkspaceEditAndContinueListener() | ||
{ | ||
} | ||
|
||
public void StartListening(Workspace workspace, object serviceOpt) | ||
{ | ||
if (workspace is not VisualStudioWorkspace) | ||
{ | ||
return; | ||
} | ||
|
||
workspace.DocumentOpened += WorkspaceDocumentOpened; | ||
} | ||
|
||
public void StopListening(Workspace workspace) | ||
{ | ||
if (workspace is not VisualStudioWorkspace) | ||
{ | ||
return; | ||
} | ||
|
||
workspace.DocumentOpened -= WorkspaceDocumentOpened; | ||
} | ||
|
||
private void WorkspaceDocumentOpened(object? sender, DocumentEventArgs e) | ||
{ | ||
var proxy = new RemoteEditAndContinueServiceProxy(e.Document.Project.Solution.Workspace); | ||
_ = Task.Run(() => proxy.OnSourceFileUpdatedAsync(e.Document, CancellationToken.None)).ReportNonFatalErrorAsync(); | ||
} | ||
} | ||
} |