diff --git a/src/EditorFeatures/CSharpTest/CodeActions/Preview/PreviewExceptionTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/Preview/PreviewExceptionTests.cs index 0279cde48884d..c9cb8ab98b1dd 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/Preview/PreviewExceptionTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/Preview/PreviewExceptionTests.cs @@ -13,6 +13,7 @@ using Microsoft.CodeAnalysis.Editor.Implementation.Suggestions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; diff --git a/src/EditorFeatures/Core/Workspaces/EditorErrorReportingService.cs b/src/EditorFeatures/Core/ErrorReporting/EditorErrorReportingService.cs similarity index 66% rename from src/EditorFeatures/Core/Workspaces/EditorErrorReportingService.cs rename to src/EditorFeatures/Core/ErrorReporting/EditorErrorReportingService.cs index 62fc8fb137562..1c3ce53a6e287 100644 --- a/src/EditorFeatures/Core/Workspaces/EditorErrorReportingService.cs +++ b/src/EditorFeatures/Core/ErrorReporting/EditorErrorReportingService.cs @@ -3,14 +3,22 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.CodeAnalysis.Extensions; +using System.Composition; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Telemetry; -namespace Microsoft.CodeAnalysis.Editor.Implementation.Workspaces +namespace Microsoft.CodeAnalysis.ErrorReporting { - internal class EditorErrorReportingService : IErrorReportingService + [ExportWorkspaceService(typeof(IErrorReportingService), ServiceLayer.Editor), Shared] + internal sealed class EditorErrorReportingService : IErrorReportingService { + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public EditorErrorReportingService() + { + } + public string HostDisplayName => "host"; public void ShowDetailedErrorInfo(Exception exception) diff --git a/src/EditorFeatures/Core/Extensions/EditorLayerExtensionManager.cs b/src/EditorFeatures/Core/Extensions/EditorLayerExtensionManager.cs index 0a4e0d733d82e..54c3cdacdadfd 100644 --- a/src/EditorFeatures/Core/Extensions/EditorLayerExtensionManager.cs +++ b/src/EditorFeatures/Core/Extensions/EditorLayerExtensionManager.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Editor.Options; using Microsoft.CodeAnalysis.ErrorLogger; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; diff --git a/src/EditorFeatures/Core/InfoBar/EditorInfoBarService.cs b/src/EditorFeatures/Core/InfoBar/EditorInfoBarService.cs deleted file mode 100644 index 437f129f7ef09..0000000000000 --- a/src/EditorFeatures/Core/InfoBar/EditorInfoBarService.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#nullable disable - -using System; -using System.Composition; -using Microsoft.CodeAnalysis.Extensions; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Internal.Log; - -namespace Microsoft.CodeAnalysis.Editor.Implementation.Workspaces -{ - [ExportWorkspaceService(typeof(IInfoBarService)), Shared] - internal class EditorInfoBarService : IInfoBarService - { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public EditorInfoBarService() - { - } - - public void ShowInfoBar(string message, params InfoBarUI[] items) - => Logger.Log(FunctionId.Extension_InfoBar, message); - } -} diff --git a/src/EditorFeatures/Core/Workspaces/EditorErrorReportingServiceFactory.cs b/src/EditorFeatures/Core/Workspaces/EditorErrorReportingServiceFactory.cs deleted file mode 100644 index 3872453ce3477..0000000000000 --- a/src/EditorFeatures/Core/Workspaces/EditorErrorReportingServiceFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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. - -#nullable disable - -using System; -using System.Composition; -using Microsoft.CodeAnalysis.Extensions; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.Editor.Implementation.Workspaces -{ - [ExportWorkspaceServiceFactory(typeof(IErrorReportingService), ServiceLayer.Editor), Shared] - internal class EditorErrorReportingServiceFactory : IWorkspaceServiceFactory - { - private readonly IErrorReportingService _singleton = new EditorErrorReportingService(); - - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public EditorErrorReportingServiceFactory() - { - } - - public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) - => _singleton; - } -} diff --git a/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs b/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs index d29746f7892a1..9edc5902fc382 100644 --- a/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs +++ b/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.ErrorLogger; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.PooledObjects; diff --git a/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs b/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs index 7029f5bbc819b..43d84445e200f 100644 --- a/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs +++ b/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; diff --git a/src/Features/Core/Portable/CodeFixes/CodeFixService.cs b/src/Features/Core/Portable/CodeFixes/CodeFixService.cs index 401517ac5ebe0..add4125ad7016 100644 --- a/src/Features/Core/Portable/CodeFixes/CodeFixService.cs +++ b/src/Features/Core/Portable/CodeFixes/CodeFixService.cs @@ -16,6 +16,7 @@ using Microsoft.CodeAnalysis.CodeFixes.Suppression; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ErrorLogger; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Internal.Log; diff --git a/src/VisualStudio/Core/Def/Workspace/DetailedErrorInfoDialog.xaml b/src/VisualStudio/Core/Def/ErrorReporting/DetailedErrorInfoDialog.xaml similarity index 92% rename from src/VisualStudio/Core/Def/Workspace/DetailedErrorInfoDialog.xaml rename to src/VisualStudio/Core/Def/ErrorReporting/DetailedErrorInfoDialog.xaml index 58242b98e1f7c..e9485dfd4761e 100644 --- a/src/VisualStudio/Core/Def/Workspace/DetailedErrorInfoDialog.xaml +++ b/src/VisualStudio/Core/Def/ErrorReporting/DetailedErrorInfoDialog.xaml @@ -1,8 +1,8 @@ - { diff --git a/src/VisualStudio/Core/Def/ErrorReporting/VisualStudioInfoBar.cs b/src/VisualStudio/Core/Def/ErrorReporting/VisualStudioInfoBar.cs new file mode 100644 index 0000000000000..2328e0861c842 --- /dev/null +++ b/src/VisualStudio/Core/Def/ErrorReporting/VisualStudioInfoBar.cs @@ -0,0 +1,157 @@ +// 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.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Shared.TestHooks; +using Microsoft.VisualStudio; +using Microsoft.VisualStudio.Imaging; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ErrorReporting +{ + internal sealed class VisualStudioInfoBar + { + private readonly IThreadingContext _threadingContext; + private readonly SVsServiceProvider _serviceProvider; + private readonly IAsynchronousOperationListener _listener; + + /// + /// Keep track of the messages that are currently being shown to the user. If we would + /// show the same message again, block that from happening so we don't spam the user with + /// the same message. When the info bar item is dismissed though, we then may show the + /// same message in the future. This is important for user clarity as it's possible for + /// a feature to fail for some reason, then work fine for a while, then fail again. We want + /// the second failure message to be reported to ensure the user is not confused. + /// + /// Accessed on UI thread. + /// + private readonly HashSet _currentlyShowingMessages = new(); + + public VisualStudioInfoBar( + IThreadingContext threadingContext, + SVsServiceProvider serviceProvider, + IAsynchronousOperationListenerProvider listenerProvider) + { + _threadingContext = threadingContext; + _serviceProvider = serviceProvider; + _listener = listenerProvider.GetListener(FeatureAttribute.InfoBar); + } + + public void ShowInfoBar(string message, params InfoBarUI[] items) + { + // We can be called from any thread since errors can occur anywhere, however we can only construct and InfoBar from the UI thread. + _threadingContext.JoinableTaskFactory.RunAsync(async () => + { + using var _ = _listener.BeginAsyncOperation(nameof(ShowInfoBar)); + + await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(_threadingContext.DisposalToken); + + // If we're already shown this same message to the user, then do not bother showing it + // to them again. It will just be noisy. + if (!_currentlyShowingMessages.Contains(message) && + _serviceProvider.GetService(typeof(SVsShell)) is IVsShell shell && + ErrorHandler.Succeeded(shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var globalInfoBar)) && + globalInfoBar is IVsInfoBarHost infoBarHost && + _serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) is IVsInfoBarUIFactory factory) + { + // create action item list + var actionItems = new List(); + + foreach (var item in items) + { + switch (item.Kind) + { + case InfoBarUI.UIKind.Button: + actionItems.Add(new InfoBarButton(item.Title)); + break; + case InfoBarUI.UIKind.HyperLink: + actionItems.Add(new InfoBarHyperlink(item.Title)); + break; + case InfoBarUI.UIKind.Close: + break; + default: + throw ExceptionUtilities.UnexpectedValue(item.Kind); + } + } + + var infoBarModel = new InfoBarModel( + new[] { new InfoBarTextSpan(message) }, + actionItems, + KnownMonikers.StatusInformation, + isCloseButtonVisible: true); + + var infoBarUI = factory.CreateInfoBar(infoBarModel); + if (infoBarUI == null) + return; + + uint? infoBarCookie = null; + var eventSink = new InfoBarEvents(items, onClose: () => + { + Contract.ThrowIfFalse(_threadingContext.JoinableTaskContext.IsOnMainThread); + + // Remove the message from the list that we're keeping track of. Future identical + // messages can now be shown. + _currentlyShowingMessages.Remove(message); + + // Run given onClose action if there is one. + items.FirstOrDefault(i => i.Kind == InfoBarUI.UIKind.Close).Action?.Invoke(); + + if (infoBarCookie.HasValue) + { + infoBarUI.Unadvise(infoBarCookie.Value); + } + }); + + infoBarUI.Advise(eventSink, out var cookie); + infoBarCookie = cookie; + + infoBarHost.AddInfoBar(infoBarUI); + + _currentlyShowingMessages.Add(message); + } + }); + } + + private sealed class InfoBarEvents : IVsInfoBarUIEvents + { + private readonly InfoBarUI[] _items; + private readonly Action _onClose; + + public InfoBarEvents(InfoBarUI[] items, Action onClose) + { + Contract.ThrowIfNull(onClose); + + _items = items; + _onClose = onClose; + } + + public void OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement, IVsInfoBarActionItem actionItem) + { + var item = _items.FirstOrDefault(i => i.Title == actionItem.Text); + if (item.IsDefault) + { + return; + } + + item.Action?.Invoke(); + + if (!item.CloseAfterAction) + { + return; + } + + infoBarUIElement.Close(); + } + + public void OnClosed(IVsInfoBarUIElement infoBarUIElement) + => _onClose(); + } + } +} diff --git a/src/VisualStudio/Core/Def/ExternalAccess/LegacyCodeAnalysis/LegacyCodeAnalysisVisualStudioSuppressionFixServiceAccessor.cs b/src/VisualStudio/Core/Def/ExternalAccess/LegacyCodeAnalysis/LegacyCodeAnalysisVisualStudioSuppressionFixServiceAccessor.cs index 51835b117629c..7814b414389a1 100644 --- a/src/VisualStudio/Core/Def/ExternalAccess/LegacyCodeAnalysis/LegacyCodeAnalysisVisualStudioSuppressionFixServiceAccessor.cs +++ b/src/VisualStudio/Core/Def/ExternalAccess/LegacyCodeAnalysis/LegacyCodeAnalysisVisualStudioSuppressionFixServiceAccessor.cs @@ -6,6 +6,7 @@ using System.Composition; using Microsoft.CodeAnalysis.Telemetry; using Microsoft.CodeAnalysis.Extensions; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.ExternalAccess.LegacyCodeAnalysis.Api; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.LanguageServices; diff --git a/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs b/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs index 16f74311f2e5c..603383618b9c0 100644 --- a/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs +++ b/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs @@ -9,11 +9,10 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; -using Microsoft.CodeAnalysis.Extensions; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.Options; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Telemetry; using Microsoft.VisualStudio.LanguageServices.Implementation; diff --git a/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarService.cs b/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarService.cs deleted file mode 100644 index c236e2aded1b7..0000000000000 --- a/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarService.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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. - -#nullable disable - -using System; -using System.Collections.Generic; -using System.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; -using Microsoft.VisualStudio.Shell.Interop; -using Roslyn.Utilities; - -namespace Microsoft.VisualStudio.LanguageServices.Implementation -{ - [Export(typeof(VisualStudioInfoBarService)), Shared] - internal sealed class VisualStudioInfoBarService : ForegroundThreadAffinitizedObject - { - private readonly SVsServiceProvider _serviceProvider; - private readonly IAsynchronousOperationListener _listener; - - /// - /// Keep track of the messages that are currently being shown to the user. If we would - /// show the same message again, block that from happening so we don't spam the user with - /// the same message. When the info bar item is dismissed though, we then may show the - /// same message in the future. This is important for user clarity as it's possible for - /// a feature to fail for some reason, then work fine for a while, then fail again. We want - /// the second failure message to be reported to ensure the user is not confused. - /// - private readonly HashSet _currentlyShowingMessages = new(); - - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public VisualStudioInfoBarService( - IThreadingContext threadingContext, - SVsServiceProvider serviceProvider, - IAsynchronousOperationListenerProvider listenerProvider) - : base(threadingContext) - { - _serviceProvider = serviceProvider; - _listener = listenerProvider.GetListener(FeatureAttribute.InfoBar); - } - - public void ShowInfoBar(string message, params InfoBarUI[] items) - { - ThisCanBeCalledOnAnyThread(); - - // We can be called from any thread since errors can occur anywhere, however we can only construct and InfoBar from the UI thread. - this.ThreadingContext.JoinableTaskFactory.RunAsync(async () => - { - using var _ = _listener.BeginAsyncOperation(nameof(ShowInfoBar)); - await this.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(ThreadingContext.DisposalToken); - if (TryGetInfoBarData(out var infoBarHost)) - CreateInfoBar(infoBarHost, message, items); - }); - } - - private bool TryGetInfoBarData(out IVsInfoBarHost infoBarHost) - { - AssertIsForeground(); - - infoBarHost = null; - - // global error info, show it on main window info bar - if (_serviceProvider.GetService(typeof(SVsShell)) is not IVsShell shell || - ErrorHandler.Failed(shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var globalInfoBar))) - { - return false; - } - - infoBarHost = globalInfoBar as IVsInfoBarHost; - return infoBarHost != null; - } - - private void CreateInfoBar(IVsInfoBarHost infoBarHost, string message, InfoBarUI[] items) - { - this.AssertIsForeground(); - - if (_serviceProvider.GetService(typeof(SVsInfoBarUIFactory)) is not IVsInfoBarUIFactory factory) - { - // no info bar factory, don't do anything - return; - } - - // If we're already shown this same message to the user, then do not bother showing it - // to them again. It will just be noisy. - if (_currentlyShowingMessages.Contains(message)) - return; - - var textSpans = new List() - { - new InfoBarTextSpan(message) - }; - - // create action item list - var actionItems = new List(); - - foreach (var item in items) - { - switch (item.Kind) - { - case InfoBarUI.UIKind.Button: - actionItems.Add(new InfoBarButton(item.Title)); - break; - case InfoBarUI.UIKind.HyperLink: - actionItems.Add(new InfoBarHyperlink(item.Title)); - break; - case InfoBarUI.UIKind.Close: - break; - default: - throw ExceptionUtilities.UnexpectedValue(item.Kind); - } - } - - var infoBarModel = new InfoBarModel( - textSpans, - actionItems, - KnownMonikers.StatusInformation, - isCloseButtonVisible: true); - - var infoBarUI = factory.CreateInfoBar(infoBarModel); - if (infoBarUI == null) - return; - - uint? infoBarCookie = null; - var eventSink = new InfoBarEvents(items, onClose: () => - { - // Remove the message from the list that we're keeping track of. Future identical - // messages can now be shown. - _currentlyShowingMessages.Remove(message); - - // Run given onClose action if there is one. - items.FirstOrDefault(i => i.Kind == InfoBarUI.UIKind.Close).Action?.Invoke(); - - if (infoBarCookie.HasValue) - { - infoBarUI.Unadvise(infoBarCookie.Value); - } - }); - - infoBarUI.Advise(eventSink, out var cookie); - infoBarCookie = cookie; - - infoBarHost.AddInfoBar(infoBarUI); - _currentlyShowingMessages.Add(message); - } - - private class InfoBarEvents : IVsInfoBarUIEvents - { - private readonly InfoBarUI[] _items; - private readonly Action _onClose; - - public InfoBarEvents(InfoBarUI[] items, Action onClose) - { - Contract.ThrowIfNull(onClose); - - _items = items; - _onClose = onClose; - } - - public void OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement, IVsInfoBarActionItem actionItem) - { - var item = _items.FirstOrDefault(i => i.Title == actionItem.Text); - if (item.IsDefault) - { - return; - } - - item.Action?.Invoke(); - - if (!item.CloseAfterAction) - { - return; - } - - infoBarUIElement.Close(); - } - - public void OnClosed(IVsInfoBarUIElement infoBarUIElement) - => _onClose(); - } - } -} diff --git a/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarWorkspaceService.cs b/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarWorkspaceService.cs deleted file mode 100644 index d1130963b1434..0000000000000 --- a/src/VisualStudio/Core/Def/InfoBar/VisualStudioInfoBarWorkspaceService.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#nullable disable - -using System; -using System.Composition; -using Microsoft.CodeAnalysis.Extensions; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.VisualStudio.LanguageServices.Implementation -{ - [ExportWorkspaceService(typeof(IInfoBarService), layer: ServiceLayer.Host), Shared] - internal sealed class VisualStudioInfoBarWorkspaceService : IInfoBarService - { - private readonly VisualStudioInfoBarService _service; - - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public VisualStudioInfoBarWorkspaceService(VisualStudioInfoBarService service) - => _service = service; - - public void ShowInfoBar(string message, params InfoBarUI[] items) - => _service.ShowInfoBar(message, items); - } -} diff --git a/src/VisualStudio/Core/Def/KeybindingReset/KeybindingResetDetector.cs b/src/VisualStudio/Core/Def/KeybindingReset/KeybindingResetDetector.cs index af3d8fc725dce..600e2e85ec2a2 100644 --- a/src/VisualStudio/Core/Def/KeybindingReset/KeybindingResetDetector.cs +++ b/src/VisualStudio/Core/Def/KeybindingReset/KeybindingResetDetector.cs @@ -64,7 +64,7 @@ internal sealed class KeybindingResetDetector : ForegroundThreadAffinitizedObjec private readonly IGlobalOptionService _globalOptions; private readonly System.IServiceProvider _serviceProvider; - private readonly VisualStudioInfoBarService _infoBarService; + private readonly VisualStudioInfoBar _infoBarService; // All mutable fields are UI-thread affinitized @@ -91,7 +91,7 @@ internal sealed class KeybindingResetDetector : ForegroundThreadAffinitizedObjec public KeybindingResetDetector( IThreadingContext threadingContext, IGlobalOptionService globalOptions, - VisualStudioInfoBarService infoBarService, + VisualStudioInfoBar infoBarService, SVsServiceProvider serviceProvider) : base(threadingContext) { diff --git a/src/VisualStudio/Core/Def/Workspace/VisualStudioErrorReportingServiceFactory.cs b/src/VisualStudio/Core/Def/Workspace/VisualStudioErrorReportingServiceFactory.cs deleted file mode 100644 index 1305f6fd82ad5..0000000000000 --- a/src/VisualStudio/Core/Def/Workspace/VisualStudioErrorReportingServiceFactory.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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 Microsoft.CodeAnalysis.Editor.Shared.Utilities; -using Microsoft.CodeAnalysis.Extensions; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.Shell; - -namespace Microsoft.VisualStudio.LanguageServices.Implementation -{ - [ExportWorkspaceServiceFactory(typeof(IErrorReportingService), ServiceLayer.Host), Shared] - internal sealed class VisualStudioErrorReportingServiceFactory : IWorkspaceServiceFactory - { - private readonly IThreadingContext _threadingContext; - private readonly IAsynchronousOperationListenerProvider _listenerProvider; - private readonly SVsServiceProvider _serviceProvider; - - private IErrorReportingService? _singleton; - - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public VisualStudioErrorReportingServiceFactory( - IThreadingContext threadingContext, - IAsynchronousOperationListenerProvider listenerProvider, - SVsServiceProvider serviceProvider) - { - _threadingContext = threadingContext; - _listenerProvider = listenerProvider; - _serviceProvider = serviceProvider; - } - - public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) - { - if (_singleton == null) - { - _singleton = new VisualStudioErrorReportingService( - _threadingContext, - _listenerProvider, - workspaceServices.GetRequiredService(), - _serviceProvider); - } - - return _singleton; - } - } -} diff --git a/src/Workspaces/Core/Portable/ExtensionManager/IErrorReportingService.cs b/src/Workspaces/Core/Portable/ErrorReporting/IErrorReportingService.cs similarity index 95% rename from src/Workspaces/Core/Portable/ExtensionManager/IErrorReportingService.cs rename to src/Workspaces/Core/Portable/ErrorReporting/IErrorReportingService.cs index 44a47f51142dc..cb7de711cbeae 100644 --- a/src/Workspaces/Core/Portable/ExtensionManager/IErrorReportingService.cs +++ b/src/Workspaces/Core/Portable/ErrorReporting/IErrorReportingService.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Telemetry; -namespace Microsoft.CodeAnalysis.Extensions +namespace Microsoft.CodeAnalysis.ErrorReporting { internal interface IErrorReportingService : IWorkspaceService { diff --git a/src/Workspaces/Core/Portable/ExtensionManager/IInfoBarService.cs b/src/Workspaces/Core/Portable/ErrorReporting/InfoBarUI.cs similarity index 76% rename from src/Workspaces/Core/Portable/ExtensionManager/IInfoBarService.cs rename to src/Workspaces/Core/Portable/ErrorReporting/InfoBarUI.cs index 4fccee988cd09..48daea96abded 100644 --- a/src/Workspaces/Core/Portable/ExtensionManager/IInfoBarService.cs +++ b/src/Workspaces/Core/Portable/ErrorReporting/InfoBarUI.cs @@ -4,19 +4,10 @@ using System; using System.Diagnostics.CodeAnalysis; -using Microsoft.CodeAnalysis.Host; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Extensions +namespace Microsoft.CodeAnalysis.ErrorReporting { - internal interface IInfoBarService : IWorkspaceService - { - /// - /// Show global info bar - /// - void ShowInfoBar(string message, params InfoBarUI[] items); - } - internal struct InfoBarUI { public readonly string? Title; diff --git a/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs b/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs index 7aba10a48ba24..cf5ac3423a067 100644 --- a/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs +++ b/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.EditAndContinue; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.StackTraceExplorer; diff --git a/src/Workspaces/CoreTestUtilities/TestErrorReportingService.cs b/src/Workspaces/CoreTestUtilities/TestErrorReportingService.cs index 0d52027c1eac8..0238e010c6885 100644 --- a/src/Workspaces/CoreTestUtilities/TestErrorReportingService.cs +++ b/src/Workspaces/CoreTestUtilities/TestErrorReportingService.cs @@ -5,6 +5,7 @@ using System; using System.Composition; using Microsoft.CodeAnalysis.Extensions; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Telemetry; using Xunit;