Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Assets/Tests/InputSystem/CoreTests_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
using UnityEngine.TestTools;
using UnityEngine.TestTools.Utils;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;

#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.


#pragma warning disable CS0649
// As should be obvious from the number of tests in here, the action system rivals the entire combined rest of the system
// in terms of complexity.
partial class CoreTests
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/CoreTests_Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Profiling;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;
using Is = NUnit.Framework.Is;

partial class CoreTests
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/CoreTests_Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using UnityEngine.TestTools.Utils;
using Gyroscope = UnityEngine.InputSystem.Gyroscope;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;
using Is = NUnit.Framework.Is;
using Quaternion = UnityEngine.Quaternion;
using TouchPhase = UnityEngine.InputSystem.TouchPhase;
using Vector2 = UnityEngine.Vector2;
Expand Down
3 changes: 2 additions & 1 deletion Assets/Tests/InputSystem/CoreTests_Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
using UnityEngine.TestTools;
using UnityEngine.TestTools.Constraints;
using UnityEngine.TestTools.Utils;
using Is = UnityEngine.TestTools.Constraints.Is;

using Is = NUnit.Framework.Is;
using Random = UnityEngine.Random;
using TouchPhase = UnityEngine.InputSystem.TouchPhase;

Expand Down
1 change: 0 additions & 1 deletion Assets/Tests/InputSystem/CoreTests_MouseEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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!


partial class CoreTests
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using UnityEngine.TestTools.Constraints;
using Object = UnityEngine.Object;
using Gyroscope = UnityEngine.InputSystem.Gyroscope;
using Is = UnityEngine.TestTools.Constraints.Is;
using Is = NUnit.Framework.Is;
using UnityEngine.InputSystem.OnScreen;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/Plugins/UITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using UnityEngine.TestTools.Utils;
using UnityEngine.UI;
using Image = UnityEngine.UI.Image;
using Is = UnityEngine.TestTools.Constraints.Is;
using Is = NUnit.Framework.Is;
using MouseButton = UnityEngine.InputSystem.LowLevel.MouseButton;
using UnityEngine.Scripting;
using Cursor = UnityEngine.Cursor;
Expand Down