Auto-Implemented Properties is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Auto-Implemented Properties
API ID: CountDeclPropertyAutoLanguages: C#
Targets: Architectures, Classes, Project
Number of auto-implemented properties.
An auto-implemented property (C#'s { get; set; } shorthand) has its backing field generated automatically by the compiler, rather than declared and managed explicitly.
For example:
namespace MetricsDemo
{
public class PropertyDemo
{
public int X { get; set; }
private int y;
public int Y
{
get { return y; }
set { y = value; }
}
}
}
X is auto-implemented, giving CountDeclPropertyAuto = 1. Y has an explicit backing field (y) and hand-written accessor bodies, so it doesn't count here even though it's still a property.
See Properties for the total including explicitly-implemented properties like Y.
- C#: Project, Class, Struct
- For projects and architectures, this metric must also be enabled from "Project Configuration/Metrics/Projects and Architectures" with the "Show aggregated class metrics" option. Enabling this option can be time consuming.
- This metric can be disabled from "Project Configuration/Metrics/Object Orientated" with the "Show method and variable count metrics" option.