Match SerializedFile names case-sensitively#106
Merged
Conversation
The serialized-file id provider keyed names by their lowercased form, so cross-file reference resolution, scene-bundle keying and ContentLayout linkage were all case-insensitive. Record and match names using the case found on the file system / inside the archive instead: drop the ToLowerInvariant() at every serialized-file name key site (a file's own name, external reference paths, scene .sharedAssets names, m_SceneHashes scene files, and ContentLayout .cf hashes). This also makes dangling-ref stub names preserve the referenced case rather than lowercasing them. No schema change (serialized_files.name already stored the actual relative path). Full test suite green, confirming the test data has no case mismatch between references and the files they target.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Analyzer’s internal keying/matching of SerializedFile names to be case-sensitive, aligning serialized-file reference resolution and ContentDirectory linkage with the already-case-sensitive handling for archive names.
Changes:
- Removed
ToLowerInvariant()normalization atSerializedFile-name keying sites, so cross-file reference IDs match exact casing. - Updated ContentDirectory
.cfdependency-key generation and lookup to use the original<contenthash>.cfcasing. - Adjusted related comments and behavior so dangling-ref stub names preserve referenced casing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Analyzer/Util/ContentFileDependencyMap.cs | Updates documentation/comments to reflect case-sensitive <contenthash>.cf keying. |
| Analyzer/SQLite/Writers/SerializedFileSQLiteWriter.cs | Stops lowercasing serialized file keys and external reference basenames; uses exact casing for ID lookup/mapping. |
| Analyzer/SQLite/Writers/ContentLayoutSQLWriter.cs | Stops lowercasing ContentLayout-derived .cf keys used for dependency mapping and serialized-file linkage. |
| Analyzer/SQLite/Handlers/AssetBundleHandler.cs | Stops lowercasing the SBP/Addressables scene file key when resolving scene SerializedFile IDs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using var reader = new UnityFileReader(fullPath, 64 * 1024 * 1024); | ||
| using var pptrReader = new PPtrAndCrcProcessor(sf, reader, containingFolder, m_SkipCrc, AddReference); | ||
| int serializedFileId = m_SerializedFileIdProvider.GetId(Path.GetFileName(fullPath).ToLowerInvariant()); | ||
| int serializedFileId = m_SerializedFileIdProvider.GetId(Path.GetFileName(fullPath)); |
SkowronskiAndrew
marked this pull request as ready for review
July 21, 2026 14:55
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
Follow-up to #51 (case-sensitive archive names).
Simplify SerializedFile handling to be case-sensitive for the actual filename.
I'm not sure the origin of the case-insensitive matching but this seems unnecessary, and muddies the
expectations about how references and file naming works.
The only case I'm aware of where Unity messes with the case is the convention it has of making
AssetBundle names lower case. (e.g. the Unity Archive is lower case regardless of the string
used in the AssetBundle name). This PR doesn't impact that legacy behavior.
Changes
ToLowerInvariant()at every SerializedFile-name key site:(
SerializedFileSQLiteWriter).sharedAssetsname and the scene file fromm_SceneHashes(SerializedFileSQLiteWriter,AssetBundleHandler)<contenthash>.cfkeys used for ContentLayout linkage and the content-filedependency map (
ContentLayoutSQLWriter,ContentFileDependencyMap)serialized_files.namealready stored the actual relative path;only the internal matching key changed.
Testing
dotnet test— full suite green (UnityFileSystem 425/10 skipped, Analyzer 62,UnityDataTool 259).
scene-bundle pipelines (BuildPipeline and SBP/Addressables), ContentDirectory,
dangling-refs and find-refs. Everything still resolves, confirming the test data has no
case mismatch between references and the files they target (CAB/
.cfnames arelowercase hex, player external references match their on-disk names, and the built-in
dangling targets
unity_builtin_extra/unity default resourcesstill match).