Skip to content

FIX: [Port] Fixed CS0246 'InputSystemState' compile error in release Player builds with UNITY_INCLUDE_TESTS - #2513

Open
unitydavidlo wants to merge 1 commit into
developfrom
input/port-include-tests-release-build-test-framework
Open

unitydavidlo wants to merge 1 commit into
developfrom
input/port-include-tests-release-build-test-framework

Conversation

@unitydavidlo

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #2508, which didn't fully fix the problem.

The problem: a non-development Player build that includes test assemblies, with the UNITY_INCLUDE_TESTS scripting define set, still fails to compile with 1.20.2:

Tests/TestFixture/InputTestStateManager.cs(157,23): error CS0246: The type or namespace name 'InputSystemState' could not be found (are you missing a using directive or an assembly reference?)

A customer reported this after updating to 1.20.2. It's the same customer who reported the remoteConnection error.

Why: #2508 ported only the InputSystem.cs part of the trunk fix (ISX-2788). The trunk fix also changed the guards on the save/restore state code that the Unity.InputSystem.TestFramework assembly uses. In develop that code is still behind #if DEBUG, and DEBUG is only defined in development builds:

  • InputSystemState (#if DEBUG)
  • InputManager.SaveState / DeviceState / SerializedState (#if DEBUG)
  • InputRemoting.SaveState / SerializedState (#if DEBUG)

I said in #2508 that the other files in the trunk change only applied to trunk. That was wrong for these.

The fix: use the same guards as trunk:

  • The three blocks above are now #if UNITY_EDITOR || UNITY_INCLUDE_TESTS.
  • InputTestFixture calls SaveAndReset/Restore under #if UNITY_EDITOR || UNITY_INCLUDE_TESTS instead of #if DEVELOPMENT_BUILD || UNITY_EDITOR.

Testing status & QA

I made macOS Player builds with Unity 6000.3.25f1:

Package Build Result
develop before this change Non-development, UNITY_INCLUDE_TESTS, BuildOptions.IncludeTestAssemblies Fails with the CS0246 error above
This branch Same Builds fine
This branch Development, no UNITY_INCLUDE_TESTS Builds fine

The test assemblies have to be included in the build to hit this, for example with BuildOptions.IncludeTestAssemblies. Setting UNITY_INCLUDE_TESTS on its own doesn't compile Unity.InputSystem.TestFramework into the Player. My testing for #2508 didn't include them, so it missed this.

QA suggestion:

  • Make a non-development Player build with UNITY_INCLUDE_TESTS set and test assemblies included. It should compile.
  • Check that Input remoting from a development Player to the Editor still works.

There's no automated test, for the same reason as #2508: our CI only makes development builds for tests.

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low. This only changes which builds compile the test-only state code. In development builds without UNITY_INCLUDE_TESTS that code is no longer compiled, and nothing outside the Editor and the test framework uses it. A development build without UNITY_INCLUDE_TESTS still compiles.

Comments to reviewers

The changes match trunk's guards for these files.

There's no issue-tracker case yet. I'll add the ID to the title and changelog once there is one.

This PR was prepared by Claude Code (an AI coding agent).

Checklist

Before review:

  • Changelog entry added.
  • Tests added/changed, if applicable. (Not added. See Testing status.)
  • Docs for new/changed API's. (Not applicable: no API changes.)

During merge:

  • Commit message for squash-merge is prefixed with FIX: ___.

🤖 Generated with Claude Code

…Player builds with UNITY_INCLUDE_TESTS

The 1.20.2 port of the trunk fix (ISX-2788) only brought over the
InputSystem.remoteConnection change. The test framework assembly still
needs InputSystemState, InputManager.SaveState and InputRemoting.SaveState,
which were guarded by DEBUG and so missing in non-development Player builds
that include test assemblies. Guard them with UNITY_EDITOR ||
UNITY_INCLUDE_TESTS as trunk does, and do the same for the DEVELOPMENT_BUILD
guards in InputTestFixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@u-pr u-pr Bot 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.

💡 Harness Review

Ship it

The guard changes consistently enable state snapshots and fixture save/restore in release Players that include tests. I examined the affected code, callers, helper guards, test assembly configuration, and changelog and found no actionable issues.

Reviewed commit 3f0d06b

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2513   +/-   ##
========================================
  Coverage    79.22%   79.22%           
========================================
  Files          769      769           
  Lines       141300   141300           
========================================
  Hits        111939   111939           
  Misses       29361    29361           
Flag Coverage Δ
inputsystem_MacOS_6000.0_project 77.90% <ø> (+<0.01%) ⬆️
inputsystem_MacOS_6000.3_project 77.89% <ø> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.0_project 77.81% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.80% <ø> (ø)
inputsystem_Windows_6000.0_project 78.02% <ø> (ø)
inputsystem_Windows_6000.3_project 78.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nputSystem/Runtime/Devices/Remote/InputRemoting.cs 81.32% <ø> (ø)
...ty.inputsystem/InputSystem/Runtime/InputManager.cs 89.15% <ø> (ø)
....inputsystem/Tests/TestFixture/InputTestFixture.cs 76.81% <ø> (ø)

ℹ️ Need help interpreting these results?

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.

1 participant