Skip to content

[ECO-5624] Fix unity newtonsoft dependency#1313

Merged
sacOO7 merged 5 commits intomainfrom
fix/newtonsoft-unity
Nov 10, 2025
Merged

[ECO-5624] Fix unity newtonsoft dependency#1313
sacOO7 merged 5 commits intomainfrom
fix/newtonsoft-unity

Conversation

@sacOO7
Copy link
Copy Markdown
Collaborator

@sacOO7 sacOO7 commented Oct 25, 2025

Summary by CodeRabbit

  • New Features

    • Provides a single merged Unity runtime assembly for simpler plugin use.
  • Improvements

    • Automates the Unity plugin update workflow.
    • Better runtime/platform detection for Unity at runtime.
    • Streamlines example dashboard code and restores default network monitoring behavior.
  • Chores

    • Removes obsolete Unity plugin metadata and trims precompiled dependency references.
    • Removes an unused Unity package dependency from manifest.
  • Documentation

    • Updates Unity guidance to the dashboard demo and new updater flow.
  • Tests

    • Unity tests migrated from FluentAssertions to NUnit.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a Cake task that ilRepack-merges Unity-targeted DLLs into a single IO.Ably.dll and exposes Update.AblyUnity; replaces explicit updater copy scripts with that target; removes many Unity plugin .meta/.deps files; introduces UnityAdapter/UnityHelper for runtime detection; converts Agent runtime/os helpers to cached properties; migrates tests from FluentAssertions to NUnit and renames several example/test classes and asmdef references. Also updates build csproj for UNITY_PACKAGE, and adds/renames methods and a global variable in src/calculator.py.

Changes

