close
Skip to content

DOCS: Move hardcoded code examples to testable files - #2472

Open
ChoshikaBagratee wants to merge 10 commits into
developfrom
docatt-11021-move-hardcoded-code-examples
Open

DOCS: Move hardcoded code examples to testable files#2472
ChoshikaBagratee wants to merge 10 commits into
developfrom
docatt-11021-move-hardcoded-code-examples

Conversation

@ChoshikaBagratee

@ChoshikaBagratee ChoshikaBagratee commented Aug 12, 2026

Copy link
Copy Markdown

Description

JIRA: DOCATT-11021

Moves some of the code examples into testable files. I did not have time to move all of them.

Testing status & QA

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity:
  • Halo Effect:

Comments to reviewers

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

@cla-assistant-unity

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ChoshikaBagratee
ChoshikaBagratee marked this pull request as ready for review August 21, 2026 19:28
@ChoshikaBagratee ChoshikaBagratee changed the title Move hardcoded code examples to testable files DOCS: Move hardcoded code examples to testable files Aug 21, 2026

@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

Needs changes

The migration consistently redirects the affected manual pages to external source regions, but several of the newly added samples cannot be compiled together in the existing documentation-samples assembly.

Reviewed commit 8a42ed2

🤖 Helpful? 👍/👎

using UnityEngine;
using UnityEngine.InputSystem;

class BindingConflictsExample : InputTestFixture

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.

P1

InputTestFixture is not provided by this assembly's only direct reference (Unity.InputSystem): its declaration belongs to the separate Unity.InputSystem.TestFramework assembly. Consequently this sample produces an unresolved-type compiler error in Unity.InputSystem.DocCodeSamples. Either put this test-fixture example in a test assembly that references the framework (with the appropriate test constraints) or avoid using the fixture in this compiled sample.

🤖 Helpful? 👍/👎

using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Interactions;

public class ExampleScript : MonoBehaviour

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.

P1

These sources are all compiled into one documentation-samples assembly, so this declares DocCodeSamples.Tests.ExampleScript a second time—the same fully qualified type is already declared in ConfigureInputfromCode.cs. The same change also introduces a duplicate global MyPlayerScript between GenerateCsApiFromActions.cs and UsingDirectWorkflow.cs. C# rejects both duplicate declarations, preventing the entire samples assembly from compiling; give the snippets distinct types or namespaces.

🤖 Helpful? 👍/👎

// you change the default values for the action map, the name of the interface
// will be different.

public class MyPlayerScript : MonoBehaviour, IGameplayActions

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.

P1

The sample assembly contains neither IGameplayActions nor MyPlayerControls; the latter is only described in the comments as code the user would generate. This makes the relocated sample fail to compile (and generated callback interfaces are nested under their generated wrapper type). Add an appropriate generated test fixture/stub and implement the nested interface, or exclude this intentionally incomplete snippet from the compiled sample assembly.

🤖 Helpful? 👍/👎

// controls (For example, "<Gamepad>/<Button>").
// NOTE: The unconstrained InputStateHistory class can record changes on controls
// of different value types.
var history = new InputStateHistory<Vector2>("<Touchscreen>/primaryTouch/position");

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.

P1

InputStateHistory<TValue> is declared in UnityEngine.InputSystem.LowLevel, but this file imports only UnityEngine.InputSystem. The two examples therefore cannot resolve InputStateHistory and make the samples assembly fail to compile. Add the LowLevel using (or fully qualify the type).

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2472   +/-   ##
========================================
  Coverage    78.95%   78.95%           
========================================
  Files          767      767           
  Lines       140780   140780           
========================================
  Hits        111153   111153           
  Misses       29627    29627           
Files with missing lines Coverage Δ
...stem/DocCodeSamples.Tests/GamepadHapticsExample.cs 0.00% <ø> (ø)

ℹ️ 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