Repository navigation
test: avoid C# 14 ambiguous Contains call in UniversalRpcTests - #4193
Open
BrianUnity wants to merge 2 commits into
Open
BrianUnity wants to merge 2 commits into
BrianUnity wants to merge 2 commits into
Conversation
From C# 14, an array converts implicitly to ReadOnlySpan<T>, so recipient.Contains(c) on a ulong[] matches both MemoryExtensions.Contains and Unity.Collections' NativeArrayExtensions.Contains, and the compiler reports CS0121. Add a ContainsId extension method backed by Array.IndexOf and use it at the 12 affected call sites. It compiles the same way on C# 9.
BrianUnity
marked this pull request as ready for review
October 16, 2026 10:44
Contributor
|
Check the configuration's TOML syntax, permitted settings, and size limit. See the error below. Error message: Configuration content:# This is the configuration for the u-pr bot
# https://github.cds.internal.unity3d.com/unity/u-pr
# For configuration of this file:
# https://developer.portal.internal.unity.com/catalog/default/component/u-pr/docs/configuration/automatic_runs/
[github_app]
handle_pr_actions = ['opened', 'ready_for_review'] # PR events that auto-run pr_commands
pr_commands = ["/harness-review"] # what runs on those events
reviewer_commands = ["/harness-review"] # what runs when @u-pr is added as reviewer
|
Contributor
There was a problem hiding this comment.
💡 Harness Review
The helper avoids the C# 14 overload ambiguity while preserving array membership behavior. I examined all 12 replacements, the helper’s scope, and the recipient inputs in both current and legacy tests; no actionable issues were found.
Reviewed commit 5cce296
🤖 Helpful? 👍/👎
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop-3.x.x #4193 +/- ##
==============================================
Coverage 76.11% 76.11%
==============================================
Files 159 159
Lines 27333 27333
==============================================
Hits 20805 20805
Misses 6528 6528
Flags with carried forward coverage won't be shown. Click here to find out more.
|
EmandM
approved these changes
Oct 16, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
UniversalRpcTests.csdoes not compile with C# 14. The compiler reports error CS0121 (ambiguous call) at 12 lines like this one:recipientis aulong[]. C# 14 can convert an array to aReadOnlySpan<T>automatically. Because of this, two span methods now matchrecipient.Contains(c):System.MemoryExtensions.ContainsUnity.Collections.NativeArrayExtensions.ContainsThe compiler cannot choose between them.
This PR adds a small extension method,
ContainsId, that usesArray.IndexOf. The 12 lines now callrecipient.ContainsId(c). The new name does not match the span methods, so the call is not ambiguous. The behavior does not change, and the code still compiles with older C# versions.I searched the rest of the package for the same problem and found none.
Jira ticket
UUM-155844
Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Automated tests:
Covered by existing automated testsWith the same
Array.IndexOfcheck, all PlayMode tests passed on .NET 10 (5378 passed, 0 failed).Up-port
Not needed. This PR targets the newest branch.
Backports
develop-2.0.0anddevelophave the same 12 lines. They need the same fix if they must compile with C# 14.