Protected Internal Instance Variables 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.
Protected Internal Instance Variables
API ID: CountDeclInstanceVariableProtectedInternalLanguages: C#
Targets: Architectures, Classes, Project
Number of protected internal instance variables.
A protected internal instance variable (C#'s protected internal access modifier) is accessible from anywhere in the same assembly, or from derived classes in other assemblies.
For example:
namespace MetricsDemo
{
public class AccessModifiers
{
internal int InternalField;
protected internal int ProtectedInternalField;
internal void InternalMethod()
{
InternalField++;
}
protected internal void ProtectedInternalMethod()
{
ProtectedInternalField++;
}
}
}
ProtectedInternalField is the only protected internal instance variable, giving CountDeclInstanceVariableProtectedInternal = 1. InternalField is plain internal — a narrower access level (same assembly only, no exception for derived classes elsewhere) — so it doesn't count here.
See Instance Variables for the total across all access levels, and Internal Instance Variables for the related access level. Public Instance Variables, Protected Instance Variables, and Private Instance Variables cover the access levels shared with C++ and Java.
Targets By Language:- 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.