See also: Complete list of dead code rules.
Live | In use. Keep. |
Dead | Not in use. Remove. |
Dead but exposed | Unknown. Can possibly remove. |
Project | Can expose? |
---|---|
DLL | Yes |
OCX | Yes |
Standard EXE | No (VB 3-6, VB 2002-2003) Yes (VB 2005-) |
ActiveX EXE | Yes |
Being exposed is subject to the project type and scope declarations. In classic VB, the Instancing property of a class defines its scope. In VB.NET, the keywords Private, Protected, Friend and Public are used to control the scope. The below table shows which scopes can be exposed.
Scope | Exposed? |
---|---|
Public | Yes |
Friend | No (VB 3-6, VB 2002-2005) No (VB2008- default) Yes or no (VB2008- with <InternalsVisibleTo>) |
Protected | Yes (default) No (in a NotInheritable Class) |
Protected Friend | Yes if either Friend or Protected is exposed. No if not. |
Private | No |
The <InternalsVisibleTo> attribute, added to VB2008, allows external projects to call Friend members, even when Friend is normally limited to in-project use only. If <InternalsVisibleTo> is found, Project Analyzer treats Friend as exposed code when the external projects are not analyzed (and calls are unknown). If <InternalsVisibleTo> is found and all the referenced projects are analyzed, Project Analyzer treats Friend as not exposed (all calls are known).
In addition, a VBA procedure may be exposed to the host application or other documents.
Your is dead but exposed. What should you do about it?
By default, Project Analyzer hides dead code problems for exposed code. You can enable them in Problem options. Use this option in a multi-project analysis.
The firing of (most) events cannot be determined by reading the source code. Thus, events are not always included in the control flow. As an example, the showing a form is not included in a control flow.
Data flow is a run-time event. Therefore, the use of a constant value is not data flow. Project Analyzer defines a data flow as a possible data flow. At run-time the flow may not exist because
When it cannot be detected whether a parameter value is read or written in a procedure for which the source code is not available, it is assumed both read and written.
The direction of a file dependency is user file → required file. The direction may be different from the direction of control or data flow.
Procedure. The blue ball denotes that the code has a wider scope than Private. It may be Protected, Friend, Protected Friend or Public. If there is no blue ball, it is Private. | |
Dead procedure. The red line means that the code is dead. | |
Procedure may execute by external call. The violet × means the procedure has not been found to execute, but it may execute as a result of a call by another, unanalyzed project. The deadness status is thus unknown. |
You can find all the icons described inside Project Analyzer itself. See Legend in the Help menu.