Skip to content

[CI] Flaky generator test: UI namespace cache races across platform compilations #26184

Closed

Description

@dalexsoto

Failure

MediaAccessibility PR #26172, build 14698041, failed one Roslyn generator test:

Microsoft.Macios.Generator.Tests.Classes.ClassGenerationTests.GenerationTests
for the iOS UIKitPropertyTests input.

The expected Count getter contained:

UIKit.UIApplication.EnsureUIThread ();

The generated output omitted only that line. The PR does not modify generator code or tests, and generator jobs on nearby PRs passed.

Root cause

CompilationExtensions.GetUINamespaces uses a process-global static uiNamespacesCache that is not scoped to a Roslyn Compilation or platform.

PR #22195 serialized BaseGeneratorTestClass.CompareGeneratedCode, but other tests can still replace the cache concurrently. In particular, CompilationExtensionsTest.GetUINamespacesTests calls GetUINamespaces (force: true) outside that lock. xUnit runs different test classes in parallel by default.

A macOS compilation can therefore replace the cache with a set that does not contain UIKit while an iOS generator test is running. BindingContext.NeedsThreadChecks then becomes false, which produces exactly the observed missing EnsureUIThread line.

Suggested fix

Prefer eliminating the process-global cache or making it compilation-specific, for example by associating the result with the Compilation.

As temporary containment, serialize every test that mutates or consumes this shared cache, or disable test parallelization for the affected collection. Add an interleaved iOS/macOS regression test.

Evidence

Activity

  1. added
    bug
    ci-failure
    tests
    ci-postmortem
    on Jul 18, 2026
  2. added this to the Future milestone on Jul 20, 2026
  3. added a commit that references this issue on Jul 20, 2026
    940523e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugci-failureci-postmortemtests

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions