Home > Components, Providers > DXCore Components – CodeMetricProvider

DXCore Components – CodeMetricProvider

December 9th, 2010

The CodeMetricProvider component calculates and returns a code metric used in the Metrics tool window of Refactor! Pro and the Show Metrics CodeRush feature. See the “Show Metrics” post to learn more about software metrics.

You can drop the CodeMetricProvider onto your plug-in design surface from the “DXCore: Extensions & Providers” category of Visual Studio Toolbox:

DXCore CodeMetricProvider Toolbox item

It’s not a visual control, all you need is to tweak its properties and subscribe to its events. Here’s the Properties window, containing available properties, their categories and default values:

DXCore CodeMetricProvider properties

and the Events list:

DXCore CodeMetricProvider events

The CodeMetricProvider component is located in the “DevExpress.CodeRush.Extensions” assembly. It is derived from the “DevExpress.CodeRush.Core.ProviderBase” class:

DXCore CodeMetricProvider hierarchy

Here’s a list of properties in alphabetical order:

Property name

Description

CalculateOption Specifies one of the two options: AfterParse or UserInvoked, which indicates the time when the metric is being calculated – after solution parsing is done or manually by user request.
Description Text, describing the purpose or behavior of this plug-in extension. This text may appear inside the User Guide, configuration UI, or theAbout box.
DisplayName The text name that identifies this extension. This text may appear inside the User Guide, configuration UI, or the About box.
MetricGoal Specifies the value of three states: Default, Members or Types, indicating the objects for which the metric is being calculated.
ProviderName The name of this provider.
Register If true, this extension will be available to the DXCore. Otherwise, it will be hidden.
WarningValue A threshold value indicating an excessively complex member when measured by this metric. This value is used for graphing member metrics.

Events:

Event name Description
GetMetricComparer Handle this optional event to provide a comparer for the code metric provider. The comparer should contain implementation dependent operations for the code metric provider.
GetMetricValue Handle this event to calculate and return a code metric value for the given language element.
IsValidMetric Handle this optional event to specify if it is appropriate to calculate a code metric for the given language element.
LanguageSupported Handle this optional event if you want to restrict your code metric provider to one or more programming languages. If you do not handle this event, the DXCore makes your code metric provider available in all programming languages.

To learn how to build your own code metric using the CodeMetricProvider component, see the appropriate topic.

—–
Products: DXCore
Versions: 10.2 and up
VS IDEs: any
Updated: Dec/10/2010
ID: D044

Similar Posts:

  1. No comments yet. Be the first and leave a comment!