Skip to content

Add Addressables Report support #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

timt-unity3d
Copy link
Collaborator

No description provided.

@timt-unity3d timt-unity3d requested a review from Copilot July 8, 2025 18:13
Copy link

@Copilot Copilot AI left a comment

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 adds support for importing Unity Addressables build reports by parsing JSON build layout files and writing their data into new SQLite tables.

  • Introduce WriteAddressablesBuild in SQLiteWriter and register all related commands.
  • Add dozens of AbstractCommand subclasses to support addressables tables.
  • Update database schema (Init.sql) and analyzer tool to handle .json Addressables build reports.

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Analyzer/SQLite/SQLiteWriter.cs Register and use new Addressables build commands; implement WriteAddressablesBuild.
Analyzer/SQLite/Commands/*.cs Add command classes for each addressables-related table.
Analyzer/Resources/Init.sql Create all addr_build_* tables for addressables data.
Analyzer/AnalyzerTool.cs Detect .json files and route to ProcessAddressablesBuild.
Analyzer/Analyzer.csproj Add Newtonsoft.Json package for JSON deserialization.
Comments suppressed due to low confidence (2)

Analyzer/SQLite/SQLiteWriter.cs:62

  • [nitpick] The field name 'm_AddressablesDataFromOtherAsset' is missing 'Build' after 'Addressables'. Consider renaming to 'm_AddressablesBuildDataFromOtherAsset' for consistency.
    private AddressablesBuildDataFromOtherAsset m_AddressablesDataFromOtherAsset = new AddressablesBuildDataFromOtherAsset();

Analyzer/SQLite/SQLiteWriter.cs:259

  • This new method contains substantial logic for parsing and inserting data; consider adding unit tests to cover key code paths and error handling.
    public void WriteAddressablesBuild(string filename, BuildLayout buildLayout)

{
{ "name", SqliteType.Text },
{ "build_target", SqliteType.Integer },
{ "start_time", SqliteType.Integer },
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

The field mapping for 'start_time' is defined as SqliteType.Integer, but the table schema declares it as TEXT. Consider changing it to SqliteType.Text to match the schema and avoid type mismatches.

Suggested change
{ "start_time", SqliteType.Integer },
{ "start_time", SqliteType.Text },

Copilot uses AI. Check for mistakes.

@@ -6,28 +6,33 @@
using UnityDataTools.Analyzer.SQLite.Handlers;
using UnityDataTools.FileSystem;
using UnityDataTools.FileSystem.TypeTreeReaders;
using UnityDataTools.Analyzer.Build;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Xml.Linq;
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

The 'System.Xml.Linq' namespace is not used in this file; you can remove this import to reduce clutter.

Suggested change
using System.Xml.Linq;

Copilot uses AI. Check for mistakes.

@@ -6,28 +6,33 @@
using UnityDataTools.Analyzer.SQLite.Handlers;
using UnityDataTools.FileSystem;
using UnityDataTools.FileSystem.TypeTreeReaders;
using UnityDataTools.Analyzer.Build;
using static System.Runtime.InteropServices.JavaScript.JSType;
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

The static import of 'JSType' is not used; removing it will improve clarity.

Suggested change
using static System.Runtime.InteropServices.JavaScript.JSType;

Copilot uses AI. Check for mistakes.

m_AddressablesBuildBundleFile.CreateCommand(m_Database);

// Data From Other Asset Tables
// Data From Other Asset Tables
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

[nitpick] This comment is duplicated on the previous line. Removing one occurrence will keep the code cleaner.

Suggested change
// Data From Other Asset Tables

Copilot uses AI. Check for mistakes.

EraseProgressLine();
Console.Error.WriteLine();
Console.Error.WriteLine($"Error processing file: {file}");
Console.WriteLine($"{e.GetType()}: {e.Message}");
Copy link
Collaborator

Choose a reason for hiding this comment

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

.json is a standard file, and there will be .json files in a player output.

For those we should ideally continue to be silent or a minor warning about ignoring it.

Maybe there is a way to first just sanity check that it really is a Addressables build report, perhaps by peeking at the start of the file to check for clear expected formatting?

Or attempting to parsing it but only logging the full error if further analysis proves it is a Addressable file?

PRIMARY KEY (id)
);

create table addr_build_bundles
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure the short form will be immediately apparent to everyone "addr_build" as short for for Addressables Build.

Suggested change
create table addr_build_bundles
create table addressables_bundles

I wonder if there is any easy way to make all these tables optional, e.g. only created if we actually find Addressables file? I"m thinking now the dropdown of Tables will start with quite a long list of tables that will be all empty for some builds. Not the end of the world but if they are self contained maybe this can be a sql file that is only run when we discover the file?

Copy link
Collaborator

@SkowronskiAndrew SkowronskiAndrew left a comment

Choose a reason for hiding this comment

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

I took an initial peek at the code (but didn't try it out)
So far just a few suggestions about organizing the new functionality with a bit more structure, which probably could pay off as establishing a pattern for other build-pipeline-specific tables we might add in future.

{
internal class AddressablesBuild : AbstractCommand
{
protected override string TableName { get => "addr_builds"; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
protected override string TableName { get => "addr_builds"; }
protected override string TableName { get => "addressables_builds"; }

m_AddressablesBuildSubFile.SetValue("size", reference.data.Size);
m_AddressablesBuildSubFile.ExecuteNonQuery();
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

The SQLiteWriter.cs starts to get quite large. Maybe the new Addressables support code can be in a helper class that has its own source file. I can imagine similar pattern would be followed in the future if we add some Player, AssetBundle .manifest, or ContentFile specific information

Maybe AI can help do the leg work for that refactoring :)

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