Skip to content

[mobile] Skip ConcurrentDictionary reflection test on mobile platforms#127861

Open
github-actions[bot] wants to merge 3 commits intomainfrom
mobile-skip-concurrent-dict-test-109d80ddf7155796
Open

[mobile] Skip ConcurrentDictionary reflection test on mobile platforms#127861
github-actions[bot] wants to merge 3 commits intomainfrom
mobile-skip-concurrent-dict-test-109d80ddf7155796

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 6, 2026

Reasoning

The test ConcurrentDictionary_Generic_Tests_string_string.NonRandomizedToRandomizedUpgrade_FunctionsCorrectly uses reflection via Type.GetType("System.Collections.Concurrent.ConcurrentDictionary2+Tables, System.Collections.Concurrent", throwOnError: true)to load a nested private type from ConcurrentDictionary's implementation. This reflection call fails on iOS, tvOS, macCatalyst, and Android withTypeLoadException: Could not load type 'System.Collections.Concurrent.ConcurrentDictionary`2' from assembly 'System.Collections.Concurrent'`.

The test is attempting to inspect internal implementation details (the private _tables field and the nested Tables type) to extract the hash code function from the comparer. This level of reflection into nested types and private members is not supported on mobile platforms where assemblies are trimmed and/or AOT-compiled.

Since the test is verifying internal implementation behavior rather than public API contracts, and the failure is specific to reflection limitations on mobile platforms (not a product bug affecting end users), the appropriate fix is to skip the test on these platforms using [SkipOnPlatform].

Impact on platforms

Failing on all tested mobile platforms in build 1406427 (2026-05-03):

  • tvos-arm64 / osx.15.amd64.appletv.open / exit code 1
  • iossimulator-x64 / (inferred from platform pattern)
  • iossimulator-arm64 / (inferred from platform pattern)
  • maccatalyst-x64 / (inferred from platform pattern)
  • maccatalyst-arm64 / (inferred from platform pattern)
  • android-arm64 / (inferred from platform pattern)
  • android-arm / (inferred from platform pattern)
  • android-x64 / (inferred from platform pattern)
  • android-x86 / (inferred from platform pattern)

Errors log

From tvos-arm64 Helix work item System.Collections.Concurrent.Tests (console log):

[FAIL] System.Collections.Concurrent.Tests.ConcurrentDictionary_Generic_Tests_string_string.NonRandomizedToRandomizedUpgrade_FunctionsCorrectly(ignoreCase: False)
System.TypeLoadException : Could not load type 'System.Collections.Concurrent.ConcurrentDictionary`2' from assembly 'System.Collections.Concurrent'.
   at System.RuntimeTypeHandle.GetTypeByName(String typeName, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at System.Collections.Concurrent.Tests.ConcurrentDictionary_Generic_Tests_string_string.<GenerateCollidingStrings>g__GetHashCodeFunc|4_0(ConcurrentDictionary`2 cd)
   at System.Collections.Concurrent.Tests.ConcurrentDictionary_Generic_Tests_string_string.GenerateCollidingStrings(Int32 count)
   at System.Collections.Concurrent.Tests.ConcurrentDictionary_Generic_Tests_string_string.NonRandomizedToRandomizedUpgrade_FunctionsCorrectly(Boolean ignoreCase)

First build it occurred

First observed (within the scanned window) in build 1406427, which finished on 2026-05-03T09:02:27Z.

Note: This is computed within the last ~20 builds scanned and may not be the true origin. The test may have been failing on mobile platforms since its introduction, as it relies on reflection capabilities not available in trimmed/AOT mobile builds.

Note

This change was generated by the Mobile Platform Failure Scanner workflow.

Generated by Mobile Platform Failure Scanner · ● 6.8M ·

The test NonRandomizedToRandomizedUpgrade_FunctionsCorrectly uses
Type.GetType to load the nested ConcurrentDictionary+Tables type,
which fails with TypeLoadException on iOS, tvOS, macCatalyst, and Android.

Fixes test failure in runtime-extra-platforms pipeline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 6, 2026

🤖 Copilot Code Review — PR #127861

Note

This review was generated by Copilot.

Holistic Assessment

Motivation: The test NonRandomizedToRandomizedUpgrade_FunctionsCorrectly uses Type.GetType to load the nested ConcurrentDictionary+Tables type via reflection (line 78), which fails with TypeLoadException on mobile platforms. This is a known limitation of mobile runtimes and skipping the test is reasonable.

Approach: Using [SkipOnPlatform] is the correct pattern for permanently excluding tests that cannot work on specific platforms due to inherent platform limitations (as opposed to [ActiveIssue] which implies a tracked bug to be fixed). The platform set (iOS, tvOS, MacCatalyst, Android) is appropriate and the skip reason message is descriptive.

Summary: ✅ LGTM. This is a straightforward, low-risk test infrastructure fix. The attribute usage follows established patterns in the repo, the platform list is correct, and the skip reason accurately describes the limitation.


Detailed Findings

✅ Correct Use of [SkipOnPlatform] vs [ActiveIssue]

The choice to use [SkipOnPlatform] rather than [ActiveIssue] is appropriate here. The Type.GetType call loading a nested generic type by string name is not expected to be fixed on mobile platforms — it is a fundamental limitation of the trimmed/AOT environment rather than a tracked regression. The existing [ActiveIssue] on line 50 correctly addresses a different concern (aggressive trimming tracked in #81945).

✅ Platform Coverage is Complete

All four mobile platforms where this failure would occur are covered: iOS, tvOS, MacCatalyst, and Android. This matches the pattern used in other libraries (e.g., System.Runtime, System.Diagnostics.Process) for similar reflection-based limitations.

💡 Consider Whether an Issue Should Be Linked

While [SkipOnPlatform] does not require a linked issue, it might be useful for discoverability to mention a tracking issue in the commit message if one exists for the broader "nested Type.GetType on mobile" limitation. This is non-blocking — purely for future maintainers trying to understand the scope of this platform gap.

Generated by Code Review for issue #127861 ·

@kotlarmilos kotlarmilos marked this pull request as ready for review May 6, 2026 11:48
@kotlarmilos kotlarmilos requested review from Copilot and vitek-karas May 6, 2026 11:48
@kotlarmilos
Copy link
Copy Markdown
Member

@copilot Add ActiveIssue with #81945

@kotlarmilos kotlarmilos requested a review from matouskozak May 6, 2026 11:50
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone May 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses mobile test failures in System.Collections.Concurrent.Tests by skipping a ConcurrentDictionary test that relies on reflection over private nested implementation types, which is not reliable on trimmed/AOT mobile platforms.

Changes:

  • Skip NonRandomizedToRandomizedUpgrade_FunctionsCorrectly on iOS, tvOS, MacCatalyst, and Android via [SkipOnPlatform].
  • Preserve existing trimming-related gating ([ActiveIssue(... IsBuiltWithAggressiveTrimming)]) while adding explicit mobile platform exclusion.
Show a summary per file
File Description
src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionary.Generic.Tests.cs Skips the reflection-based ConcurrentDictionary implementation-detail test on mobile platforms where Type.GetType/private-type reflection is not supported under trimming/AOT.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b659870c-8b89-4bd5-9116-3e2ecaee098f

Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

@copilot Add ActiveIssue with #81945

Added the ActiveIssue for the mobile-platform skip in 907ef5a.

Copilot AI requested a review from kotlarmilos May 6, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants