Documentation

Unity Engine

Download Unity

Unity Engine

Code view reference

Displays issues related to the code in your project.
Read time 6 minutesLast updated 8 days ago

The Code view displays issues related to the C# code in your project. This view is divided into the following pages:

Known limitations

There are several known limitations in Project Auditor's code analysis:
  • It reports issues in code that might be stripped by the build process.
  • It can't distinguish between different versions of an API method with different parameters/return types: for example, it can't differentiate between the following, so it reports both:
    • public Component[] GetComponentsInChildren(Type type, bool includeInactive = false);
      (which allocates managed memory)
    • public void GetComponentsInChildren(List<T> results);
      (which doesn't allocate memory)
  • It can't distinguish between "hot" and "cold" code paths, except by checking if a method is in (or is a called by) one of the standard
    MonoBehaviour (Fixed/Late)Update
    methods, or
    SystemBase/ISystem.OnUpdate
    , or a coroutine.
  • The call tree analysis doesn't support virtual methods.

Code view

The Code Issues view reports all C# script-related issues. For each issue, this view also provides an explanation of the problem and a recommended course of action to resolve the issue.

Filters

Use the filters to filter the list of issues to areas you're interested in. For more information, refer to Filter controls.
Enable the Only Major/Critical setting to display only code issues with Major or Critical severity.
Enable the Only Performance Critical setting to display only code issues that have an inverted call hierarchy that includes an update method. For example coroutine methods, or built-in methods such as
MonoBehaviour.Update()
,
MonoBehaviour.FixedUpdate()
,
SystemBase.OnUpdate()
,
ISystem.OnUpdate()
, among others.
This allows you to focus on issues that are more likely to happen in code paths that are called every frame. Code in these paths is more likely to have an impact on runtime performance or memory management than code which runs only during initialization.

Table

The table of issues has the following columns. Use the table controls to configure how to organize and display the data.

Property

Description

IssueSummary of the issue. Right-click on the issue to open its relevant code file, or open the documentation where possible.
IDThe ID of the rule that reported the issue. Use this ID to suppress the issue type in the Project settings.
SeverityAn estimate of the severity of the issue. Severity can be Critical, Major, Moderate, or Minor. All issues found in code paths that are called every frame are automatically marked as Major.
AreasThe areas that this issue affects, such as CPU, Memory, or Iteration Time.
LocationThe type of code that contains the issue: Player, Editor, Package, Tests, or a combination of these.
FilenameThe name of the file that this issue occurred in, along with the line number. Double-click the issue to open it in your IDE.
AssemblyThe name of the assembly the code file is a part of.
DescriptorCategorizes the issue with this code.
IgnoredDisplays True if the issue is ignored. To ignore an issue, choose it in the list and then select Ignore Issue in the Details panel to the right. To display ignored issues, select Show Ignored Issues in the Filters panel.

Details panel

When you select an issue, the Details panel to the right displays a summary of why the selected item is an issue, and a recommendation of steps to take to resolve the issue. If the item isn't an issue for your project, select Ignore Issue to exclude it, or Suppress Issue Type to exclude all issues of this type from future reports. For more information, refer to Issue actions.

Inverted Call Hierarchy

The Inverted Call Hierarchy panel displays an inverted call hierarchy for the selected issue in the table. Expand the tree to display all the methods that lead to the call site of the reported issue. The panel only displays an inverted call hierarchy if code analysis was performed during this Editor session. Call hierarchies aren't saved in reports.

Assemblies view

Reports a list of all compiled assemblies. This includes all assemblies generated by code in the Assets folder and in packages.

Table

The table of issues has the following columns. Use the table controls to configure how to organize and display the data.

Property

Description

Log LevelThe log level of the message (Error/Warning/Info).
NameThe name of the assembly.
StatusDisplays whether the assembly failed to compile, or wasn't compiled because an assembly it depends on failed to compile. Empty if the assembly compiled successfully.
Read OnlyDisplays whether the source files of an assembly can be modified in the project. Packages installed from a registry or from a repository are typically Read Only.
Asmdef PathThe full path to the assembly definition file for this assembly.
LocationThe type of code in the assembly: Player, Editor, Package, Tests, or a combination of these.

Dependencies panel

The Dependencies panel displays a list of any dependencies that the assembly has.

Precompiled Assemblies

Displays a list of the precompiled assemblies in your project.

Property

Description

NameThe name of the assembly.
PathThe path to the precompiled assembly.
Roslyn AnalyzerDisplays a tick if the assembly is a Roslyn analyzer.
Target FrameworkThe .NET framework that the assembly targets. Assemblies that target a framework that the current scripting runtime doesn't support might fail to load.

Compiler Messages

Displays the compiler error, warning, and info messages. The C# compiler generates these messages when compiling the project scripts for the target platform.
To display messages from your own Roslyn analyzers in this view, you must have one or more Roslyn analyzer DLL files in your project, tagged with the
RoslynAnalyzer
label. To add a label, select the DLL file, and add the
RoslynAnalyzer
Asset Label. For more information, refer to Code analysis and source generation.

Table

The table of issues has the following columns. Use the table controls to configure how to organize and display the data.

Property

Description

Log LevelThe log level of the compiler message (Error/Warning/Info).
IDThe error/warning code reported by the compiler.
MessageThe error/warning message string reported by the compiler. Select an item in the table to display the full message in the panel to the right.
FilenameThe name of the file that this issue occurred in, along with the line number. Double-click the issue to open it in your IDE.
AssemblyThe assembly which contains the file that generated the message. The default assembly for user code in a Unity project is called Assembly-CSharp.
LocationThe type of code that generated the message: Player, Editor, Package, Tests, or a combination of these.
Full PathThe full path to the code file that generated the message.

Obsolete API

Displays the obsolete Unity API in all Unity versions. This list is a reference, and doesn't depend on whether your project uses the API. To find the obsolete API that your project uses, run an Upgrade analysis. For more information, refer to Identify obsolete API between Unity versions.
Select an item in the table to display its details and the recommended replacement in the panel to the right.

Property

Description

IssueThe obsolete API.
UpgradableDisplays a tick if the API Updater can automatically upgrade code that uses this API.
ObsoleteThe Unity version in which the API became obsolete.
RemovedThe Unity version in which the API was removed.

Additional resources