[#99] Import ContentLayout.json into the analyze database#101
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support in the Analyzer pipeline for importing Unity ContentDirectory ContentLayout.json into the analyze SQLite database, so ContentDirectory layouts become queryable via dedicated content_layout* tables and convenience views (foundation for later reference resolution work in #99 follow-up).
Changes:
- Introduces a new
ContentLayoutParser(ISQLiteFileParser) +ContentLayoutSQLWriterto importContentLayout.jsoninto newcontent_layout*tables/views (created lazily only when a layout is imported). - Adds SQL resources (tables, views, indexes) and command classes to populate the schema efficiently (single transaction + indexes created after inserts).
- Adds tests covering layout-only imports, on-demand schema creation, unsupported versions, and the “single layout per DB” guard; updates analyzer schema documentation.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| UnityDataTool.Tests/AnalyzeContentLayoutTests.cs | Adds integration tests validating layout-only import behavior and schema/view expectations. |
| Documentation/analyzer.md | Documents the new content_layout* tables and convenience views in the analyzer schema reference. |
| Analyzer/SQLite/Writers/ContentLayoutSQLWriter.cs | Implements transactional population of the ContentLayout schema and deferred index creation. |
| Analyzer/SQLite/Parsers/ContentLayoutParser.cs | Adds file detection for ContentLayout.json, version/uniqueness checks, and import orchestration. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayout.cs | Adds insert command + DDL hook for the content_layout identity table. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutSerializedFile.cs | Adds insert command + DDL hook for content_layout_serialized_files. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutSourceAsset.cs | Adds insert command + DDL hook for content_layout_source_assets. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutSerializedFileDependency.cs | Adds insert command + DDL hook for content_layout_serialized_file_dependencies. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutLoadableDependency.cs | Adds insert command + DDL hook for content_layout_loadable_dependencies. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutLoadableSceneDependency.cs | Adds insert command + DDL hook for content_layout_loadable_scene_dependencies. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutLoadableObject.cs | Adds insert command + DDL hook for content_layout_loadable_objects. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutLoadableScene.cs | Adds insert command + DDL hook for content_layout_loadable_scenes. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutBinaryArtifact.cs | Adds insert command + DDL hook for content_layout_binary_artifacts. |
| Analyzer/SQLite/Commands/ContentLayout/AddContentLayoutArtifactReference.cs | Adds insert command + DDL hook for content_layout_artifact_references. |
| Analyzer/Resources/ContentLayout.sql | Defines the content_layout identity table DDL. |
| Analyzer/Resources/ContentLayoutSerializedFiles.sql | Defines the serialized-files table DDL keyed by layout file_index. |
| Analyzer/Resources/ContentLayoutSourceAssets.sql | Defines the source-assets table DDL. |
| Analyzer/Resources/ContentLayoutSerializedFileDependencies.sql | Defines the serialized-file dependency edges DDL with order-preserving position. |
| Analyzer/Resources/ContentLayoutLoadableDependencies.sql | Defines the loadable-object dependency table DDL. |
| Analyzer/Resources/ContentLayoutLoadableSceneDependencies.sql | Defines the loadable-scene dependency table DDL. |
| Analyzer/Resources/ContentLayoutLoadableObjects.sql | Defines the loadable-objects table DDL including is_root_asset and dropped-file sentinel mapping. |
| Analyzer/Resources/ContentLayoutLoadableScenes.sql | Defines the loadable-scenes table DDL. |
| Analyzer/Resources/ContentLayoutBinaryArtifacts.sql | Defines the binary-artifacts table DDL for artifact sizes/categories/hashes. |
| Analyzer/Resources/ContentLayoutArtifactReferences.sql | Defines the artifact reference-edges table DDL. |
| Analyzer/Resources/ContentLayoutViews.sql | Defines convenience views joining layout tables and core analyzer tables. |
| Analyzer/Resources/ContentLayoutIndexes.sql | Defines post-import indexes for query performance on large layouts. |
| Analyzer/Properties/Resources.resx | Registers the new SQL resource files for embedding. |
| Analyzer/Properties/Resources.Designer.cs | Adds generated accessors for the new embedded SQL resources. |
| Analyzer/AnalyzerTool.cs | Registers ContentLayoutParser in the parser list so it’s recognized during analyze runs. |
Files not reviewed (1)
- Analyzer/Properties/Resources.Designer.cs: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SkowronskiAndrew
marked this pull request as ready for review
July 16, 2026 19:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #99 (first of two PRs; a follow-up adds reference resolution and input validation).
ContentDirectory builds name every output file by content hash, so an analyze database built from them can't be traced back to source assets.
ContentLayout.json(written byBuildPipeline.BuildContentDirectoryinto the build report directory) carries that mapping — source assets, file-to-file dependencies, loadables, and artifact sizes. This PR imports it into the analyze database as a set ofcontent_layout*tables and views, making the layout queryable with SQL. This is useful on its own for large layouts, and it is also the foundation the follow-up PR builds on to resolve references between Content Files.Changes
Analyzer
ContentLayoutParser(ISQLiteFileParser), detected by the exact filenameContentLayout.json(Unity always writes that name, so no content sniffing is needed). Unsupported schema versions fail with a clear error, and only a single layout per database is accepted.ContentLayoutSQLWriter+ command classes + SQL resources, following the Addressables build layout import pattern: tables and views are created lazily on the first import, so analyzing AssetBundles or Player builds doesn't add empty tables; population runs in one transaction, with indexes created afterwards for large-layout performance.content_layout_serialized_files,_source_assets,_serialized_file_dependencieswith an order-preservingpositioncolumn,_loadable_objects,_loadable_scenes,_binary_artifacts,_artifact_references, …), with two adjustments for natural querying: json sentinels (-1, missing content hash) become SQLNULL, and the top-levelRootAssetslist is folded into anis_root_assetflag.content_layout_source_assets_view(source asset → built files) andcontent_layout_data_files_view(the.resS/.resourcedata files each serialized file uses).content_layout_serialized_files.serialized_filelinks to the coreserialized_filestable; it stays NULL in this PR and is populated by the follow-up PR when the build content is analyzed together with the layout.Documentation
analyzer.md: schema reference for the new tables and views.Testing
dotnet test— full suite green (734 passed).AnalyzeContentLayoutTestscovers a layout-only analyze of the LeadingEdge ContentDirectory reference build: header row, per-table row counts, spot checks (built-in entry, dependency ordering, root-asset flag, derived filenames), view joins, the on-demand table creation (nocontent_layouttables when analyzing AssetBundles), the unsupported-version error, and the single-layout guard.ContentLayout.json.🤖 Generated with Claude Code