Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Code view reference

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

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

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 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.
SeverityAn estimate of the severity of the issue. Severity can be Major, Moderate, Minor, or Ignored. All issues found in code paths that are called every frame are automatically marked as Major.
AreasThe area of performance that this issue affects. Area can be CPU, Memory, or both.
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.

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).
Assembly NameThe name of the assembly.
Compile TimeThe time in ms it took to compile the assembly in preparation for code analysis when generating the report.
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.

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

Assembly NameThe name of the assembly.
Roslyn AnalyzerThe related Roslyn analyzer, if any.
PathThe path to the precompiled assembly.

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.
Important
To populate this view with data, you must enable the Use Roslyn Analyzers setting in the Preferences window. Additionally, 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 Roslyn analyzers and source generators.

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).
CodeThe 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.
Target AssemblyThe assembly which contains the file that generated the message. The default assembly for user code in a Unity project is called Assembly-CSharp.
Full PathThe full path to the code file that generated the message.

Domain Reload view

Displays the results of a Roslyn analyzer that detects code issues that result in unexpected or non-deterministic behavior if domain reload on entering Play mode is disabled in your project (as it is by default). Domain reloading can impact project iteration times (in particular, the time it takes to enter and exit Play mode), so it's best practice to fix all the issues displayed in this view and then keep domain reload off. For more information, refer to Domain reloading.
Important
To populate this view with data, you must enable the Use Roslyn Analyzers setting in the Preferences window.

Table

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

Property

Description

CodeThe error/warning code reported by the compiler.
IssueThe 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.
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.

Additional resources