[#72] Add find-refs test coverage and fix its database/null-ref bugs#79
Merged
Conversation
Rename UnityFileSystemTestData and introduce a LeadingEdge project for testing Content Directory builds and other newer features that require Unity >=6.6. Add AGENTS.md explaining the relationship between these projects and the referenced files checked in to TestCommon
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the find-refs CLI command to work against current analyze-produced databases (issue #72 and a ScriptableObject null-read crash), adds --stdout output support, and introduces deterministic Unity build outputs plus NUnit coverage to prevent regressions.
Changes:
- Fix
find-refsdatabase opening and NULL handling in correlated subqueries; add--stdoutoutput mode and CLI validation. - Add comprehensive
find-refsregression/behavior tests (plus one newdumptest) using checked-in LeadingEdge AssetBundle build output. - Introduce/rename Unity reference projects (
Baseline,LeadingEdge) and check in corresponding reference build/test-data + documentation.
Reviewed changes
Copilot reviewed 74 out of 133 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| UnityProjects/LeadingEdge/CLAUDE.md | Points to the project’s agent guidance. |
| UnityProjects/LeadingEdge/Assets/Scripts/SerializationDemo.cs.meta | Unity metadata for SerializationDemo. |
| UnityProjects/LeadingEdge/Assets/Scripts/SerializationDemo.cs | New ScriptableObject used to exercise serialization for dump testing. |
| UnityProjects/LeadingEdge/Assets/Scripts/LoadableAudioClipReference.cs.meta | Unity metadata for LoadableAudioClipReference. |
| UnityProjects/LeadingEdge/Assets/Scripts/LoadableAudioClipReference.cs | ScriptableObject referencing AudioClips via serialized Dictionary<string, Loadable<AudioClip>>. |
| UnityProjects/LeadingEdge/Assets/Scripts/DirectScriptableObjectReference.cs.meta | Unity metadata for DirectScriptableObjectReference. |
| UnityProjects/LeadingEdge/Assets/Scripts/DirectScriptableObjectReference.cs | ScriptableObject referencing other ScriptableObjects via a serialized dictionary (root aggregation). |
| UnityProjects/LeadingEdge/Assets/Scripts/DirectAudioClipReference.cs.meta | Unity metadata for DirectAudioClipReference. |
| UnityProjects/LeadingEdge/Assets/Scripts/DirectAudioClipReference.cs | ScriptableObject referencing AudioClips directly via serialized dictionary. |
| UnityProjects/LeadingEdge/Assets/Scripts.meta | Unity folder metadata for Assets/Scripts. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SingleAudioClipLoadableReference.asset.meta | Unity metadata for a single-clip loadable reference asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SingleAudioClipLoadableReference.asset | Deterministic ScriptableObject asset referencing a.mp3 via Loadable. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SingleAudioClipDirectReference.asset.meta | Unity metadata for a single-clip direct reference asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SingleAudioClipDirectReference.asset | Deterministic ScriptableObject asset referencing a.mp3 directly. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SerializationDemo.asset.meta | Unity metadata for SerializationDemo.asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/SerializationDemo.asset | Deterministic serialization fixture asset for dump tests. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/LoadableAudioClipReference.asset.meta | Unity metadata for LoadableAudioClipReference.asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/LoadableAudioClipReference.asset | Deterministic multi-clip loadable reference asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/DirectAudioClipReference.asset.meta | Unity metadata for DirectAudioClipReference.asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/DirectAudioClipReference.asset | Deterministic multi-clip direct reference asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/ContentDirectoryRoot.asset.meta | Unity metadata for the Content Directory build root asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/ContentDirectoryRoot.asset | Root ScriptableObject asset for the Content Directory build scenario. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/AssetBundleRoot.asset.meta | Unity metadata for the AssetBundle build root asset. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects/AssetBundleRoot.asset | Root ScriptableObject asset for the AssetBundle build scenario. |
| UnityProjects/LeadingEdge/Assets/ScriptableObjects.meta | Unity folder metadata for Assets/ScriptableObjects. |
| UnityProjects/LeadingEdge/Assets/Scenes/SampleScene.unity.meta | Unity metadata for a sample scene. |
| UnityProjects/LeadingEdge/Assets/Scenes/SampleScene.unity | Minimal scene content for the LeadingEdge project. |
| UnityProjects/LeadingEdge/Assets/Scenes.meta | Unity folder metadata for Assets/Scenes. |
| UnityProjects/LeadingEdge/Assets/InputSystem_Actions.inputactions.meta | Unity metadata for input actions asset. |
| UnityProjects/LeadingEdge/Assets/Editor/GenerateAssets.cs.meta | Unity metadata for GenerateAssets editor script. |
| UnityProjects/LeadingEdge/Assets/Editor/GenerateAssets.cs | Editor script to generate deterministic ScriptableObject assets for test builds. |
| UnityProjects/LeadingEdge/Assets/Editor/BuildContentDirectory.cs.meta | Unity metadata for Content Directory build script. |
| UnityProjects/LeadingEdge/Assets/Editor/BuildContentDirectory.cs | Editor script to build and copy Content Directory output into checked-in test data. |
| UnityProjects/LeadingEdge/Assets/Editor/BuildAssetBundles.cs.meta | Unity metadata for AssetBundle build script. |
| UnityProjects/LeadingEdge/Assets/Editor/BuildAssetBundles.cs | Editor script to build and copy AssetBundles output into checked-in test data. |
| UnityProjects/LeadingEdge/Assets/Editor.meta | Unity folder metadata for Assets/Editor. |
| UnityProjects/LeadingEdge/Assets/Audio/a.mp3.meta | Unity metadata for a.mp3 test audio. |
| UnityProjects/LeadingEdge/Assets/Audio/6.mp3.meta | Unity metadata for 6.mp3 test audio. |
| UnityProjects/LeadingEdge/Assets/Audio.meta | Unity folder metadata for Assets/Audio. |
| UnityProjects/LeadingEdge/AGENTS.md | Documentation for updating LeadingEdge project and its generated outputs. |
| UnityProjects/Baseline/CLAUDE.md | Points to the Baseline project’s agent guidance. |
| UnityProjects/Baseline/Assets/SerializeReferencePolymorphismExample.cs.meta | Unity metadata for SerializeReference example component. |
| UnityProjects/Baseline/Assets/SerializeReferencePolymorphismExample.cs | SerializeReference polymorphism fixture script. |
| UnityProjects/Baseline/Assets/Scenes/SampleSceneSettings.lighting.meta | Unity metadata for Baseline lighting settings asset. |
| UnityProjects/Baseline/Assets/Scenes/SampleSceneSettings.lighting | Baseline lighting settings fixture. |
| UnityProjects/Baseline/Assets/Scenes/SampleScene.unity.meta | Unity metadata for Baseline sample scene. |
| UnityProjects/Baseline/Assets/Scenes/SampleScene.unity | Baseline sample scene fixture. |
| UnityProjects/Baseline/Assets/Scenes/OtherScene.unity.meta | Unity metadata for Baseline other scene. |
| UnityProjects/Baseline/Assets/Scenes/OtherScene.unity | Baseline other scene fixture (player build source). |
| UnityProjects/Baseline/Assets/Scenes.meta | Unity folder metadata for Baseline scenes. |
| UnityProjects/Baseline/Assets/Editor/TypeIdRegistryGenerator.cs.meta | Unity metadata for TypeId registry generator script. |
| UnityProjects/Baseline/Assets/Editor/TypeIdRegistryGenerator.cs | Editor script to regenerate UnityFileSystem/TypeIdRegistry.cs. |
| UnityProjects/Baseline/Assets/Editor/BuildAssetBundles.cs.meta | Unity metadata for Baseline build script. |
| UnityProjects/Baseline/Assets/Editor/BuildAssetBundles.cs | Baseline build scripts for AssetBundles and PlayerData generation. |
| UnityProjects/Baseline/Assets/Editor.meta | Unity folder metadata for Baseline editor scripts. |
| UnityProjects/Baseline/Assets/AssetBundleData/wood.jpg.meta | Unity metadata for texture fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Sting-Sword lowpoly.fbx.meta | Unity metadata for FBX fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Square_Soft_A_Cookie.tif.meta | Unity metadata for TIFF fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Robot_Basic.fbx.meta | Unity metadata for FBX fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Prefab.prefab.meta | Unity metadata for prefab fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Prefab.prefab | Prefab fixture content. |
| UnityProjects/Baseline/Assets/AssetBundleData/Material.mat.meta | Unity metadata for material fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Material.mat | Material fixture content. |
| UnityProjects/Baseline/Assets/AssetBundleData/LegacyAnimation.anim.meta | Unity metadata for legacy animation fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/LegacyAnimation.anim | Legacy animation clip fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/blip.wav.meta | Unity metadata for WAV fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/blip.wav | WAV audio fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/AnimatorControlle.controller.meta | Unity metadata for animator controller fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/AnimatorControlle.controller | Animator controller fixture content. |
| UnityProjects/Baseline/Assets/AssetBundleData/Animation.anim.meta | Unity metadata for animation fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData/Animation.anim | Animation clip fixture. |
| UnityProjects/Baseline/Assets/AssetBundleData.meta | Unity folder metadata for Baseline AssetBundleData. |
| UnityProjects/Baseline/Assets/AssetBundle2Data/Shader.shader.meta | Unity metadata for shader fixture. |
| UnityProjects/Baseline/Assets/AssetBundle2Data/Shader.shader | Shader fixture content. |
| UnityProjects/Baseline/Assets/AssetBundle2Data.meta | Unity folder metadata for Baseline AssetBundle2Data. |
| UnityProjects/Baseline/AGENTS.md | Documentation for Baseline project purpose and generation scripts. |
| UnityFileSystem/TypeIdRegistry.cs | Update generator path reference to new Baseline location. |
| UnityDataTool/Program.cs | Add --stdout for find-refs + mutual-exclusion validation; plumb flag into handler. |
| UnityDataTool.Tests/FindRefsTests.cs | New NUnit coverage for find-refs behavior and regressions (issue #72 + ScriptableObject NULL handling). |
| UnityDataTool.Tests/ExpectedDataGenerator.cs | Use shared DB open helper instead of invalid connection string keyword. |
| UnityDataTool.Tests/DumpTests.cs | Add test that dumps SerializationDemo from LeadingEdge AssetBundle output. |
| TestCommon/Data/PlayerData/CLAUDE.md | Points to agent guidance for PlayerData test data. |
| TestCommon/Data/PlayerData/AGENTS.md | Documentation for PlayerData test fixture generation. |
| TestCommon/Data/LeadingEdgeBuilds/ContentDirectory/BuildManifestHash.txt | Checked-in LeadingEdge Content Directory manifest hash. |
| TestCommon/Data/LeadingEdgeBuilds/ContentDirectory/15d5df98d98434e67e06716cfabfad1b.json | Checked-in LeadingEdge Content Directory build manifest JSON. |
| TestCommon/Data/LeadingEdgeBuilds/CLAUDE.md | Points to agent guidance for LeadingEdge builds. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/ScriptsOnlyCache.yaml | Checked-in Content Directory build report artifact. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/ContentSizeSummary.txt | Checked-in Content Directory build report summary. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/ContentLayout.json | Checked-in Content Directory content layout for analysis/testing. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/BuildReportSummary.json | Checked-in Content Directory build report summary JSON. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/BuildLog.jsonl | Checked-in Content Directory build log. |
| TestCommon/Data/LeadingEdgeBuilds/BuildReport-ContentDirectory/BuildContentTEP.json | Checked-in tracing artifact for Content Directory build. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/singleaudioclipdirectreference.manifest | Checked-in AssetBundle manifest for deterministic test inputs. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/serializationdemo.manifest | Checked-in AssetBundle manifest for serialization fixture. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/directaudioclipreference.manifest | Checked-in AssetBundle manifest for AudioClip reference fixture. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/AssetBundles.manifest | Checked-in overall AssetBundles manifest. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/assetbundleroot.manifest | Checked-in AssetBundle manifest for root aggregation fixture. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/a.manifest | Checked-in AssetBundle manifest for a.mp3. |
| TestCommon/Data/LeadingEdgeBuilds/AssetBundles/6.manifest | Checked-in AssetBundle manifest for 6.mp3. |
| TestCommon/Data/LeadingEdgeBuilds/AGENTS.md | Documentation for the LeadingEdge checked-in build outputs and layout. |
| TestCommon/Data/AssetBundles/CLAUDE.md | Points to agent guidance for AssetBundle test data. |
| TestCommon/Data/AssetBundles/AGENTS.md | Documentation for AssetBundle test fixture generation. |
| ReferenceFinder/ReferenceFinderTool.cs | Fix connection string construction; add --stdout support; null-check correlated-subquery reads. |
| README.md | Update repository overview to reflect new UnityProjects folder. |
| Documentation/command-find-refs.md | Document traversal behavior and new --stdout option. |
| CLAUDE.md | Point to root AGENTS.md. |
| AGENTS.md | Update repo-wide agent guidance to document Baseline/LeadingEdge Unity projects. |
| .gitignore | Update ignores to cover new UnityProjects layout and generated folders. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+52
to
+59
| try | ||
| { | ||
| Directory.Delete(m_WorkFolder, true); | ||
| } | ||
| catch (IOException) | ||
| { | ||
| // Best effort cleanup; leftover files in the test output folder are harmless. | ||
| } |
…rage find-refs had no automated tests and two bugs that broke it against any current analyze database: - Issue #72: the database was opened with a hand-written connection string using the legacy System.Data.SQLite "Version=3" keyword, which Microsoft.Data.Sqlite rejects. Build the connection string with SqliteConnectionStringBuilder instead (matching SQLiteWriter). Fixed the same broken string in ExpectedDataGenerator. - A ScriptableObject is a MonoBehaviour whose m_GameObject PPtr is 0, so its game_object column is a non-null id matching no row; the game_object/script subqueries then return NULL and GetString threw. Null-check those reads. Also add a --stdout option to find-refs (mutually exclusive with -o), mirroring dump, and update command-find-refs.md. Add FindRefsTests covering both bugs, name/type lookup and disambiguation, object-id lookup, --find-all, missing objects, empty refs table, the --stdout/-o validator, and direct refs-table queries. Tests run against the LeadingEdge AssetBundle reference build.
7c7bdf0 to
e3046f7
Compare
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
This branch introduces a second Unity reference project used to generate deterministic test data, adds the first tests that run against that build output, and fixes the broken
find-refscommand (the original motivation, issue #72) while adding thorough test coverage for it.Changes
Fix
find-refs(issue #72 + a second bug)find-refshad no automated tests and two bugs that broke it against any database produced by the currentanalyze:System.Data.SQLiteVersion=3keyword, whichMicrosoft.Data.Sqliterejects (Connection string keyword 'version' is not supported). It is now built withSqliteConnectionStringBuilder, matchingSQLiteWriter. The same broken string inExpectedDataGeneratorwas fixed too.m_GameObjectPPtr is0, so itsgame_objectcolumn holds a non-null id that matches no row; thegame_object/scriptcorrelated subqueries then returnNULLandGetStringthrewInvalidOperationException. Those reads are now null-checked. This brokefind-refsfor essentially any ScriptableObject reference chain.--stdoutforfind-refsAdded a
--stdoutoption (mutually exclusive with-o/--output-file), mirroringdump, so chains can be written to the console.command-find-refs.mddocuments the new option and clarifies the traversal behavior:find-refswalks up the reference graph and stops at the first asset it reaches, so chains end at the immediate containing asset rather than the ultimate root.New
find-refstestsUnityDataTool.Tests/FindRefsTests.csrunsanalyzeon the LeadingEdge AssetBundle build in setup and covers:[Script = ...]without crashing (regression for the second bug).AssetBundleRootfrom a leaf asset, and confirming a target search stops at the leaf asset (documents the stop-at-first-asset traversal).--find-all(produces identical chains to the default for this data), non-existent object, empty refs table (--skip-references), and the--stdout/-ovalidator.refs/object_viewqueries validating the underlying reference counts.Second reference Unity project (
LeadingEdge) and reference build dataBaseline(stable LTS versions) and addedLeadingEdge, which tracks the newest Unity version so newer build features (Content Directory builds, serializedDictionary<,>, Loadable`) can be tested. Editor scripts generate ScriptableObjects with well-known relationships between assets and AudioClips and run both AssetBundle and Content Directory builds.TestCommon/Data/LeadingEdgeBuilds(AssetBundles, Content Directory, and build reports), used by the new tests.AGENTS.md/CLAUDE.mddocumentation for the projects and test-data folders.First test using the new build output (
dump)DumpTestsgained a test that dumps theSerializationDemoScriptableObject from the LeadingEdge AssetBundle build and confirms the serialized field layout and values across the core numeric types, the string, the[SerializeReference]managed reference, and the int array.Testing
dotnet test UnityDataTool.Tests— 231 passing, 0 failing.