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

Capture file content on open instead of save #54643

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void OnSourceFileUpdated(Document document)
foreach (var debuggingSession in GetActiveDebuggingSessions())
{
// fire and forget
_ = Task.Run(() => debuggingSession.OnSourceFileUpdatedAsync(document));
_ = Task.Run(() => debuggingSession.OnSourceFileUpdatedAsync(document)).ReportNonFatalErrorAsync();
}
}

Expand Down
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();
}
}
}