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

Remove unnecessary constructor chaining in DiagnosticService

上级 b7913a66
......@@ -30,12 +30,19 @@ internal partial class DiagnosticService : IDiagnosticService
private readonly EventListenerTracker<IDiagnosticService> _eventListenerTracker;
private ImmutableHashSet<IDiagnosticUpdateSource> _updateSources;
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public DiagnosticService(
IAsynchronousOperationListenerProvider listenerProvider,
[ImportMany] IEnumerable<Lazy<IEventListener, EventListenerMetadata>> eventListeners) : this()
[ImportMany] IEnumerable<Lazy<IEventListener, EventListenerMetadata>> 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<IDiagnosticUpdateSource>.Empty;
// queue to serialize events.
_eventMap = new EventMap();
......
......@@ -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<IDiagnosticUpdateSource> _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<IDiagnosticUpdateSource>.Empty;
}
public void Register(IDiagnosticUpdateSource source)
{
lock (_gate)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册