Cohort / File(s) Summary
Build system & Cake tasks
cake-build/tasks/build.cake
Added _Build_Ably_Unity_Dll (validates NETStandard2.0 bin and required DLLs, deletes prior output, ilRepack-merges assemblies into IO.Ably.dll at unity/Assets/Ably/Plugins), added public Update.AblyUnity target depending on it; explicit error handling and logging.
Updater scripts
unity-plugins-updater.cmd, unity-plugins-updater.sh
Replaced multiple explicit copy commands with a single Cake invocation --target=Update.AblyUnity; retained version write/echo.
Project build settings
src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj
Removed explicit UnityEngine Reference; added conditional PropertyGroup under UNITY_PACKAGE to set CopyLocalLockFileAssemblies=true so NuGet dependencies are copied for ILRepack.
Unity plugin metadata & deps removed
unity/Assets/Ably/Plugins/*, unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/*, lib/unity/AOT/Newtonsoft.Json.dll.meta
Deleted many Unity .meta files and Newtonsoft.Json.deps.json; one AOT meta mapping key changed to an explicit empty-string key.
Assembly definitions & package manifest
unity/Assets/Tests/*/*.asmdef, unity/Packages/manifest.json, unity/Packages/packages-lock.json
Reduced precompiledReferences to IO.Ably.dll only, removed com.boundfoxstudios.fluentassertions from manifest/lock and registry scopes, added WebGL exclusion to PlayMode asmdef.
Test assertion migration & renames
unity/Assets/Tests/EditMode/*.cs, unity/Assets/Tests/PlayMode/*.cs
Replaced FluentAssertions with NUnit Assert equivalents across many tests; renamed test classes (AblyInterfaceSpecsAblyRealtimeSpecs, AuthSandboxSpecsAuthSpecs, StatsSandBoxSpecsStatsSpecs) and updated related helper types/constructors.
Example code renames & minor logic
unity/Assets/Ably/Examples/Dashboard/AblyMain.cs, .../AblyChannel.cs, .../AblyPresence.cs
Renamed example classes (AblyConsoleAblyMain, AblyChannelUiConsoleAblyChannel, AblyPresenceUiConsoleAblyPresence); updated factory calls; removed AutomaticNetworkStateMonitoring = false from ClientOptions.
Unity helper & adapter
src/IO.Ably.Shared/Unity/UnityAdapter.cs, src/IO.Ably.Shared/Unity/UnityHelper.cs
Added reflection-based UnityAdapter (IsAvailable, UnityVersion, RuntimePlatform) and UnityHelper mapping Unity runtime platform to agent-style identifiers with cached OsIdentifier and UnityIdentifier.
Agent refactor
src/IO.Ably.Shared/Agent.cs
Replaced DotnetRuntimeIdentifier and OsIdentifier methods with lazy-cached properties; removed older Unity-specific public helpers; updated call sites to use properties and UnityHelper.UnityIdentifier under UNITY_PACKAGE.
Call-site & tests updates
src/IO.Ably.Tests.Shared/**, src/IO.Ably.Shared/**
Updated call sites and tests to use Agent.DotnetRuntimeIdentifier and Agent.OsIdentifier properties (no method calls); added new Unity files to project items.
Linker config
unity/Assets/Ably/Plugins/link.xml
Removed IO.Ably.DeltaCodec entry; added UnityEngine.CoreModule/Application exposure for unityVersion/platform.
Docs & contributing
unity/CONTRIBUTING.md, unity/README.md, README.md
Updated contributor instructions to describe merged DLL workflow, removed assembly-validation guidance, added logging integration examples and Unity usage notes.
Calculator updates (new cohort)
src/calculator.py
Added method def coderabbit_add(x, y) to Calculator; changed coderabbit_formula(x, y)coderabbit_formula(x, y, z) (signature updated); renamed global old_global_varnew_global_var.

Sequence Diagram(s)

sequenceDiagram
    participant Updater as Updater script (shell/cmd)
    participant Cake as Cake
    participant Build as NETStandard build output
    participant Unity as Unity project (Assets/Ably/Plugins)

    rect rgb(247,247,255)
    Note over Updater,Unity: OLD flow (pre-change)
    Updater->>Build: --target=Build.NetStandard --define=UNITY_PACKAGE
    Updater->>Unity: copy IO.Ably.dll, IO.Ably.DeltaCodec.dll, *.pdb -> unity/Assets/Ably/Plugins
    Updater->>Unity: update version file
    end

    rect rgb(240,255,240)
    Note over Updater,Cake: NEW flow (post-change)
    Updater->>Cake: --target=Update.AblyUnity
    Cake->>Cake: run _Build_Ably_Unity_Dll
    Cake->>Build: validate NETStandard2.0 bin & required DLLs
    Cake->>Build: ilRepack merge assemblies -> produce merged IO.Ably.dll
    Cake->>Unity: copy merged IO.Ably.dll -> unity/Assets/Ably/Plugins
    Cake->>Unity: update version file
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on:
    • cake-build/tasks/build.cake — ilRepack arguments, path resolution, deletion semantics and error messages.
    • src/IO.Ably.Shared/{Agent.cs, UnityHelper.cs, UnityAdapter.cs} — lazy initialization, thread-safety, reflection fallbacks, platform-to-identifier mapping and public API changes.
    • Test migrations — ensure assertion semantics preserved and renamed test fixtures match CI expectations.
    • asmdef and Unity metadata deletions — confirm Unity will accept merged IO.Ably.dll and regenerate necessary .meta files.
    • src/calculator.py — verify added method, updated signature, and global variable rename do not break consumers.

Poem

🐰
I hopped through builds and merged each thread,
Small DLLs united into one ahead.
Tests now assert with steady light,
Plugins tidy, meta files light.
A rabbit cheers — the update’s right!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.23% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Out of Scope Changes check ❓ Inconclusive While most changes align with fixing Newtonsoft dependencies, extensive refactoring of test classes (renaming, assertion library migration) and Agent.cs identifier caching appear tangential to the core Newtonsoft dependency issue. Clarify whether the test refactoring and Agent identifier caching are necessary for the Newtonsoft DLL update or separate improvements that should be decoupled.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ECO-5624 Fix unity newtonsoft dependency' accurately describes the main change of fixing Newtonsoft dependency issues for Unity, making it clear and specific.
Linked Issues check ✅ Passed The PR successfully addresses the coding requirements from linked issues #1312 and ECO-5624: updated Newtonsoft DLLs for Unity, created new build tasks, and removed incompatible dependencies.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/newtonsoft-unity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 25, 2025 14:58 Inactive
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from bf98850 to 86d5060 Compare October 26, 2025 08:39
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 26, 2025 08:40 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 26, 2025 13:59 Inactive
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 0808025 to e6da13c Compare October 26, 2025 14:16
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 26, 2025 14:17 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 05:19 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 08:45 Inactive
@sacOO7 sacOO7 marked this pull request as ready for review October 27, 2025 08:49
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
cake-build/tasks/build.cake (1)

107-154: Consider adding existence checks for all DLLs before merging.

The task checks for the existence of the primary DLL and Newtonsoft.Json.dll but doesn't verify the existence of the other dependency DLLs (DeltaCodec, System.Runtime.CompilerServices.Unsafe, System.Threading.Channels, System.Threading.Tasks.Extensions) before attempting the merge. If any of these DLLs are missing, the merge operation may fail with a less descriptive error.

Consider adding explicit existence checks for all DLLs in the merge array:

     var dllsToMerge = new[]
     {
         netStandard20BinPath.CombineWithFilePath("IO.Ably.DeltaCodec.dll"),
         netStandard20BinPath.CombineWithFilePath("System.Runtime.CompilerServices.Unsafe.dll"),
         netStandard20BinPath.CombineWithFilePath("System.Threading.Channels.dll"),
         netStandard20BinPath.CombineWithFilePath("System.Threading.Tasks.Extensions.dll"),
         newtonsoftDll
     };
     
+    // Verify all DLLs exist before merging
+    foreach (var dll in dllsToMerge)
+    {
+        if (!FileExists(dll))
+        {
+            throw new Exception($"Required DLL not found: {dll}. Please build the IO.Ably.NETStandard20 project first.");
+        }
+    }
+    
     var unityOutputPath = paths.Root.Combine("unity/Assets/Ably/Plugins");
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 49287d8 and 5f03560.

⛔ Files ignored due to path filters (15)
  • lib/unity/AOT/Newtonsoft.Json.dll is excluded by !**/*.dll
  • lib/unity/UnityEngine.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Examples/Dashboard/AblyDashboard.unity is excluded by !**/*.unity
  • unity/Assets/Ably/Examples/Dashboard/logo.png is excluded by !**/*.png
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/IO.Ably.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll is excluded by !**/*.dll
  • unity/ProjectSettings/EditorBuildSettings.asset is excluded by !**/*.asset
  • unity/ProjectSettings/PackageManagerSettings.asset is excluded by !**/*.asset
  • unity/ProjectSettings/ProjectSettings.asset is excluded by !**/*.asset
  • unity/doc_images/assembly_version_validation.PNG is excluded by !**/*.png
📒 Files selected for processing (32)
  • cake-build/tasks/build.cake (2 hunks)
  • lib/unity/AOT/Newtonsoft.Json.dll.meta (1 hunks)
  • src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj (1 hunks)
  • unity-plugins-updater.cmd (1 hunks)
  • unity-plugins-updater.sh (1 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs (2 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyMain.cs (3 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyPresence.cs (2 hunks)
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.xml.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.xml.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll.meta (0 hunks)
  • unity/Assets/Tests/AblySandbox/AblySandbox.asmdef (1 hunks)
  • unity/Assets/Tests/EditMode/AblyInterfaceSpecs.cs (2 hunks)
  • unity/Assets/Tests/EditMode/AuthSandboxSpecs.cs (30 hunks)
  • unity/Assets/Tests/EditMode/EditMode.asmdef (1 hunks)
  • unity/Assets/Tests/EditMode/StatsSandBoxSpecs.cs (1 hunks)
  • unity/Assets/Tests/PlayMode/AblyInterfaceSpecs.cs (3 hunks)
  • unity/Assets/Tests/PlayMode/AuthSandboxSpecs.cs (30 hunks)
  • unity/Assets/Tests/PlayMode/PlayMode.asmdef (1 hunks)
  • unity/Assets/Tests/PlayMode/StatsSandBoxSpecs.cs (1 hunks)
  • unity/CONTRIBUTING.md (1 hunks)
  • unity/Packages/manifest.json (1 hunks)
  • unity/Packages/packages-lock.json (0 hunks)
  • unity/README.md (2 hunks)
💤 Files with no reviewable changes (12)
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta
  • unity/Packages/packages-lock.json
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.xml.meta
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.xml.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll.meta
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT.meta
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll.meta
🧰 Additional context used
🧬 Code graph analysis (7)
unity/Assets/Tests/EditMode/AblyInterfaceSpecs.cs (1)
src/IO.Ably.Shared/Agent.cs (4)
  • Agent (11-297)
  • OsIdentifier (159-258)
  • UnityPlayerIdentifier (90-94)
  • DotnetRuntimeIdentifier (46-87)
unity/Assets/Tests/PlayMode/StatsSandBoxSpecs.cs (1)
unity/Assets/Tests/AblySandbox/AblySandbox.cs (2)
  • AblySandbox (13-133)
  • AblySandbox (17-29)
unity/Assets/Tests/PlayMode/AblyInterfaceSpecs.cs (1)
src/IO.Ably.Shared/Agent.cs (4)
  • Agent (11-297)
  • OsIdentifier (159-258)
  • UnityPlayerIdentifier (90-94)
  • DotnetRuntimeIdentifier (46-87)
unity/Assets/Tests/EditMode/StatsSandBoxSpecs.cs (1)
unity/Assets/Tests/AblySandbox/AblySandbox.cs (2)
  • AblySandbox (13-133)
  • AblySandbox (17-29)
unity/Assets/Tests/EditMode/AuthSandboxSpecs.cs (6)
src/IO.Ably.Shared/TokenDetails.cs (1)
  • IsValidToken (131-146)
src/IO.Ably.Shared/Types/ErrorCodes.cs (1)
  • ErrorCodes (3-111)
unity/Assets/Tests/AblySandbox/TaskCompletionAwaiter.cs (1)
  • SetCompleted (58-61)
unity/Assets/Tests/PlayMode/AuthSandboxSpecs.cs (3)
  • Task (1014-1042)
  • Task (1044-1067)
  • Task (1069-1075)
unity/Assets/Tests/AblySandbox/AblySandbox.cs (3)
  • Task (67-74)
  • Task (76-88)
  • Task (90-104)
unity/Assets/Tests/AblySandbox/E7Assert.cs (2)
  • Task (9-12)
  • Task (14-39)
unity/Assets/Tests/PlayMode/AuthSandboxSpecs.cs (5)
src/IO.Ably.Shared/TokenDetails.cs (1)
  • IsValidToken (131-146)
src/IO.Ably.Shared/Types/ErrorCodes.cs (1)
  • ErrorCodes (3-111)
unity/Assets/Tests/EditMode/AuthSandboxSpecs.cs (3)
  • Task (1013-1041)
  • Task (1043-1066)
  • Task (1068-1074)
unity/Assets/Tests/AblySandbox/AblySandbox.cs (3)
  • Task (67-74)
  • Task (76-88)
  • Task (90-104)
unity/Assets/Tests/AblySandbox/E7Assert.cs (2)
  • Task (9-12)
  • Task (14-39)
unity/Assets/Ably/Examples/Dashboard/AblyMain.cs (2)
unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs (4)
  • AblyChannel (8-123)
  • AblyChannel (22-26)
  • AblyChannel (28-31)
  • RegisterUiComponents (33-54)
unity/Assets/Ably/Examples/Dashboard/AblyPresence.cs (4)
  • AblyPresence (7-142)
  • AblyPresence (21-25)
  • AblyPresence (27-30)
  • RegisterUiComponents (32-55)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check
  • GitHub Check: check
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
🔇 Additional comments (27)
lib/unity/AOT/Newtonsoft.Json.dll.meta (1)

15-15: LGTM - Unity metadata format correction.

The change from an implicit empty key to an explicit quoted empty string ('') is a valid YAML format adjustment for Unity's PluginImporter metadata.

unity/CONTRIBUTING.md (1)

151-154: LGTM - Documentation reflects new consolidated DLL workflow.

The updated description accurately reflects the new build process where dependencies are merged into IO.Ably.dll using ILRepack, aligning with the PR objectives.

unity/Assets/Tests/PlayMode/AuthSandboxSpecs.cs (2)

74-81: LGTM - FluentAssertions to NUnit migration.

The assertion conversions are correctly implemented with proper argument order (expected, actual).


381-381: Correct use of Assert.AreSame for singleton comparison.

Using Assert.AreSame for ErrorInfo.NonRenewableToken is appropriate as it checks reference equality for what is likely a static/singleton error instance.

unity/Assets/Tests/PlayMode/AblyInterfaceSpecs.cs (1)

221-243: LGTM - Correct FluentAssertions to NUnit migration.

The assertion conversions maintain the correct argument order and test logic. The validation of agent header structure and format is preserved.

unity/Assets/Tests/PlayMode/PlayMode.asmdef (2)

10-12: Appropriate WebGL exclusion.

Adding WebGL to excludePlatforms is consistent with the documented platform limitations in unity/README.md, which notes that WebGL is not supported due to WebSocket incompatibility.


15-18: LGTM - Consolidated precompiled references.

Reducing precompiled references to just nunit.framework.dll and IO.Ably.dll aligns with the PR's goal of merging dependencies into a single Unity DLL.

unity/Assets/Tests/AblySandbox/AblySandbox.asmdef (1)

9-12: LGTM - Consistent dependency consolidation.

The reduction of precompiled references matches the pattern applied across all test assemblies, supporting the unified IO.Ably.dll approach.

unity/README.md (2)

5-8: LGTM - Simplified system requirements.

Removing the Unity Scripting Runtime Version requirement streamlines the documentation while retaining the essential API Compatibility Level requirement.


60-61: Updated demo reference.

The change from chat demo to dashboard demo reflects the current example applications available in the repository.

unity/Assets/Tests/EditMode/EditMode.asmdef (1)

16-19: EditMode tests successfully migrated to NUnit.

Verification confirms all EditMode test files (AblyInterfaceSpecs.cs, AuthSandboxSpecs.cs, StatsSandBoxSpecs.cs) have been fully migrated to NUnit assertions. All assertion calls use Assert.* methods (AreEqual, IsTrue, IsFalse, IsNull) rather than FluentAssertions patterns. No FluentAssertions imports or BoundfoxStudios references remain. The removal of BoundfoxStudios.FluentAssertions from precompiled references is correct and justified.

cake-build/tasks/build.cake (1)

182-185: LGTM!

The public task provides a clear entry point for updating Unity DLLs with proper dependency on the internal build task.

unity/Assets/Ably/Examples/Dashboard/AblyPresence.cs (1)

7-30: LGTM!

The class rename from AblyPresenceUiConsole to AblyPresence improves code clarity by removing redundant naming. The constructor and factory method have been updated consistently.

unity/Assets/Tests/EditMode/AuthSandboxSpecs.cs (3)

73-80: LGTM!

The FluentAssertions migration to NUnit assertions is correctly applied. The assertion logic remains functionally equivalent.


110-132: LGTM!

The token validation assertions have been correctly migrated from FluentAssertions to NUnit. The test logic and expected behaviors are preserved.


161-169: LGTM!

Error reason and connection state assertions have been properly converted to NUnit format with correct assertion methods.

unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs (1)

8-30: LGTM!

The class rename from AblyChannelUiConsole to AblyChannel is consistent with the broader refactoring effort and improves naming clarity.

unity/Assets/Ably/Examples/Dashboard/AblyMain.cs (1)

10-10: LGTM!

The class rename from AblyConsole to AblyMain and the field type updates are consistent with the refactoring in the referenced classes (AblyChannel and AblyPresence). The factory method usage is correct.

Also applies to: 22-34

unity/Packages/manifest.json (1)

1-60: LGTM!

The removal of the FluentAssertions package and its scoped registry is consistent with the test migration from FluentAssertions to NUnit assertions throughout the Unity project.

unity-plugins-updater.cmd (1)

1-7: LGTM!

The simplification to use the centralized Update.AblyUnity Cake target is a good improvement. This eliminates duplication and delegates the DLL merging and copying logic to the build system, making the script more maintainable.

unity/Assets/Tests/PlayMode/StatsSandBoxSpecs.cs (1)

71-89: LGTM!

The FluentAssertions to NUnit assertion migration is correctly applied with proper argument order (expected, actual) following NUnit conventions.

unity/Assets/Tests/EditMode/StatsSandBoxSpecs.cs (1)

70-87: LGTM! Clean migration to NUnit assertions.

The FluentAssertions-to-NUnit migration maintains the correct test logic and aligns with the PR objective to enable Unity play mode testing on devices.

src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj (2)

64-64: LGTM! Path updated to align with Unity library reorganization.

The HintPath change correctly reflects the new location of UnityEngine.dll under lib/unity/.


68-72: Good addition to support ILRepack for Unity packaging.

The conditional CopyLocalLockFileAssemblies setting ensures NuGet dependencies are available in the output directory for ILRepack to merge. This correctly activates when UNITY_PACKAGE is defined via the --define=UNITY_PACKAGE flag in unity-plugins-updater.sh (line 6).

unity/Assets/Tests/EditMode/AblyInterfaceSpecs.cs (2)

224-224: LGTM! Correct assertion migration.

The conversion from FluentAssertions to NUnit maintains the correct test logic for verifying the header values array length.


227-228: LGTM! Assertion migrations maintain test intent.

The FluentAssertions-to-NUnit conversions are correct:

  • String prefix checks properly migrated to Assert.IsTrue(...StartsWith())
  • Count/length checks properly migrated to Assert.AreEqual
  • Line 245 retains the descriptive failure message, which is good for debugging

Also applies to: 238-238, 242-242, 245-245

unity-plugins-updater.sh (1)

7-7: Good consolidation of the Unity plugin update workflow.

Delegating to a Cake target is cleaner than explicit file copying. Ensure that the Update.AblyUnity target correctly places all required artifacts (IO.Ably.dll, PDB files, etc.) into unity/Assets/Ably/Plugins.

Run the following script to verify the Cake target exists and inspect its implementation:

@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 5f03560 to de00d64 Compare October 27, 2025 09:06
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 09:07 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 10:31 Inactive
@sacOO7 sacOO7 requested a review from ttypic October 27, 2025 10:58
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 1e7097b to 438dc8a Compare October 27, 2025 11:10
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 11:11 Inactive
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 438dc8a to 4df62c1 Compare October 27, 2025 11:48
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 27, 2025 11:49 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 28, 2025 13:03 Inactive
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 61b484c to 7d0629b Compare October 30, 2025 06:50
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features October 30, 2025 06:51 Inactive
Copy link
Copy Markdown
Contributor

@ttypic ttypic left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot temporarily deployed to staging/pull/1313/features November 5, 2025 08:50 Inactive
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d0629b and fdd67ec.

📒 Files selected for processing (7)
  • src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj (1 hunks)
  • src/IO.Ably.Shared/Agent.cs (5 hunks)
  • src/IO.Ably.Shared/Unity/UnityAdapter.cs (1 hunks)
  • src/IO.Ably.Shared/Unity/UnityHelper.cs (1 hunks)
  • src/IO.Ably.Tests.Shared/AgentTests.cs (1 hunks)
  • src/IO.Ably.Tests.Shared/Realtime/ConnectionSpecs/ConnectionParameterSpecs.cs (2 hunks)
  • src/IO.Ably.Tests.Shared/Rest/AblyHttpClientSpecs.cs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj
🧰 Additional context used
🧬 Code graph analysis (6)
src/IO.Ably.Tests.Shared/Rest/AblyHttpClientSpecs.cs (1)
src/IO.Ably.Shared/Agent.cs (1)
  • Agent (11-245)
src/IO.Ably.Tests.Shared/Realtime/ConnectionSpecs/ConnectionParameterSpecs.cs (1)
src/IO.Ably.Shared/Agent.cs (1)
  • Agent (11-245)
src/IO.Ably.Shared/Unity/UnityAdapter.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)
  • RuntimePlatform (36-79)
src/IO.Ably.Shared/Agent.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (2)
  • GetOsIdentifier (98-150)
  • UnityHelper (9-166)
src/IO.Ably.Tests.Shared/AgentTests.cs (1)
src/IO.Ably.Shared/Agent.cs (1)
  • Agent (11-245)
src/IO.Ably.Shared/Unity/UnityHelper.cs (2)
src/IO.Ably.Shared/Agent.cs (1)
  • GetOsIdentifier (107-206)
src/IO.Ably.Shared/Unity/UnityAdapter.cs (1)
  • UnityAdapter (26-150)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check
  • GitHub Check: check (net9.0)
  • GitHub Check: check
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
🔇 Additional comments (1)
src/IO.Ably.Tests.Shared/Realtime/ConnectionSpecs/ConnectionParameterSpecs.cs (1)

133-134: LGTM! Property access correctly replaces method calls.

The conversion from method calls to property access aligns with the Agent.cs refactoring that introduces cached, lazy-loaded properties for runtime and OS identifiers.

Comment thread src/IO.Ably.Shared/Agent.cs
Comment thread src/IO.Ably.Shared/Unity/UnityAdapter.cs
Comment thread src/IO.Ably.Shared/Unity/UnityAdapter.cs Outdated
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features November 6, 2025 07:30 Inactive
@sacOO7 sacOO7 force-pushed the fix/newtonsoft-unity branch from 1c0aa6c to 9459200 Compare November 6, 2025 10:13
@github-actions github-actions bot temporarily deployed to staging/pull/1313/features November 6, 2025 10:14 Inactive
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1c0aa6c and 9459200.

⛔ Files ignored due to path filters (1)
  • unity/Assets/Ably/Plugins/IO.Ably.dll is excluded by !**/*.dll
