From 6be80e7bede5f9a8e29690f29b96e577ece398b3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 5 Dec 2017 12:54:16 -0800 Subject: [PATCH] Use windows VS error reporter instead of the no-op default --- .../VisualStudioErrorReporterFactory.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs new file mode 100644 index 0000000000..5a59a5a77e --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Shell; + +namespace Microsoft.VisualStudio.LanguageServices.Razor +{ + [Shared] + [ExportWorkspaceServiceFactory(typeof(ErrorReporter), ServiceLayer.Host)] + internal class VisualStudioErrorReporterFactory : IWorkspaceServiceFactory + { + private readonly IServiceProvider _serviceProvider; + + [ImportingConstructor] + public VisualStudioErrorReporterFactory(SVsServiceProvider serviceProvider) + { + if (serviceProvider == null) + { + throw new ArgumentNullException(nameof(serviceProvider)); + } + + _serviceProvider = serviceProvider; + } + + public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) + { + return new VisualStudioErrorReporter(_serviceProvider); + } + } +}