Open sandboxFocus

Method AddMetrics

AddMetrics(ServiceProviderBuilder<IProjectService>)

Registers the standard metric providers (IMetricProvider<T> for SyntaxNodesCount, StatementsCount, and LinesOfCode) with the service builder.

Declaration
public static void AddMetrics(this ServiceProviderBuilder<IProjectService> builder)
Parameters
Type Name Description
ServiceProviderBuilder<IProjectService> builder

The service builder to register the metric providers with.

Remarks

Call this method to enable consumption of the standard metrics from the Workspaces API. For example:

WorkspaceCollection.Default.ServiceBuilder.AddMetrics();
var workspace = await WorkspaceCollection.Default.LoadAsync("MyProject.csproj");
var count = method.Metrics().Get<SyntaxNodesCount>();
See Also