Skip to content

Commit

Permalink
Merge pull request #58697 from dotnet/merges/release/dev17.1-to-relea…
Browse files Browse the repository at this point in the history
…se/dev17.1-vs-deps

Merge release/dev17.1 to release/dev17.1-vs-deps
  • Loading branch information
dotnet-bot authored Jan 7, 2022
2 parents 9db89d4 + e79b92e commit f028ed9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Telemetry;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Composition;
Expand All @@ -33,11 +35,14 @@
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.MetadataReferences;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Microsoft.VisualStudio.LanguageServices.Implementation.Venus;
using Microsoft.VisualStudio.LanguageServices.Telemetry;
using Microsoft.VisualStudio.LanguageServices.Utilities;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Telemetry;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;
using VSLangProj;
using VSLangProj140;
Expand Down Expand Up @@ -197,6 +202,12 @@ public async Task InitializeUIAffinitizedServicesAsync(IAsyncServiceProvider asy
// Create services that are bound to the UI thread
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(_threadingContext.DisposalToken);

// Fetch the session synchronously on the UI thread; if this doesn't happen before we try using this on
// the background thread then we will experience hangs like we see in this bug:
// https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=190808 or
// https://devdiv.visualstudio.com/DevDiv/_workitems?id=296981&_a=edit
var telemetrySession = TelemetryService.DefaultSession;

var solutionClosingContext = UIContext.FromUIContextGuid(VSConstants.UICONTEXT.SolutionClosing_guid);
solutionClosingContext.UIContextChanged += (_, e) => _solutionClosing = e.Activated;

Expand All @@ -215,6 +226,15 @@ public async Task InitializeUIAffinitizedServicesAsync(IAsyncServiceProvider asy
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(_threadingContext.DisposalToken);

openFileTracker.ProcessQueuedWorkOnUIThread();

// Switch to a background thread to avoid loading option providers on UI thread (telemetry is reading options).
await TaskScheduler.Default;

var telemetryService = (VisualStudioWorkspaceTelemetryService)Services.GetRequiredService<IWorkspaceTelemetryService>();
telemetryService.InitializeTelemetrySession(telemetrySession);

Logger.Log(FunctionId.Run_Environment,
KeyValueLogMessage.Create(m => m["Version"] = FileVersionInfo.GetVersionInfo(typeof(VisualStudioWorkspace).Assembly.Location).FileVersion));
}

public void QueueCheckForFilesBeingOpen(ImmutableArray<string> newFileNames)
Expand Down
10 changes: 0 additions & 10 deletions src/VisualStudio/Core/Def/RoslynPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke

_workspace = this.ComponentModel.GetService<VisualStudioWorkspace>();

// Fetch the session synchronously on the UI thread; if this doesn't happen before we try using this on
// the background thread then we will experience hangs like we see in this bug:
// https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=190808 or
// https://devdiv.visualstudio.com/DevDiv/_workitems?id=296981&_a=edit
var telemetryService = (VisualStudioWorkspaceTelemetryService)_workspace.Services.GetRequiredService<IWorkspaceTelemetryService>();
telemetryService.InitializeTelemetrySession(TelemetryService.DefaultSession);

Logger.Log(FunctionId.Run_Environment,
KeyValueLogMessage.Create(m => m["Version"] = FileVersionInfo.GetVersionInfo(typeof(VisualStudioWorkspace).Assembly.Location).FileVersion));

InitializeColors();

// load some services that have to be loaded in UI thread
Expand Down

0 comments on commit f028ed9

Please sign in to comment.