Skip to content

[#55] Show type name in build_report_packed_asset_contents_view#90

Merged
SkowronskiAndrew merged 2 commits into
mainfrom
issue55-use-buildreport-packedasset-typestring
Jul 9, 2026
Merged

[#55] Show type name in build_report_packed_asset_contents_view#90
SkowronskiAndrew merged 2 commits into
mainfrom
issue55-use-buildreport-packedasset-typestring

Conversation

@SkowronskiAndrew

Copy link
Copy Markdown
Collaborator

Summary

Fixes #55.

BuildReport files record each packed asset's type by numeric Class ID only, which is compact but not human-friendly when browsing build_report_packed_asset_contents_view. Previously the view exposed the raw integer.

The analyze schema already has a types table mapping ids to names, and UnityFileSystem/TypeIdRegistry.cs now provides a comprehensive id→name list. This change populates the types table from the registry during BuildReport import and updates the view to show the type name — so names are available even when the associated build output (and its TypeTrees) is not analyzed alongside the report. This ships as part of the v2.0 analyze-schema changes.

Changes

  • PackedAssetsHandler: For each packed asset content, when the numeric type id maps to a known name in TypeIdRegistry, insert it into the shared types table (INSERT OR IGNORE, so an authoritative TypeTree-derived name already present wins). The build_report_packed_asset_info.type column still stores the numeric id.
  • build_report_packed_asset_contents_view: type now shows the type name via COALESCE(types.name, CAST(type AS TEXT)) — the name when known, the numeric id as text otherwise.
  • TypeIdRegistry: added TryGetTypeName so callers can tell whether a real name exists (unlike GetTypeName, which falls back to the id).
  • AbstractCommand / AddType: added a ConflictClause seam and set the types insert to INSERT OR IGNORE. This prevents a UNIQUE-constraint crash when a report and its build output are analyzed together — the writer's in-memory type-set doesn't know about ids the handler inserted. Names for known ids are identical between the registry and TypeTrees, so this is lossless.
  • Schema version: bumped PRAGMA user_version to 4 and reframed its comment as a general schema tracker (find-refs is just the only command that reads an existing DB and checks it). find-refs' minimum required version is unchanged.
  • Docs: updated Documentation/buildreport.md (type-names limitation and column-naming notes).

Testing

  • dotnet test — full suite green (Analyzer.Tests 62, UnityFileSystem.Tests 425, UnityDataTool.Tests 238).
  • Updated Analyze_BuildReport_AssetBundle_ContainsPackedAssetsData to assert type = 'Texture2D' and added an assertion on the returned type name.
  • Manual: ran analyze on the sample AssetBundle.buildreport; the view now reports string types (Texture2D, AssetBundle, Sprite, Material, Shader, …).

Populate the types table from TypeIdRegistry when importing a BuildReport
so the packed asset contents view can display human-readable type names
instead of numeric class ids, even when the build output is not analyzed
alongside the report.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Analyzer’s BuildReport import and SQL views so packed-asset type IDs can be displayed as human-readable Unity type names (via types), even when no accompanying build output / TypeTrees are analyzed.

Changes:

  • Populate types during BuildReport PackedAssets import using TypeIdRegistry when available.
  • Update build_report_packed_asset_contents_view to show a type name (fallback to numeric ID as text).
  • Add TryGetTypeName to TypeIdRegistry and bump schema user_version to 4; adjust tests/docs accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
UnityFileSystem/TypeIdRegistry.cs Adds TryGetTypeName for “known vs unknown” type-name lookup.
Analyzer/SQLite/Handlers/PackedAssetsHandler.cs Inserts type-name mappings into types during BuildReport packed-asset import.
Analyzer/SQLite/Commands/AbstractCommand.cs Adds an INSERT conflict-clause seam for command generation.
Analyzer/SQLite/Commands/SerializedFile/AddType.cs Applies conflict handling to types inserts to avoid duplicate-key crashes.
Analyzer/Resources/PackedAssets.sql Updates the packed-asset contents view to expose type names via types.
Analyzer/Resources/Init.sql Bumps schema version to 4 and updates schema-version commentary.
UnityDataTool.Tests/BuildReportTests.cs Updates assertions to expect string type names in the view.
Documentation/buildreport.md Updates docs to reflect numeric storage + view-level type-name display and other notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Analyzer/SQLite/Commands/SerializedFile/AddType.cs
Comment thread Analyzer/SQLite/Handlers/PackedAssetsHandler.cs
Comment thread Documentation/buildreport.md Outdated
**Duplicate filenames:** Multiple build reports cannot be imported into the same database if they share the same filename. This is a general UnityDataTool limitation that assumes unique SerializedFile names.

**Type names:** While `build_report_packed_asset_info.type` records valid [Class IDs](https://docs.unity3d.com/Manual/ClassIDReference.html), the string type name may not exist in the `types` table. The `types` table is only populated when processing object instances (during TypeTree analysis). Analyzing both build output **and** build report together ensures types are fully populated; otherwise only numeric IDs are available.
**Duplicate filenames:** Multiple build reports cannot be imported into the same database if they share the same filename. This is a general UnityDataTool limitation that assumes unique SerializedFile names. The BuildReport files in the build history (introduced in Unity 6.6) intentionally have unique file names (incorporating the build session GUID), so analyze does not hit this issue when analyzing multiple entries from the BuildHistory folder. When analyzing multiple AssetBundle build reports, or build reports from older versions of unity, be sure to assign a unique filename to each. See also issue #36.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed capitalization (unity -> Unity) and normalized the double-spaces in 8ad05d2.

- PackedAssetsHandler: skip redundant type inserts via a HashSet (a report
  can list thousands of objects sharing a few types).
- AddType: reword the OR IGNORE comment - first insert wins is fine since the
  name for a given id matches across TypeIdRegistry and TypeTree; the case that
  matters (id missing from the registry) still gets its name from TypeTree.
- buildreport.md: capitalization and spacing.
@SkowronskiAndrew

Copy link
Copy Markdown
Collaborator Author

This is example of the change with a player build:

image

@SkowronskiAndrew SkowronskiAndrew merged commit 1968f55 into main Jul 9, 2026
5 checks passed
@SkowronskiAndrew SkowronskiAndrew deleted the issue55-use-buildreport-packedasset-typestring branch July 9, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Populate Type table during BuildReport import

2 participants