Skip to content

Match SerializedFile names case-sensitively#106

Merged
SkowronskiAndrew merged 1 commit into
mainfrom
case-sensitive-serialized-file-handling
Jul 21, 2026
Merged

Match SerializedFile names case-sensitively#106
SkowronskiAndrew merged 1 commit into
mainfrom
case-sensitive-serialized-file-handling

Conversation

@SkowronskiAndrew

@SkowronskiAndrew SkowronskiAndrew commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

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

  • Dropped ToLowerInvariant() at every SerializedFile-name key site:
    • a file's own name and its external-reference path basenames
      (SerializedFileSQLiteWriter)
    • the SBP/Addressables scene .sharedAssets name and the scene file from
      m_SceneHashes (SerializedFileSQLiteWriter, AssetBundleHandler)
    • the <contenthash>.cf keys used for ContentLayout linkage and the content-file
      dependency map (ContentLayoutSQLWriter, ContentFileDependencyMap)
  • Updated the related comments.
  • Dangling-ref stub names now preserve the referenced case instead of being lowercased.
  • No schema change: serialized_files.name already 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).
  • The suite exercises AssetBundles across Unity 2019–2023, player builds, both
    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/.cf names are
    lowercase hex, player external references match their on-disk names, and the built-in
    dangling targets unity_builtin_extra / unity default resources still match).

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.

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

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 at SerializedFile-name keying sites, so cross-file reference IDs match exact casing.
  • Updated ContentDirectory .cf dependency-key generation and lookup to use the original <contenthash>.cf casing.
  • 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
SkowronskiAndrew marked this pull request as ready for review July 21, 2026 14:55
@SkowronskiAndrew
SkowronskiAndrew merged commit ae9bc52 into main Jul 21, 2026
6 checks passed
@SkowronskiAndrew
SkowronskiAndrew deleted the case-sensitive-serialized-file-handling branch July 21, 2026 14:56
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.

2 participants