Table of Contents

RDC00410: Default instance in its own class

Severity: Warning  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: SuspiciousPredeclaredInstanceAccessAnalyzer

The code of a class module names the default instance of its own class.

A class whose VB_PredeclaredId attribute is True has a default instance: a variable named after the class, which holds an object of it (MS-VBAL §5.2.4.1.2 Default Instance Variables Static Semantics). In the code of the class, the object that runs the code is Me. It is the default instance only when the code was called on the default instance. When a member that names the default instance is called on another object of the class, it reads or changes the default instance, not that object.

The finding is the name of the class, where the code names the default instance.

How it is raised

Situation Example Resolution
A member of a predeclared class names the class's default instance. Factory.Init in the class Factory Write Me.Init (or Init) for the object that runs the code. Keep the class name where the default instance is meant.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca