How unity-technologies/projectauditor works
Main Components
• Project Auditor Core – the central engine that coordinates analysis.
• Data & Configuration – the “Data” folder contains JSON files (e.g., ApiDatabase.json, ProjectSettings.json, RoslynTextLookup.json) which act as configuration and lookup data for the analysis.
• Editor Integration:
• API Layer – located under the Editor/API folder; exposes types like AnalysisParams, Rule, Report, etc., which are key to configuring and triggering audits.
• Code Analysis & Assembly Utilities – found under Editor/CodeAnalysis and Editor/AssemblyUtils; these components are responsible for collecting and processing metadata from code and assemblies.
• Modules – under Editor/Modules and Editor/SettingsAnalysis; these provide specialized analyzers for different domains (Animation, Assets, AudioClips, Code, Meshes, Shaders, Texture, etc.).
• UI – under Editor/UI; manages the presentation layer for audit reports and diagnostic information. The framework subfolder further contains components for views, charts, tables, and selection windows.
• Roslyn Analyzers – the “RoslynAnalyzers” directory indicates the integration with Roslyn for additional code diagnostics.
• Testing – the “Tests” directory supports unit and integration testing for nearly all major functionalities.
Relationships and Interactions
• The Unity Editor triggers Project Auditor (as it is a Unity package installed into the project) and loads the Project Auditor window.
• The UI layer interacts with the core API to request analyses and display results.
• The core modules (API, CodeAnalysis, AssemblyUtils, Modules, SettingsAnalysis) work together to process assets, code, settings, and build reports.
• Data and configuration files feed into the analysis routines by providing reference data and settings.
• Roslyn Analyzers complement the built-in analysis engines, adding code diagnostic capabilities.
• Test suites are set up to simulate these interactions and provide feedback to developers.
Architectural Patterns and Principles
• Modular design: The system is divided into highly focused modules (each in its own directory) handling specific aspects of the analysis. This promotes maintainability and extensibility.
• Separation of concerns: The API, Analysis, UI, and Data layers are distinctly separated. Each handles its own logic without excessive coupling.
• Extensibility: By exposing an API and definable module analyzers, the tool can be extended with additional analysis types or integrations.
• Dependency Management: The project uses Unity’s package distribution and integration conventions. The clear file/tree separation (Editor vs. Data vs. Tests) reflects this pattern.
Final Advice
• Break the Editor folder into sub-components that reflect logical groups (API, Analysis, UI).
• How these components interact in terms of both data flow and control flow. For instance, when a user triggers a scan in the ProjectAuditorWindow, it calls into the API, which then delegates work among various Analyzer Modules, each possibly consulting configuration data.