Buildalyzer icon indicating copy to clipboard operation
Buildalyzer copied to clipboard

Experimental new tracing

Open Corniel opened this issue 1 year ago • 0 comments

The current way of logging/tracing the build results feel not right. This PR is way to improve on that. The idea is that a (extremely lightweight) BuildEventArgsCollector that has only one purpose; to collect all BuildEventArgs that are produced during the build.

private IAnalyzerResults BuildTargets(
    BuildEnvironment buildEnvironment, string targetFramework, string[] targetsToBuild, AnalyzerResults results)
{
    using var pipeLogger = new AnonymousPipeLoggerServer(cancellation.Token);
    using var collector = new BuildEventArgsCollector(pipeLogger);

    // ..
    var events = collector.ToImmutableArray();

    // Some mechanism to create analyzer results based on the created events
    return AnalyzerResults.FromEvents(events);
}

The idea is - and I've tested this already a bit - is that it is easier to create analyzer results based all collected events afterwards then during the process. On top of that, it also separates the code: there is code that collects, and there is code that processes the events.

Finally it makes it even easier to address the request of #278 because supporting additional languages is just a matter of registering some code that can create its own output based on the events collected.

Corniel avatar Sep 07 '24 08:09 Corniel