提交 cff02436 编写于 作者: S Sam Harwell

Use MEF catalog instead of direct construction

上级 8f4ca694
......@@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
......@@ -44,7 +43,7 @@ internal partial class DiagnosticsClassificationTaggerProvider : AbstractDiagnos
protected override IEnumerable<Option2<bool>> Options => s_tagSourceOptions;
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public DiagnosticsClassificationTaggerProvider(
IThreadingContext threadingContext,
IDiagnosticService diagnosticService,
......
......@@ -7,15 +7,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Test.Utilities;
......@@ -58,7 +57,7 @@ internal class DiagnosticTaggerWrapper<TProvider, TTag> : IDisposable
_registrationService = workspace.Services.GetRequiredService<ISolutionCrawlerRegistrationService>();
_registrationService.Register(workspace);
DiagnosticService = new DiagnosticService(_listenerProvider, Array.Empty<Lazy<IEventListener, EventListenerMetadata>>());
DiagnosticService = (DiagnosticService)workspace.ExportProvider.GetExportedValue<IDiagnosticService>();
DiagnosticService.Register(updateSource);
if (createTaggerProvider)
......@@ -99,13 +98,9 @@ public ITaggerProvider TaggerProvider
}
else if (typeof(TProvider) == typeof(DiagnosticsClassificationTaggerProvider))
{
_taggerProvider = new DiagnosticsClassificationTaggerProvider(
_threadingContext,
DiagnosticService,
_workspace.ExportProvider.GetExportedValue<ClassificationTypeMap>(),
_workspace.GetService<IForegroundNotificationService>(),
_workspace.GetService<IEditorOptionsFactoryService>(),
_listenerProvider);
_taggerProvider = _workspace.ExportProvider.GetExportedValues<ITaggerProvider>()
.OfType<DiagnosticsClassificationTaggerProvider>()
.Single();
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册