Open sandboxFocus

Class MetricProvider<T>

Base class for implementing custom metric providers. Derive from this class to create metrics that can measure code characteristics like complexity, coupling, or custom patterns.

Inheritance
MetricProvider<T>
Namespace: Metalama.Framework.Engine.Metrics
Assembly: Metalama.Framework.Sdk.dll
Syntax
public abstract class MetricProvider<T> : IMetricProvider<T>, IProjectService, IService where T : struct, IMetric
Type Parameters
Name Description
T

The metric type, which must be a struct implementing IMetric.

Remarks

To create a custom metric:

  1. Create a metric struct implementing IMetric<T> for each declaration type it supports.
  2. Create a metric provider class deriving from MetricProvider<T> (or SyntaxMetricProvider<T> for syntax-based metrics).
  3. Annotate the provider class with MetalamaPlugInAttribute.

Override the following methods:

For syntax-based metrics that analyze syntax trees, use SyntaxMetricProvider<T> instead.

Constructors

Name Description
MetricProvider()

Methods

Name Description
Aggregate(ref T, in T)

Aggregates a new value into an aggregate value.

ComputeMetricForMember(IMember)

Computes the metric for a member.

ComputeMetricForType(INamedType)

Computes the metric for a whole type.

GetMetric(IMeasurable)

Gets the metric for a measurable code element.

Extension Methods

See Also