From b1430983b25802c6e11f696a5f8574ec07385333 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 4 Aug 2020 07:56:06 -0700 Subject: [PATCH] Remove unnecessary constructor chaining in DiagnosticService --- .../Core/Portable/Diagnostics/DiagnosticService.cs | 9 ++++++++- ...nosticService_UpdateSourceRegistrationService.cs | 13 ------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticService.cs b/src/Features/Core/Portable/Diagnostics/DiagnosticService.cs index bddee756b80..12290fda96c 100644 --- a/src/Features/Core/Portable/Diagnostics/DiagnosticService.cs +++ b/src/Features/Core/Portable/Diagnostics/DiagnosticService.cs @@ -30,12 +30,19 @@ internal partial class DiagnosticService : IDiagnosticService private readonly EventListenerTracker _eventListenerTracker; + private ImmutableHashSet _updateSources; + [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public DiagnosticService( IAsynchronousOperationListenerProvider listenerProvider, - [ImportMany] IEnumerable> eventListeners) : this() + [ImportMany] IEnumerable> eventListeners) { + // we use registry service rather than doing MEF import since MEF import method can have race issue where + // update source gets created before aggregator - diagnostic service - is created and we will lose events fired before + // the aggregator is created. + _updateSources = ImmutableHashSet.Empty; + // queue to serialize events. _eventMap = new EventMap(); diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticService_UpdateSourceRegistrationService.cs b/src/Features/Core/Portable/Diagnostics/DiagnosticService_UpdateSourceRegistrationService.cs index cb91d677965..f586248984e 100644 --- a/src/Features/Core/Portable/Diagnostics/DiagnosticService_UpdateSourceRegistrationService.cs +++ b/src/Features/Core/Portable/Diagnostics/DiagnosticService_UpdateSourceRegistrationService.cs @@ -2,26 +2,13 @@ // 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.Collections.Immutable; using System.Composition; -using System.Diagnostics.CodeAnalysis; namespace Microsoft.CodeAnalysis.Diagnostics { [Export(typeof(IDiagnosticUpdateSourceRegistrationService))] internal partial class DiagnosticService : IDiagnosticUpdateSourceRegistrationService { - private ImmutableHashSet _updateSources; - - [SuppressMessage("RoslyDiagnosticsReliability", "RS0034:Exported parts should have [ImportingConstructor]", Justification = "Private constructor used for deterministic field initialization")] - public DiagnosticService() - { - // we use registry service rather than doing MEF import since MEF import method can have race issue where - // update source gets created before aggregator - diagnostic service - is created and we will lose events fired before - // the aggregator is created. - _updateSources = ImmutableHashSet.Empty; - } - public void Register(IDiagnosticUpdateSource source) { lock (_gate) -- GitLab