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
    bugIf an issue is a bug or a pull request a bug fix
    ci-failureThe issue only affects CI
    testsAnything related to tests
    ci-postmortemCI post-mortem analysis: flaky tests, infrastructure failures, shared regressions
    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

    bugIf an issue is a bug or a pull request a bug fixci-failureThe issue only affects CIci-postmortemCI post-mortem analysis: flaky tests, infrastructure failures, shared regressionstestsAnything related to tests

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions