docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AnalysisContext

    Base class for a context object passed by a Module to an Analyzer's Analyze() method.

    Inheritance
    object
    AnalysisContext
    AssetAnalysisContext
    AudioClipAnalysisContext
    InstructionAnalysisContext
    MeshAnalysisContext
    PackageAnalysisContext
    SettingsAnalysisContext
    ShaderAnalysisContext
    SpriteAtlasAnalysisContext
    TextureAnalysisContext
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.ProjectAuditor.Editor.Core
    Assembly: Unity.ProjectAuditor.Editor.dll
    Syntax
    public class AnalysisContext
    Remarks

    AnalysisContext provides information to the Analyze() method which is used to decide which issues to report. It also provides helper methods to build Issues or Insights.

    Fields

    Params

    The AnalysisParams object that was passed to (or created by) the ProjectAuditor's Audit() method.

    Declaration
    public AnalysisParams Params
    Field Value
    Type Description
    AnalysisParams
    Remarks

    This contains information that can be useful during analysis: for example, the analysis target platform, or information to determine whether a particular Descriptor is applicable in the current analysis.

    Methods

    CreateInsight(IssueCategory, string)

    Create a ReportItemBuilder for an Insight: A ReportItem collected for informational purposes.

    Declaration
    public ReportItemBuilder CreateInsight(IssueCategory category, string description)
    Parameters
    Type Name Description
    IssueCategory category

    Issue category

    string description

    User-friendly description

    Returns
    Type Description
    ReportItemBuilder

    The ReportItemBuilder, constructed with the specified category and description string

    CreateIssue(IssueCategory, string, params object[])

    Create a ReportItemBuilder for an Issue: a potential problem in the project, with an actionable recommendation to resolve it.

    Declaration
    public ReportItemBuilder CreateIssue(IssueCategory category, string id, params object[] messageArgs)
    Parameters
    Type Name Description
    IssueCategory category

    Issue category

    string id

    Descriptor ID

    object[] messageArgs

    Arguments to be used in the message formatting

    Returns
    Type Description
    ReportItemBuilder

    The ReportItemBuilder, constructed with the specified category, descriptor ID and message arguments

    IsDescriptorEnabled(Descriptor)

    Checks whether a given Descriptor is enabled for the current analysis.

    Declaration
    public bool IsDescriptorEnabled(Descriptor descriptor)
    Parameters
    Type Name Description
    Descriptor descriptor

    The descriptor to check

    Returns
    Type Description
    bool

    True if the Descriptor is applicable to the current target platform and Unity version, and if it's either enabled by default or by a Rule specified in Params. Otherwise, returns false.

    Remarks

    The analysis for some Issues can take a long time to run, particularly in a large project. The Descriptors for such issues may declare IsEnabledByDefault to be false to stop them running when running Project Auditor interactively in the Editor. When running Project Auditor in a CI/CD environment it may be desirable to re-enable analysis for these Descriptors. WithAdditionalDiagnosticRules(List<Rule>) can be used to add temporary Rules to increase the Severity of a Descriptor to anything other than Severity.None in order to re-enable analysis in this context.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)