Source Code

This page explains the design and internal organization of TFS Aggregator v2’s code. If you want to rebuild, customize, submit changes this is the place to start.

Major Components

The Aggregator.Core assembly contains the logic to process a Work Item and run the aggregate scripts. It is normally used by Aggregator.ServerPlugin which intercept the TFS server side events and forward them to Aggregator.Core. Aggregator.ConsoleApp is a simple console app that helps users in developing and testing policies without installing the server plugin.

Source Code Organization

The project is available on GitHub. We use a simple master/develop/pull-request branching scheme. All the source is available in the TFS-Aggregator-2.sln Visual Studio 2015 solution. To produce the MSI, see [Local build/contrib/local-build).

Policy data

Aggregator parses the Policy file at start. The logic is contained in Aggregator.Core/Configuration; whose entry point is the Aggregator.Core.Configuration.TFSAggregatorSettings class. That class is also the root of the configuration data model: Aggregator code gets a reference to a TFSAggregatorSettings instance to configure.

You can populate this class from a different source like a database.

Object Model

Aggregator’s Object Model solves some objectives: 1. simplifying the scripts 2. decouple from TFS Object Model 3. Ease mocking i.e. testing

You find the OM interfaces in Aggregator.Core/Interfaces and the implementation for the TFS OM in Aggregator.Core/Facade.

See Scripting for an introduction.

Scripting

Aggregator.Core/Script contains the build and execute logic for all scripting engines. For C# and VB, the script code is compiled once and the produced assembly is reused until the plug-in restarts. The DotNetScriptEngine base class contains all the logic while CSharpScriptEngine and VBNetScriptEngine define how to sew the script’s code snippets toghether. Powershell support is experimental.

Logging

The Core is decoupled from the logging sub-system: interesting events are pushed via the Aggregator.Core.ILogEvents interface that each client must implement. This way the same event generate a message in the log file or on the console. Important messages create EventLog messages on the server but not on the console application.

To add a message you have to: 1. add a method to ILogEvents interface 2. implement the method in TextLogComposer class

Note that the calling site is invoking a method passing typed parameters. TextLogComposer implementation set the message level and compose the text properly formatting the parameters.

What’s next

Please read Local build, Debugging and Troubleshooting to get a complete picture.