-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathBuildCheckConnectorLogger.cs
52 lines (41 loc) · 1.62 KB
/
BuildCheckConnectorLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.Framework;
namespace Microsoft.Build.Experimental.BuildCheck.Infrastructure;
/// <summary>
/// Central logger for the build check infrastructure.
/// Receives events from the <see cref="BuildCheckForwardingLogger"/>.
/// Processes the events and forwards them to the <see cref="IBuildCheckManager"/> and registered checks.
/// </summary>
/// <remarks>
/// Ensure that the consuming events are in sync with <see cref="BuildCheckForwardingLogger"/>.
/// </remarks>
internal sealed class BuildCheckConnectorLogger : ILogger
{
private readonly BuildCheckBuildEventHandler _eventHandler;
internal BuildCheckConnectorLogger(
ICheckContextFactory checkContextFactory,
IBuildCheckManager buildCheckManager)
{
_eventHandler = new BuildCheckBuildEventHandler(checkContextFactory, buildCheckManager);
}
public LoggerVerbosity Verbosity { get; set; }
public string? Parameters { get; set; }
public void Initialize(IEventSource eventSource)
{
eventSource.AnyEventRaised += EventSource_AnyEventRaised;
if (eventSource is IEventSource3 eventSource3)
{
eventSource3.IncludeTaskInputs();
}
if (eventSource is IEventSource4 eventSource4)
{
eventSource4.IncludeEvaluationPropertiesAndItems();
}
}
public void Shutdown()
{
}
private void EventSource_AnyEventRaised(object sender, BuildEventArgs e)
=> _eventHandler.HandleBuildEvent(e);
}