📒 Files selected for processing (7)
  • src/IO.Ably.Shared/IO.Ably.Shared.projitems (1 hunks)
  • src/IO.Ably.Shared/Unity/UnityAdapter.cs (1 hunks)
  • src/IO.Ably.Shared/Unity/UnityHelper.cs (1 hunks)
  • unity/Assets/Ably/Plugins/link.xml (1 hunks)
  • unity/Assets/Tests/AblySandbox/AblyRealtimeExtensions.cs (0 hunks)
  • unity/Assets/Tests/EditMode/AblyRealtimeSpecs.cs (2 hunks)
  • unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs (3 hunks)
💤 Files with no reviewable changes (1)
  • unity/Assets/Tests/AblySandbox/AblyRealtimeExtensions.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • unity/Assets/Tests/EditMode/AblyRealtimeSpecs.cs
🧰 Additional context used
🧬 Code graph analysis (3)
unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs (2)
src/IO.Ably.Shared/Agent.cs (1)
  • Agent (11-245)
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)
  • UnityHelper (9-166)
src/IO.Ably.Shared/Unity/UnityHelper.cs (2)
src/IO.Ably.Shared/Agent.cs (1)
  • GetOsIdentifier (107-206)
src/IO.Ably.Shared/Unity/UnityAdapter.cs (1)
  • UnityAdapter (26-132)
src/IO.Ably.Shared/Unity/UnityAdapter.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)
  • RuntimePlatform (36-79)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: check
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net9.0)
🔇 Additional comments (8)
unity/Assets/Ably/Plugins/link.xml (1)

3-8: LGTM! Linker configuration correctly preserves Unity reflection targets.

The addition of UnityEngine.CoreModule with UnityEngine.Application type and its unityVersion and platform properties is correctly aligned with the reflection-based access in UnityAdapter.cs. This ensures IL2CPP builds won't strip these properties that are accessed dynamically.

src/IO.Ably.Shared/Unity/UnityAdapter.cs (3)

58-72: Verify Unity version support and consider adding fallbacks.

The comment on line 63 states Unity 2017.1, but according to Unity's upgrade documentation, the assembly split to UnityEngine.CoreModule occurred in Unity 2017.2. Additionally, the past review discussion suggested a more defensive approach with fallbacks (try CoreModule → try UnityEngine → scan loaded assemblies), but the current implementation only probes CoreModule.

While this should work for Unity 2019+ (your target), consider whether the more defensive approach is warranted for robustness.

If you want to add the defensive fallbacks discussed in the previous review, here's the implementation:

 private static Type GetUnityApplication()
 {
     try
     {
-        // Attempt to load UnityEngine.Application type at runtime
-        // The UnityEngine.Application class has been located in the UnityEngine.CoreModule assembly since Unity 2017.1
-        // Returns null if the class is not found in UnityEngine.CoreModule
-        return Type.GetType("UnityEngine.Application, UnityEngine.CoreModule", throwOnError: false);
+        // 1. Try Unity 2019+ (CoreModule) - introduced in Unity 2017.2
+        var application = Type.GetType("UnityEngine.Application, UnityEngine.CoreModule", throwOnError: false);
+        
+        if (application != null)
+        {
+            return application;
+        }
+        
+        // 2. Try legacy Unity (pre-2017.2 monolithic UnityEngine)
+        application = Type.GetType("UnityEngine.Application, UnityEngine", throwOnError: false);
+        
+        if (application != null)
+        {
+            return application;
+        }
+        
+        // 3. Fallback: scan all loaded UnityEngine assemblies
+        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
+        {
+            var name = assembly.GetName().Name;
+            if (name != null && name.StartsWith("UnityEngine", StringComparison.Ordinal))
+            {
+                var type = assembly.GetType("UnityEngine.Application");
+                if (type != null)
+                {
+                    return type;
+                }
+            }
+        }
+        
+        return null;
     }
     catch
     {
         // Silently fail - Unity is not available
         return null;
     }
 }

78-101: LGTM! Safe string property access.

The method correctly uses the null-conditional operator and safe cast (as string) to handle potential reflection failures gracefully. The implementation is thread-safe when used with the Lazy<string> wrapper.


107-131: LGTM! Safe enum-to-string conversion.

The method uses ToString() to convert the RuntimePlatform enum to its string representation (e.g., "OSXEditor", "WindowsPlayer"). This approach avoids the boxing/unboxing issues that would occur with integer conversion and is safer than the int-based approach discussed in past reviews. The null-conditional operator and null coalescing ensure graceful degradation.

src/IO.Ably.Shared/IO.Ably.Shared.projitems (1)

181-182: LGTM! Unity integration files correctly added to build.

The two new Unity helper files are properly included in the MSBuild project items, making them available across all project configurations.

unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs (2)

10-10: LGTM! Necessary using directive for Unity helpers.

The using IO.Ably.Unity directive is required to access UnityHelper.UnityIdentifier used in the test assertions.


212-246: LGTM! Test correctly migrated to NUnit and property-based access.

The test method has been properly updated to:

  • Use NUnit assertions instead of FluentAssertions (enables play mode testing on devices per PR objectives)
  • Access Agent.DotnetRuntimeIdentifier, Agent.OsIdentifier, and UnityHelper.UnityIdentifier as properties (matching the Lazy-cached property pattern introduced in the Agent and Unity helpers)
  • Maintain correct assertion logic for Unity agent header validation
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)

98-150: LGTM! Comprehensive platform detection logic.

The GetOsIdentifier() method correctly maps all Unity runtime platforms to their corresponding Ably agent identifiers. The try-catch block provides graceful degradation for unknown future Unity platforms, and the empty string return aligns with the non-Unity fallback behavior.

Comment thread src/IO.Ably.Shared/Unity/UnityHelper.cs
Comment thread src/IO.Ably.Shared/Unity/UnityHelper.cs
@sacOO7 sacOO7 requested a review from Copilot November 7, 2025 14:38
Copy link
Copy Markdown

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 modernizes the Unity integration by removing external dependencies (FluentAssertions, separate DLL files), implementing reflection-based Unity detection to eliminate compile-time dependencies, and updating documentation to reflect simplified setup requirements. The changes consolidate all dependencies into a single IO.Ably.dll and replace assertion libraries with NUnit in tests.

  • Replaces FluentAssertions with NUnit assertions across all test files
  • Implements reflection-based Unity platform detection via new UnityAdapter and UnityHelper classes
  • Consolidates multiple DLLs into single merged IO.Ably.dll for Unity
  • Removes AutomaticNetworkStateMonitoring = false requirement from Unity setup

Reviewed Changes

Copilot reviewed 45 out of 71 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
unity/README.md Simplified Unity setup requirements and updated example references
unity/CONTRIBUTING.md Removed assembly validation documentation and updated plugin update process
unity/Assets/Tests/**/*.cs Converted FluentAssertions to NUnit assertions and renamed test classes
src/IO.Ably.Shared/Agent.cs Refactored to use properties instead of methods and integrated UnityHelper
src/IO.Ably.Shared/Unity/*.cs New reflection-based Unity detection without compile-time dependencies
cake-build/tasks/build.cake Added DLL merging task for Unity package creation
unity/Assets/Ably/Plugins/link.xml Updated to preserve UnityEngine.CoreModule properties
Comments suppressed due to low confidence (2)

unity/Assets/Tests/PlayMode/AuthSpecs.cs:612

  • These time-based assertions are fragile. The assertions compare token.Issued and token.Expires to DateTimeOffset.UtcNow which is evaluated at assertion time, not at token creation time. This creates a race condition where the test could fail if there's any delay between token creation and assertion. Consider capturing DateTimeOffset.UtcNow before the token request and using that captured value for assertions.
    unity/Assets/Tests/EditMode/AuthSpecs.cs:611
  • These time-based assertions are fragile. The assertions compare token.Issued and token.Expires to DateTimeOffset.UtcNow which is evaluated at assertion time, not at token creation time. This creates a race condition where the test could fail if there's any delay between token creation and assertion. Consider capturing DateTimeOffset.UtcNow before the token request and using that captured value for assertions.

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

Comment thread unity/Assets/Ably/Plugins/link.xml
Comment thread src/IO.Ably.Shared/Unity/UnityAdapter.cs
Comment thread src/IO.Ably.Shared/Unity/UnityAdapter.cs
Comment thread src/IO.Ably.Shared/Unity/UnityAdapter.cs
Comment thread src/IO.Ably.Shared/Unity/UnityHelper.cs
Base automatically changed from fix/upgrade-newtonsoft-dep to main November 10, 2025 07:09
- Added cake script to build IO.Ably.Dll with all dependencies merged
- Removed old dependencies from Ably/Plugins
- Updated README and CONTRIBUTING guide
- Updated test assertions to support native NUnit asserts
- Updated PlayMode.asmdef to exclude WebGL
- Removed references to UnityEngine imports, used reflection based approach
- Improved agent header caching machanism in Agent.cs
- Created UnityAdapter and UnityHelper to access unity specific APIs
- Updated UnityAdapter to handle instance access for different unity versions
- Fixed unity editmode and playmode tests for agent identifiers
- Updated link.xml with exclusions for needed types
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
unity/Assets/Ably/Plugins/link.xml (1)

3-8: Address the contradiction regarding UnityEngine.Application preservation.

This adds explicit link.xml directives to preserve UnityEngine.Application.unityVersion and UnityEngine.Application.platform, but a past review flagged a contradictory comment in UnityAdapter.cs stating these directives are unnecessary because "UnityEngine.Application (it's always preserved)".

Clarify whether:

  1. These properties are always preserved by Unity's il2cpp linker (in which case the link.xml entries are redundant and the comment is correct), or
  2. These properties are not always preserved (in which case the link.xml entries are necessary and the comment needs updating).

Please verify whether these properties are actually used in the codebase and whether explicit preservation is necessary:

#!/bin/bash
# Description: Find usages of UnityEngine.Application.unityVersion and platform in the codebase
# Expected: Show all call sites accessing these properties to confirm they are actually used

rg -nP --type=cs '\bApplication\.(unityVersion|platform)\b' unity/Assets/Ably/
rg -nP --type=cs 'GetType.*Application' unity/Assets/Ably/ -A 3 -B 3
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)

156-165: Fix incorrect Unity identifier when Unity is unavailable.

This issue was previously flagged: When UnityAdapter.IsAvailable is false (line 160), the method returns "unity", which incorrectly reports Unity presence in the agent header even when running outside Unity. This should return an empty string to exclude the Unity identifier from the agent header when Unity is not available.

Apply this fix:

 private static string GetUnityIdentifier()
 {
     if (!UnityAdapter.IsAvailable)
     {
-        return "unity";
+        return string.Empty;
     }

     var version = UnityAdapter.UnityVersion;
     return version.IsEmpty() ? "unity" : $"unity/{version}";
 }

This ensures the Unity identifier is only included when actually running in Unity, with a fallback to "unity" (without version) if the version string cannot be determined.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9459200 and 9a7ea90.

⛔ Files ignored due to path filters (15)
  • lib/UnityEngine.dll is excluded by !**/*.dll
  • lib/unity/AOT/Newtonsoft.Json.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Examples/Dashboard/AblyDashboard.unity is excluded by !**/*.unity
  • unity/Assets/Ably/Examples/Dashboard/logo.png is excluded by !**/*.png
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/IO.Ably.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll is excluded by !**/*.dll
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll is excluded by !**/*.dll
  • unity/ProjectSettings/EditorBuildSettings.asset is excluded by !**/*.asset
  • unity/ProjectSettings/PackageManagerSettings.asset is excluded by !**/*.asset
  • unity/ProjectSettings/ProjectSettings.asset is excluded by !**/*.asset
  • unity/doc_images/assembly_version_validation.PNG is excluded by !**/*.png
📒 Files selected for processing (42)
  • README.md (1 hunks)
  • cake-build/tasks/build.cake (2 hunks)
  • lib/unity/AOT/Newtonsoft.Json.dll.meta (1 hunks)
  • src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj (1 hunks)
  • src/IO.Ably.Shared/Agent.cs (5 hunks)
  • src/IO.Ably.Shared/IO.Ably.Shared.projitems (1 hunks)
  • src/IO.Ably.Shared/Unity/UnityAdapter.cs (1 hunks)
  • src/IO.Ably.Shared/Unity/UnityHelper.cs (1 hunks)
  • src/IO.Ably.Tests.Shared/AgentTests.cs (1 hunks)
  • src/IO.Ably.Tests.Shared/Realtime/ConnectionSpecs/ConnectionParameterSpecs.cs (2 hunks)
  • src/IO.Ably.Tests.Shared/Rest/AblyHttpClientSpecs.cs (2 hunks)
  • unity-plugins-updater.cmd (1 hunks)
  • unity-plugins-updater.sh (1 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs (2 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyMain.cs (3 hunks)
  • unity/Assets/Ably/Examples/Dashboard/AblyPresence.cs (2 hunks)
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.xml.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.xml.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll.meta (0 hunks)
  • unity/Assets/Ably/Plugins/link.xml (1 hunks)
  • unity/Assets/Tests/AblySandbox/AblyRealtimeExtensions.cs (0 hunks)
  • unity/Assets/Tests/AblySandbox/AblySandbox.asmdef (1 hunks)
  • unity/Assets/Tests/EditMode/AblyRealtimeSpecs.cs (2 hunks)
  • unity/Assets/Tests/EditMode/AuthSpecs.cs (32 hunks)
  • unity/Assets/Tests/EditMode/EditMode.asmdef (1 hunks)
  • unity/Assets/Tests/EditMode/StatsSpecs.cs (2 hunks)
  • unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs (3 hunks)
  • unity/Assets/Tests/PlayMode/AuthSpecs.cs (32 hunks)
  • unity/Assets/Tests/PlayMode/PlayMode.asmdef (1 hunks)
  • unity/Assets/Tests/PlayMode/StatsSpecs.cs (2 hunks)
  • unity/CONTRIBUTING.md (1 hunks)
  • unity/Packages/manifest.json (1 hunks)
  • unity/Packages/packages-lock.json (0 hunks)
  • unity/README.md (2 hunks)
💤 Files with no reviewable changes (13)
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.xml.meta
  • unity/Assets/Tests/AblySandbox/AblyRealtimeExtensions.cs
  • unity/Assets/Ably/Plugins/System.Threading.Channels.dll.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.xml.meta
  • unity/Assets/Ably/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.deps.json
  • unity/Assets/Ably/Plugins/NewtonsoftJsonAOT.meta
  • unity/Packages/packages-lock.json
  • unity/Assets/Ably/Plugins/IO.Ably.DeltaCodec.dll.meta
  • unity/Assets/Ably/Plugins/System.Threading.Tasks.Extensions.dll.meta
  • unity/Assets/Ably/Plugins/NewtonsoftJsonEditor/Newtonsoft.Json.dll.meta
🚧 Files skipped from review as they are similar to previous changes (16)
  • lib/unity/AOT/Newtonsoft.Json.dll.meta
  • unity/Assets/Tests/PlayMode/StatsSpecs.cs
  • src/IO.Ably.Shared/Unity/UnityAdapter.cs
  • unity/Packages/manifest.json
  • src/IO.Ably.Shared/IO.Ably.Shared.projitems
  • unity/Assets/Tests/EditMode/EditMode.asmdef
  • cake-build/tasks/build.cake
  • README.md
  • src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj
  • unity/Assets/Tests/EditMode/StatsSpecs.cs
  • src/IO.Ably.Tests.Shared/AgentTests.cs
  • unity/Assets/Tests/PlayMode/PlayMode.asmdef
  • src/IO.Ably.Tests.Shared/Realtime/ConnectionSpecs/ConnectionParameterSpecs.cs
  • unity/README.md
  • unity/Assets/Tests/AblySandbox/AblySandbox.asmdef
  • unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs
🧰 Additional context used
🧬 Code graph analysis (8)
unity/Assets/Tests/EditMode/AuthSpecs.cs (3)
src/IO.Ably.Shared/TokenDetails.cs (1)
  • IsValidToken (131-146)
src/IO.Ably.Shared/Types/ErrorCodes.cs (1)
  • ErrorCodes (3-111)
unity/Assets/Tests/PlayMode/AuthSpecs.cs (5)
  • Task (1014-1042)
  • Task (1044-1067)
  • Task (1069-1075)
  • RSA4Helper (1002-1076)
  • RSA4Helper (1008-1012)
unity/Assets/Tests/EditMode/AblyRealtimeSpecs.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)
  • UnityHelper (9-166)
unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (1)
  • UnityHelper (9-166)
unity/Assets/Tests/PlayMode/AuthSpecs.cs (3)
src/IO.Ably.Shared/TokenDetails.cs (1)
  • IsValidToken (131-146)
src/IO.Ably.Shared/Types/ErrorCodes.cs (1)
  • ErrorCodes (3-111)
unity/Assets/Tests/EditMode/AuthSpecs.cs (5)
  • Task (1013-1041)
  • Task (1043-1066)
  • Task (1068-1074)
  • RSA4Helper (1001-1075)
  • RSA4Helper (1007-1011)
src/IO.Ably.Tests.Shared/Rest/AblyHttpClientSpecs.cs (2)
src/IO.Ably.Shared/Agent.cs (1)
  • Agent (11-245)
src/IO.Ably.NETStandard20/Platform.cs (1)
  • Agent (28-52)
src/IO.Ably.Shared/Agent.cs (1)
src/IO.Ably.Shared/Unity/UnityHelper.cs (2)
  • GetOsIdentifier (98-150)
  • UnityHelper (9-166)
src/IO.Ably.Shared/Unity/UnityHelper.cs (2)
src/IO.Ably.Shared/Agent.cs (1)
  • GetOsIdentifier (107-206)
src/IO.Ably.Shared/Unity/UnityAdapter.cs (1)
  • UnityAdapter (26-132)
unity/Assets/Ably/Examples/Dashboard/AblyMain.cs (2)
unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs (4)
  • AblyChannel (8-123)
  • AblyChannel (22-26)
  • AblyChannel (28-31)
  • RegisterUiComponents (33-54)
unity/Assets/Ably/Examples/Dashboard/AblyPresence.cs (4)
  • AblyPresence (7-142)
  • AblyPresence (21-25)
  • AblyPresence (27-30)
  • RegisterUiComponents (32-55)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check
  • GitHub Check: check
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net9.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net7.0)
  • GitHub Check: check (net6.0)
  • GitHub Check: check (net8.0)
  • GitHub Check: check (net6.0)
🔇 Additional comments (11)
unity/CONTRIBUTING.md (1)

151-154: Documentation accurately reflects the implemented behavior.

Verification confirms that the documentation at line 154 is accurate. The updater scripts call Cake build targets that invoke ILRepack to merge dependencies into IO.Ably.dll (confirmed in cake-build/tasks/build.cake line 111) and output it to unity/Assets/Ably/Plugins/ (confirmed in cake-build/tasks/build.cake line 147). The changes clarify the script's behavior and align with the PR objective to create a unified merged DLL for Unity.

unity-plugins-updater.sh (1)

6-7: Good consistency with the CMD script, but verify dependencies and consider error handling.

The shell script now mirrors the Windows CMD workflow, which is excellent for maintainability. However, the same verification about the Update.AblyUnityBuild.NetStandard dependency chain applies here (see comments on unity-plugins-updater.cmd).

For Unix shells, consider adding set -e at the beginning of the script to fail fast on any error:

+set -e
+
 if [ $# -eq 0 ]
 then
   echo "Provide latest version number like unity-plugins-updater.sh 1.2.8"

Alternatively, add explicit error checking after each command:

 dotnet tool restore
-dotnet cake cake-build/build.cake -- --target=Build.NetStandard --define=UNITY_PACKAGE
-dotnet cake cake-build/build.cake -- --target=Update.AblyUnity
+dotnet cake cake-build/build.cake -- --target=Build.NetStandard --define=UNITY_PACKAGE || exit 1
+dotnet cake cake-build/build.cake -- --target=Update.AblyUnity || exit 1
unity-plugins-updater.cmd (1)

4-5: Dependency chain verified—code is correct as written.

The Update.AblyUnity target depends on _Build_Ably_Unity_Dll (cake-build/tasks/build.cake:190-192), which explicitly validates the existence of IO.Ably.NETStandard20/bin/Release/netstandard2.0/IO.Ably.dll and throws exceptions with clear messages if the build hasn't completed first. The sequential invocation of Build.NetStandard followed by Update.AblyUnity is intentional and necessary—running Update.AblyUnity standalone will fail with informative errors requiring the prior build step. The dependency chain is sound through explicit runtime validation rather than Cake task dependencies. Error handling with || exit /b 1 is optional but not required for correctness.

unity/Assets/Tests/EditMode/AblyRealtimeSpecs.cs (2)

10-10: LGTM! Correct namespace import and improved test class naming.

The addition of IO.Ably.Unity namespace enables access to UnityHelper, and the class rename to AblyRealtimeSpecs better reflects the test scope.

Also applies to: 17-17


222-243: LGTM! Correct migration to NUnit assertions and property-based access.

The test correctly:

  • Replaces FluentAssertions with NUnit assertions
  • Updates method calls to property access (Agent.DotnetRuntimeIdentifier, Agent.OsIdentifier)
  • Uses UnityHelper.UnityIdentifier instead of the removed Agent.UnityPlayerIdentifier()

These changes align with the PR's objective to remove FluentAssertions and refactor Agent identifiers to cached properties.

src/IO.Ably.Shared/Unity/UnityHelper.cs (2)

11-15: LGTM! Well-designed lazy initialization and platform detection constants.

The implementation correctly:

  • Uses lazy initialization to cache identifiers, avoiding repeated reflection calls
  • Defines platform-specific constants matching Ably's agent protocol format
  • Provides a RuntimePlatform nested class with string constants that mirror UnityEngine enum values without requiring a compile-time dependency

This design enables Unity detection without directly referencing UnityEngine assemblies.

Also applies to: 19-29, 36-79


85-85: LGTM! Correct property exposure and OS detection logic.

The properties correctly expose lazy-cached values, and GetOsIdentifier properly:

  • Returns empty string when Unity is unavailable
  • Maps platform strings to Ably-compatible identifiers
  • Handles unknown platforms gracefully with a catch-all fallback

The generic catch clause (lines 144-146) could optionally specify Exception type for clarity, as suggested in past reviews, but this is a minor style point.

Also applies to: 91-91, 98-150

src/IO.Ably.Shared/Agent.cs (4)

39-55: LGTM! Excellent refactoring to lazy-cached properties.

The addition of lazy-initialized fields and their corresponding properties improves performance by computing runtime and OS identifiers once and caching the results. The clear documentation and consistent pattern align well with the UnityHelper implementation.


64-64: LGTM! Correct method renames for private lazy initialization.

The methods are properly renamed to GetDotnetRuntimeIdentifier() and GetOsIdentifier(), following the naming convention for private initializers. Public access is correctly provided through the lazy-cached properties.

Also applies to: 107-107


117-119: LGTM! Unity OS identifier integration is correct.

The direct return of UnityHelper.OsIdentifier under UNITY_PACKAGE is appropriate. When Unity cannot detect the platform, it returns an empty string, which aligns with this method's fallback behavior at line 204. The past review concern about this approach was reasonably addressed by the developer.


225-225: LGTM! Correct property usage in agent composition.

The agent composition correctly uses:

  • DotnetRuntimeIdentifier and OsIdentifier properties instead of method calls
  • UnityHelper.UnityIdentifier instead of the removed Agent.UnityPlayerIdentifier()

These changes align with the refactoring to lazy-cached properties and Unity integration through UnityHelper.

Also applies to: 228-228, 231-231

Comment thread unity/Assets/Tests/PlayMode/AblyRealtimeSpecs.cs
@sacOO7 sacOO7 merged commit 29e56a2 into main Nov 10, 2025
20 checks passed
@sacOO7 sacOO7 deleted the fix/newtonsoft-unity branch November 10, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Update newtonsoft DLLs for unity

3 participants