Skip to content

FIX: Silence Unity 6000.6 PVP-301-1 deprecation analyzers (DEVELOPMENT_BUILD / UNITY_64)#2427

Closed
LeoUnity wants to merge 2 commits into
developfrom
cleanup/uum-pvp-301-1-deprecations
Closed

FIX: Silence Unity 6000.6 PVP-301-1 deprecation analyzers (DEVELOPMENT_BUILD / UNITY_64)#2427
LeoUnity wants to merge 2 commits into
developfrom
cleanup/uum-pvp-301-1-deprecations

Conversation

@LeoUnity
Copy link
Copy Markdown
Collaborator

@LeoUnity LeoUnity commented Jun 3, 2026

Summary

Unity 6000.6 (alpha) added Package Validator Plugin rule PVP-301-1 that fails Validate - inputsystem - 6000.6 - {macos13, ubuntu2204, win10} jobs on three deprecated patterns flagged by the UAC0008 / UAC0009 / UAC1001 analyzers. All 35 flagged sites exist on develop today and are pre-existing; this PR cleans them up so 6000.6 Validate goes green across all PRs.

No behavioural change is intended. The deprecated directives are mapped one-to-one to their modern Unity-6 equivalents.

What this PR does NOT do

It does not touch any other PVP rule. The other PVP errors visible in validate-6006-mac-pvp/upm-ci~/pvp/com.unity.inputsystem.result.json (PVP-33-1, PVP-40-1, PVP-84-2, PVP-91-2, etc.) are already baselined in .yamato/wrench/pvp-exemptions.json and don't cause Validate to fail — only PVP-301-1 was unhandled. Confirmed in the failing job's Yamato log: Match found: PVP-301-1 is the sole finding.

Replacements

Analyzer Pattern Replacement Sites
UAC0009 #if DEVELOPMENT_BUILD || UNITY_EDITOR (and reversed) #if UNITY_EDITOR || DEBUG 27 sites across 9 files
UAC0009 #if DEVELOPMENT_BUILD (no editor) #if !UNITY_EDITOR && DEBUG 1 site (InputSystem.cs:3509, preserves "dev-player only, not editor" semantic)
UAC0009 [Conditional("DEVELOPMENT_BUILD")] [Conditional("DEBUG")] 1 site (EnhancedTouchSupport.cs:205)
UAC0008 #if UNITY_64 if (IntPtr.Size == 8) runtime check 2 sites in MemoryHelpers.cs (MemSet, MemCpyMasked 64-bit fast paths)
UAC1001 Unannotated non-serialisable field in [Serializable] struct [NonSerialized] 3 fields in HID.cs: HIDLayoutBuilder.deviceType (System.Type), HIDElementDescriptor.usageMin / usageMax (int?)

Why DEBUG and not UNITY_ENABLE_CHECKS?

The analyzer hint lists three modern alternatives — DEBUG, UNITY_ENABLE_CHECKS, and UNITY_INCLUDE_INSTRUMENTATION. The first revision of this PR used UNITY_ENABLE_CHECKS and broke the standalone-functional-tests run (Yamato job 69319540): in a Development Build with tests (UNITY_EDITOR=false, UNITY_INCLUDE_TESTS=true, DEVELOPMENT_BUILD=true), UNITY_ENABLE_CHECKS is not set, so the remoting block in InputSystem.cs was no longer compiled and InputSystemTestHooks.cs lost its InputSystem.remoteConnection symbol.

DEBUG is the right managed-code-variant directive: it's defined in the debug C# code variant, which is the default for Development Builds. So #if UNITY_EDITOR || DEBUG matches the prior #if UNITY_EDITOR || DEVELOPMENT_BUILD semantic in all observed configurations.

Other notes on the rewrites

  • For the UNITY_64 sites, the JIT folds the IntPtr.Size == 8 branch on 64-bit targets, so the 8-byte-block fast paths still execute on x64/ARM64 with no measurable overhead.
  • The HID.cs [NonSerialized] additions only make explicit what Unity's serialiser was already doing (skipping fields with non-serialisable types) — no on-disk or runtime state-block change.

Test plan

  • Yamato Validate - inputsystem - 6000.6 - macos13 / ubuntu2204 / win10 go green (the targeted goal).
  • Yamato editor + standalone functional tests (including the Development Build + tests configuration) on 6000.0-6000.6 stay green — this is what flushed out the UNITY_ENABLE_CHECKS mistake.
  • Local: open project on 6000.x and confirm editor argument-validation throws still fire on bad input to ControlBuilder.WithName(null) / similar (i.e. DEBUG is defined in editor as expected).

Notes

🤖 Generated with Claude Code

…ed by Unity 6000.6 PVP-301-1

Unity 6000.6 enforces a new Package Validator Plugin rule (PVP-301-1)
that fails Validate jobs on three deprecated patterns flagged by the
UAC0008 / UAC0009 / UAC1001 analyzers. All flagged sites already exist
on develop and are pre-existing; nothing in the runtime semantics is
intended to change.

Replacements:
- UAC0009: `#if DEVELOPMENT_BUILD || UNITY_EDITOR` (and the swapped-order
  variant) becomes `#if UNITY_EDITOR || UNITY_ENABLE_CHECKS`. UNITY_ENABLE_CHECKS
  is Unity 6's modern equivalent (set in editor, development players, and
  debug configurations), so it preserves the prior "validate in editor +
  development players" semantic.
  - InputSystem.cs (2 sites: 3369, 3509 — the latter switches to
    `!UNITY_EDITOR && UNITY_ENABLE_CHECKS` to preserve the
    "auto-enable remoting only in development players, not in editor"
    semantic of the original `#if DEVELOPMENT_BUILD`).
  - InputManager.cs (1 site).
  - InputControlExtensions.cs (17 sites — argument-validation guards on
    hot-path ControlBuilder methods).
  - InputControlList.cs (2 sites — `[DebuggerTypeProxy]` attribute and
    DebugView class guard).
  - InputRemoting.cs, InputEventBuffer.cs, InputStateBuffers.cs,
    InputSystemState.cs, PlayerInputManager.cs (1 site each).
  - EnhancedTouchSupport.cs: `[Conditional("DEVELOPMENT_BUILD")]` becomes
    `[Conditional("UNITY_ENABLE_CHECKS")]` (the companion
    `[Conditional("UNITY_EDITOR")]` is unchanged).

- UAC0008: `#if UNITY_64` in MemoryHelpers.cs (MemSet, MemCpyMasked)
  becomes `if (IntPtr.Size == 8)` so the 64-bit-optimised 8-byte block
  loops are still emitted but gated at runtime instead of compile time.
  JIT folds the branch on 64-bit targets, so there's no measurable
  overhead in practice.

- UAC1001: Added `[NonSerialized]` on three HID fields whose types
  (`System.Type`, `int?`) are not Unity-serialisable:
  `HID.HIDLayoutBuilder.deviceType`, `HID.HIDElementDescriptor.usageMin`,
  and `usageMax`. These were already being skipped by Unity's serializer,
  so this is purely making the existing behaviour explicit and silencing
  the analyzer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@LeoUnity LeoUnity marked this pull request as ready for review June 3, 2026 10:30
@LeoUnity LeoUnity requested review from ekcoh and jfreire-unity June 3, 2026 10:34
Copy link
Copy Markdown
Contributor

@u-pr u-pr Bot left a comment

Choose a reason for hiding this comment

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

Great

The changes are solid and well-structured, with a small opportunity to optimize a loop by hoisting invariant calculations.

🤖 Helpful? 👍/👎

Comment on lines +247 to +253
while (numBytes >= 8)
{
*(ulong*)&to[pos] = ((ulong)value << 56) | ((ulong)value << 48) | ((ulong)value << 40) | ((ulong)value << 32)
| ((ulong)value << 24) | ((ulong)value << 16) | ((ulong)value << 8) | value;
numBytes -= 8;
pos += 8;
}
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.

medium

Have you considered hoisting the 64-bit fill value calculation outside of the while loop? Since value is loop-invariant, calculating it once before the loop avoids redundant bit-shifting and bitwise operations on every iteration. This can significantly improve performance when filling larger buffers.

🤖 Helpful? 👍/👎 by guardian

…eplacement

