scitools.com

← Metric catalog

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.

Properties

API ID: CountDeclProperty
Languages: C#, Pascal
Targets: Architectures, Classes, Project

Number of properties.

Counts every property regardless of how its accessors are implemented — both auto-implemented properties and ones with an explicit backing field and accessor bodies.

For example:


namespace MetricsDemo
{
    public class PropertyDemo
    {
        public int X { get; set; }

        private int y;
        public int Y
        {
            get { return y; }
            set { y = value; }
        }
    }
}

Both X (auto-implemented) and Y (explicit backing field y, with hand-written get/set bodies) count, giving CountDeclProperty = 2.

See Auto-Implemented Properties for just the auto-implemented subset. Properties aren't C#-only — Object Pascal's property Name: Type read Getter write Setter; syntax counts here too.

Targets By Language: Configuration: