diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioInfoBarService.cs b/src/VisualStudio/Core/Def/Implementation/InfoBar/VisualStudioInfoBarService.cs similarity index 95% rename from src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioInfoBarService.cs rename to src/VisualStudio/Core/Def/Implementation/InfoBar/VisualStudioInfoBarService.cs index eac76f3fe41729ffd9655106486a04961792383d..65c2f2f3d3b0c86d6bbd5dd2c1a00a0134e0fea5 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioInfoBarService.cs +++ b/src/VisualStudio/Core/Def/Implementation/InfoBar/VisualStudioInfoBarService.cs @@ -5,7 +5,9 @@ using System.ComponentModel.Composition; using System.Linq; using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Extensions; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.VisualStudio.Imaging; using Microsoft.VisualStudio.Shell; @@ -14,8 +16,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation { - [Export(typeof(IInfoBarService))] - internal class VisualStudioInfoBarService : IInfoBarService + [ExportWorkspaceService(typeof(IInfoBarService))] + internal class VisualStudioInfoBarService : ForegroundThreadAffinitizedObject, IInfoBarService { private readonly IServiceProvider _serviceProvider; private readonly IForegroundNotificationService _foregroundNotificationService; @@ -33,11 +35,13 @@ internal class VisualStudioInfoBarService : IInfoBarService public void ShowInfoBarInActiveView(string message, params InfoBarUI[] items) { + ThisCanBeCalledOnAnyThread(); ShowInfoBar(activeView: true, message: message, items: items); } public void ShowInfoBarInGlobalView(string message, params InfoBarUI[] items) { + ThisCanBeCalledOnAnyThread(); ShowInfoBar(activeView: false, message: message, items: items); } @@ -55,6 +59,8 @@ private void ShowInfoBar(bool activeView, string message, params InfoBarUI[] ite private bool TryGetInfoBarData(bool activeView, out IVsInfoBarHost infoBarHost) { + AssertIsForeground(); + infoBarHost = null; if (activeView) diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioErrorReportingServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioErrorReportingServiceFactory.cs index 4005022fc4ce12af405c898dec2aa877d943a5f7..4fdc31eaf3991095c5986799cd476a2ade5e5ff6 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioErrorReportingServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioErrorReportingServiceFactory.cs @@ -10,16 +10,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation [ExportWorkspaceServiceFactory(typeof(IErrorReportingService), ServiceLayer.Host), Shared] internal sealed class VisualStudioErrorReportingServiceFactory : IWorkspaceServiceFactory { - private readonly IErrorReportingService _singleton; + private IErrorReportingService _singleton; [ImportingConstructor] - public VisualStudioErrorReportingServiceFactory(IInfoBarService infoBarService) + public VisualStudioErrorReportingServiceFactory() { - _singleton = new VisualStudioErrorReportingService(infoBarService); } public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { + if (_singleton == null) + { + _singleton = new VisualStudioErrorReportingService(workspaceServices.GetRequiredService()); + } return _singleton; } }