UNITY_ENABLE_CHECKS is *not* equivalent to DEVELOPMENT_BUILD in player builds:
the standalone-functional-tests CI run (job 69319540) failed to compile
because in a Development Build with tests (UNITY_EDITOR=false,
UNITY_INCLUDE_TESTS=true, DEVELOPMENT_BUILD=true), UNITY_ENABLE_CHECKS
is not set, so the remoting block in InputSystem.cs was no longer
compiled — but InputSystemTestHooks.cs (which is guarded by
UNITY_EDITOR || UNITY_INCLUDE_TESTS) still referenced
InputSystem.remoteConnection.

DEBUG is the right managed-code-variant directive for this: it's defined
in the debug C# code variant, which is the default for Development
Builds. So `#if UNITY_EDITOR || DEBUG` matches the prior
`#if UNITY_EDITOR || DEVELOPMENT_BUILD` semantic in all observed
configurations.

Updated 30 lines across 10 files plus the CHANGELOG entry. HID.cs and
MemoryHelpers.cs unchanged from the previous commit (those don't involve
UNITY_ENABLE_CHECKS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov-github-com
Copy link
Copy Markdown

codecov-github-com Bot commented Jun 3, 2026

Codecov Report

Attention: Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tem/InputSystem/Runtime/Utilities/MemoryHelpers.cs 66.66% 5 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2427      +/-   ##
===========================================
+ Coverage    78.13%   78.92%   +0.79%     
===========================================
  Files          483      762     +279     
  Lines        98770   139280   +40510     
===========================================
+ Hits         77169   109926   +32757     
- Misses       21601    29354    +7753     
Flag Coverage Δ
inputsystem_MacOS_6000.0 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.0_project 77.28% <66.66%> (-0.02%) ⬇️
inputsystem_MacOS_6000.3 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.3_project 77.28% <66.66%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.4 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.4_project 77.29% <66.66%> (+0.01%) ⬆️
inputsystem_MacOS_6000.5 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.5_project 77.33% <66.66%> (+0.01%) ⬆️
inputsystem_MacOS_6000.6 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.6_project 77.33% <66.66%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0_project 77.19% <66.66%> (-0.02%) ⬇️
inputsystem_Ubuntu_6000.3 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.3_project 77.19% <66.66%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.4 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.4_project 77.20% <66.66%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.5 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.5_project 77.23% <66.66%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.6 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.6_project 77.23% <66.66%> (+0.01%) ⬆️
inputsystem_Windows_6000.0 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.0_project 77.41% <66.66%> (-0.02%) ⬇️
inputsystem_Windows_6000.3 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.3_project 77.40% <66.66%> (+<0.01%) ⬆️
inputsystem_Windows_6000.4_project 77.41% <66.66%> (+<0.01%) ⬆️
inputsystem_Windows_6000.5 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.5_project 77.46% <66.66%> (+0.01%) ⬆️
inputsystem_Windows_6000.6 5.32% <0.00%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
...tSystem/Runtime/Controls/InputControlExtensions.cs 76.12% <ø> (ø)
...m/InputSystem/Runtime/Controls/InputControlList.cs 74.31% <ø> (ø)
...nputSystem/Runtime/Devices/Remote/InputRemoting.cs 81.32% <ø> (ø)
...tem/InputSystem/Runtime/Events/InputEventBuffer.cs 73.61% <ø> (ø)
...ty.inputsystem/InputSystem/Runtime/InputManager.cs 89.04% <ø> (ø)
...ity.inputsystem/InputSystem/Runtime/InputSystem.cs 82.14% <ø> (ø)
...time/Plugins/EnhancedTouch/EnhancedTouchSupport.cs 91.66% <ø> (ø)
...inputsystem/InputSystem/Runtime/Plugins/HID/HID.cs 69.98% <ø> (ø)
.../Runtime/Plugins/PlayerInput/PlayerInputManager.cs 70.90% <ø> (ø)
...tem/InputSystem/Runtime/State/InputStateBuffers.cs 96.11% <ø> (ø)
... and 1 more

... and 196 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@LeoUnity
Copy link
Copy Markdown
Collaborator Author

LeoUnity commented Jun 3, 2026

#2425 Darren is already working on it!

@LeoUnity LeoUnity closed this Jun 3, 2026
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