Skip to content

Conversation

@ekcoh
Copy link
Collaborator

@ekcoh ekcoh commented Oct 27, 2025

Description

The https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/api/UnityEngine.TestTools.Constraints.AllocatingGCMemoryConstraint.html example is misleading since it guides to alias the extended Is from this package (adding a single extension).

This leads to warnings in certain compilers/IDEs, e.g. https://www.jetbrains.com/help/resharper/AccessToStaticMemberViaDerivedType.html

However, the extension is extending NUnit.Framework.Is and hence the aliasing of Is can be made to this type instead to still support the extensions while also not generating warnings in aforementioned IDE.

This PR has no functional impact but allows noticing warnings in test code in Rider instead of getting hundreds of warnings about the above problem.

Skipping CHANGELOG entry since this is mainly internal.

Testing status & QA

Just checked it compiles and no warnings in Rider 2025.2.3 with Unity 6000.2.7f2.

Overall Product Risks

Minimal.

  • Complexity: Minmal
  • Halo Effect: Minimal

Comments to reviewers

No functional impact at all is expected.

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.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@u-pr-agent
Copy link

u-pr-agent bot commented Oct 27, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪

The PR consists of a simple and consistent change across multiple test files to improve code quality, with a clear explanation and minimal risk.
🏅 Score: 95

The PR correctly addresses an IDE warning issue by changing a type alias, improving code maintainability with no functional impact.
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent


#pragma warning disable CS0649
[SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")]
using Is = NUnit.Framework.Is;
Copy link

Choose a reason for hiding this comment

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

Suggestion: Changing the alias for Is from UnityEngine.TestTools.Constraints.Is to the base NUnit.Framework.Is may cause build errors. The derived type contains Unity-specific constraints like Is.AllocatingGCMemory. Please verify that no tests in this file use such constraints, as they will no longer be accessible through the Is alias. [possible issue, importance: 7]

Suggested change
using Is = NUnit.Framework.Is;
// If Unity-specific constraints are used, they must be fully qualified, e.g.:
// Assert.That(myCode, UnityEngine.TestTools.Constraints.Is.AllocatingGCMemory());
// Or, for better readability, introduce a separate alias:
using Is = NUnit.Framework.Is;
using UnityIs = UnityEngine.TestTools.Constraints.Is;

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but that is a very specific use case that is still supported since the Unity extension is based on the same class being aliased here. Not using the base is considered bad practise by e.g. JetBrains Rider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UnityEngine.TestTools.Constraints just need a using statement to make it accessible.

@codecov-github-com
Copy link

codecov-github-com bot commented Oct 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff             @@
##           develop    #2265      +/-   ##
===========================================
+ Coverage    76.70%   76.81%   +0.10%     
===========================================
  Files          465      476      +11     
  Lines        87919    88645     +726     
===========================================
+ Hits         67442    68093     +651     
- Misses       20477    20552      +75     
Flag Coverage Δ
inputsystem_MacOS_2021.3 5.93% <ø> (+0.02%) ⬆️
inputsystem_MacOS_2022.3 5.39% <ø> (+0.02%) ⬆️
inputsystem_MacOS_2022.3_project 74.74% <ø> (+0.15%) ⬆️
inputsystem_MacOS_6000.0 5.18% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 76.60% <ø> (+0.09%) ⬆️
inputsystem_MacOS_6000.2 5.18% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.2_project 76.60% <ø> (+0.09%) ⬆️
inputsystem_MacOS_6000.3 5.18% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 76.60% <ø> (+0.09%) ⬆️
inputsystem_MacOS_6000.4 5.19% <ø> (+<0.01%) ⬆️
inputsystem_MacOS_6000.4_project 76.61% <ø> (+0.10%) ⬆️
inputsystem_MacOS_6000.5 5.19% <ø> (?)
inputsystem_MacOS_6000.5_project 76.61% <ø> (?)
inputsystem_Ubuntu_2021.3 5.94% <ø> (+0.02%) ⬆️
inputsystem_Ubuntu_2022.3 5.40% <ø> (+0.02%) ⬆️
inputsystem_Ubuntu_2022.3_project 74.54% <ø> (+0.14%) ⬆️
inputsystem_Ubuntu_6000.0 5.19% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 76.40% <ø> (+0.08%) ⬆️
inputsystem_Ubuntu_6000.2 5.19% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.2_project 76.40% <ø> (+0.08%) ⬆️
inputsystem_Ubuntu_6000.3 5.19% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 76.40% <ø> (+0.08%) ⬆️
inputsystem_Ubuntu_6000.4 5.19% <ø> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.4_project 76.42% <ø> (+0.09%) ⬆️
inputsystem_Ubuntu_6000.5 5.19% <ø> (?)
inputsystem_Ubuntu_6000.5_project 76.41% <ø> (?)
inputsystem_Windows_2021.3 5.93% <ø> (+0.02%) ⬆️
inputsystem_Windows_2022.3 5.39% <ø> (+0.02%) ⬆️
inputsystem_Windows_2022.3_project 74.87% <ø> (+0.14%) ⬆️
inputsystem_Windows_6000.0 5.18% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 76.72% <ø> (+0.07%) ⬆️
inputsystem_Windows_6000.2 5.18% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.2_project 76.72% <ø> (+0.08%) ⬆️
inputsystem_Windows_6000.3 5.18% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 76.72% <ø> (+0.08%) ⬆️
inputsystem_Windows_6000.4 5.19% <ø> (+<0.01%) ⬆️
inputsystem_Windows_6000.4_project 76.73% <ø> (+0.08%) ⬆️
inputsystem_Windows_6000.5 5.19% <ø> (?)
inputsystem_Windows_6000.5_project 76.73% <ø> (?)

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

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/CoreTests_Actions.cs 97.77% <ø> (-0.01%) ⬇️
Assets/Tests/InputSystem/CoreTests_Controls.cs 99.39% <ø> (ø)
Assets/Tests/InputSystem/CoreTests_Devices.cs 98.08% <ø> (ø)
Assets/Tests/InputSystem/CoreTests_Events.cs 98.49% <ø> (+0.02%) ⬆️
...sets/Tests/InputSystem/Plugins/PlayerInputTests.cs 97.82% <ø> (ø)
Assets/Tests/InputSystem/Plugins/UITests.cs 94.67% <ø> (ø)

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.TestTools;
using Is = UnityEngine.TestTools.Constraints.Is;
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this not being used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think when UnityEngine.TestTools.Constraints isn't included (with using) there is no ambiguous behavior that needs explicit aliasing to be resolved, but I probably need to double check with a version that enables this code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There was no GC memory allocation check so UnityEngine.TestTools.Constraints isn't needed at least

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using NUnit.Framework; should be enough

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for checking!

Copy link
Collaborator

@ritamerkl ritamerkl left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding.

@ekcoh ekcoh merged commit a317819 into develop Oct 28, 2025
130 checks passed
@ekcoh ekcoh deleted the fix-aliasing-to-class-implementing-static-method branch October 28, 2025 08:32
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.

4 participants