Conversation
Port of #125019 Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
The merge from upstream/main reintroduced xunit v2 patterns in files that were modified on both branches: - EdgeCaseTests.cs: [ConditionalTheory] -> [Theory] (fixes CS0618 build error blocking 21 CI jobs), SkipTestException -> SkipException.ForSkip() - Regex.Match.Tests.cs: SkipTestException -> SkipException.ForSkip() - DumpTestBase.cs: SkipTestException -> SkipException.ForSkip() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
@copilot please revert all changes to production code |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/366384e9-ee01-45a6-8bc0-e3ec75e0d12d Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Reverted all 19 production code files to their original state in 7167df8. Files reverted:
Only test code, test infrastructure ( |
|
@copilot these changes are test infra: src/libraries/sendtohelix-browser.targets, sendtohelix-wasi.targets |
…-wasi.targets (test infra) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/257c3fec-6b69-4b38-b147-c12d2df91422 Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
| </PropertyGroup> | ||
|
|
||
| <!-- | ||
| Override the xunit.v3.core.mtp-v1 validation target. The original target |
There was a problem hiding this comment.
This feels like a situation where you could be using xunit.v3.extensibility.core instead of xunit.v3.core, especially if your custom runner replaces what xunit.v3.runner.inproc.console does. That would make sense in your situation (with a custom runner) and then these rules wouldn't end up being applied. In essence, xunit.v3.core is the package we think of as the package that says "you're planning to run your tests exactly how we intended for .NET Framework and/or .NET", and when you don't fit that mold, stepping away from that package makes sense to me.
There was a problem hiding this comment.
(I make this comment without understanding how your custom runner slots into anything. Feel free to ignore me. 😂)
xunit v3 relies on Assembly.Location which returns empty string in NativeAOT, causing 'Argument was empty (Parameter AssemblyName)'. xunit v4 (4.0.0-pre.33) fixes this internally. Changes: - Override XUnitV3Version to 4.0.0-pre.33 for TestNativeAot builds - Update SingleFileTestRunner.cs for v4 API changes: - Namespace moves (ConsoleHelper, AssemblyMetadata, etc.) - Replace removed GetTargetFramework() with TargetFrameworkAttribute - Use non-obsolete Run() overload with resultWriters parameter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
@copilot looks like there are api changes in the new xunit versions for the singlefiletestrunner: these failures are in the arm64 naot run: Running assembly:System.Collections.Tests, Version=11.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 DOTNET_DbgEnab |
…ileTestRunner The AssemblyMetadata constructor in xunit v3 only accepts xunitVersion values 0-3. Reverts the v4 pre-release upgrade attempt (2c15bdf) and restores the working xunit v3 code with AssemblyMetadata(3, ...). Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b213ec25-ccc3-406a-a952-c9ea640003a5 Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
…ls is empty On Windows, UninstallableSignals() returns Enumerable.Empty<object[]>(). In xunit v3, a Theory with no data rows fails with 'No data found' instead of being silently skipped as in v2. Add SkipWhenEmpty = true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The NativeAOT attribute stub for ConditionalTheoryAttribute is a plain Attribute (not inheriting from TheoryAttribute), so it lacks properties added in xunit v3. Add SkipWhenEmpty so test code using it compiles in NativeAOT builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The property on TheoryAttribute in xunit v3 (4.0.0-pre.81) is SkipTestWithoutData, not SkipWhenEmpty. Update both the test and the NativeAOT attribute stub. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
ConditionalTheory without conditions is obsolete in xunit v3. The class already has ConditionalClass gating execution, so plain Theory suffices. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xunit v3 rejects null values in theory data arguments. Split the Ctor_Exception theory into two separate Fact tests: one for the null case and one for the non-null exception with a custom HResult. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ActiveIssueAttribute now extends BeforeAfterTestAttribute instead of plain Attribute. This allows it to intercept test execution and skip tests at runtime when conditions match (e.g., IsNativeAot). Previously, tests with [Fact] + [ActiveIssue(..., IsNativeAot)] were discovered by the AOT source generator (via [Fact]) but not skipped (since [ActiveIssue] was a no-op stub), causing failures. The condition evaluation handles: - Type + member name conditions (via reflection) - TestPlatforms flags (via OperatingSystem.IsXxx()) - TargetFrameworkMonikers and TestRuntimes flags Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xunit v3 changes test execution order, which changes the shared
static Random state. This causes (-100 * s_random.NextDouble()) to
produce -0.0 (when NextDouble() returns 0.0). The test then compares
(-0.0).ToString() ("-0") with BigInteger(0).ToString() ("0"),
which fails since BigInteger has no negative zero concept.
Skip the ToString comparison when the expected value is negative zero.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The xunit v3 AOT source generator instantiates BeforeAfterTestAttribute subclasses using a parameterless constructor. Without one, NativeAOT builds fail with CS1729. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ime-governance-docs # Conflicts: # src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj # src/native/managed/cdac/tests/DumpTests/cdac-dump-xplat-test-helix.proj
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The xUnit v3 AOT source generator always instantiates BeforeAfterTestAttribute subclasses via parameterless constructors (new T()), discarding all constructor arguments. This caused ActiveIssueAttribute to unconditionally skip ALL decorated tests with empty 'Active issue:' messages, regardless of the specified platform/ runtime conditions. Fix: Before() now reads the original attribute metadata from the test method, class, and assembly using CustomAttributeData and evaluates the skip conditions from the actual constructor arguments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The browser/wasi smoke test projects were commented out due to XHarness xunit v2 runner incompatibility with xunit v3 test assemblies. However, CI shows the non-smoke browser-wasm library tests (202 work items) run successfully with xunit v3, proving the compatibility issue was resolved. Re-enable the browser smoke test projects (Mono and CoreCLR) and remove the browser/wasi exclusion from System.Runtime.Tests smoke test. This fixes the 'No helix work items' error in browser-wasm smoke CI jobs that occurred because zero test projects were selected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 Copilot Code Review — PR #126277Note This review was generated by GitHub Copilot using Claude Opus 4.6, with additional analysis from Claude Haiku 4.5 and GPT-5.3-Codex. Holistic AssessmentMotivation: This PR fixes a real, significant bug in the NativeAOT xUnit v3 AOT test infrastructure. The xUnit v3 AOT source generator always instantiates Approach: The fix uses Summary: Detailed Findings✅ CustomAttributeData Parsing — Correct for all overloadsThe
Verified by all three models (Opus 4.6, Haiku 4.5, GPT-5.3-Codex). ✅ ConditionalFact Fix — CorrectThe change from ✅ Metadata Hierarchy Traversal — Thorough
|
The xUnit v3 AOT source generator discovers [Fact]/[Theory] methods inside classes decorated with [ConditionalClass], but ConditionalClassAttribute is a no-op stub in NativeAOT mode. This causes COM interop tests to run on NativeAOT where they crash with SIGSEGV. Use the xUnit v3 built-in SkipUnless property on each [Fact]/[Theory] in ThrowExceptionForHRTests, GetExceptionForHRTests, and GetExceptionCodeTests so these tests are properly skipped at runtime when running on NativeAOT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ConditionalClass is a no-op stub in NativeAOT mode, causing tests that should be skipped to run and crash (SIGSEGV on arm64). Replace all ~214 usages with Assert.SkipUnless calls in constructors, which works correctly in both regular and NativeAOT test execution. For static test classes (e.g. ParallelQueryCombinationTests), inject Assert.SkipUnless at the start of each test method since static classes have no instance constructor. Also removes ConditionalClassAttribute from AttributeStubs.cs entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Note
This PR was created with the assistance of GitHub Copilot.
This PR ports the test-only content from #125019 — moving libraries tests from xunit v2 to xunit v3. Production code is intentionally left unchanged.
Description
Key changes include:
eng/Versions.props,eng/testing/xunit/): Updates xunit dependencies from v2 to v3 packagesDirectory.Build.targets,eng/testing/): Adds UseAppHost overrides and build validation for xunit v3 test projectsNuGet.config): Adds nuget.org feed for xunit v3 packageseng/testing/RunnerTemplate.sh,eng/testing/RunnerTemplate.cmd): Updates test execution to use xunit v3 runnersrc/libraries/sendtohelix-browser.targets,src/libraries/sendtohelix-wasi.targets): Updates xunit trait filter syntax (-notrait→-trait-) for xunit v3 compatibilitysrc/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs): Updates for xunit v3 in-process runner APIs withAssemblyMetadata(3, ...)for NativeAOT compatibilityeng/testing/tests.singlefile.targets): Disables xunit auto-generated entry point for NativeAOT tests (uses SingleFileTestRunner instead)TheoryData→ typedTheoryData<T>with.DataaccessorIAsyncLifetimeadjustmentsAssert.ThrowsAsyncpattern updatesthrow SkipTestException→Assert.SkipUnless/Assert.SkipWhen/Assert.Skip)ifconditions were incorrectly converted toAssert.SkipUnless/Assert.SkipWhenwithout properly applying De Morgan's law:HttpClientHandlerTest.Authentication.cs:if (!A || !B) throw Skip→Assert.SkipUnless(A && B)(was incorrectlyA || !B)HttpClientHandlerTest.Headers.cs:if (!A && B) throw Skip→Assert.SkipWhen(!A && B)(was incorrectlyAssert.SkipUnless(A && B))TextWriterTests.cs(2 instances):if (!A && !B) throw Skip→Assert.SkipUnless(A || B)(was incorrectlyA && !B)BoundedChannelTests.cs:if (!A && !B) throw Skip→Assert.SkipUnless(A || B)(was incorrectlyA && !B)RendezvousChannelTests.cs:if (!A && !B) throw Skip→Assert.SkipUnless(A || B)(was incorrectlyA && !B)docs/workflow/testing/libraries/xunit3-migration.md): Adds migration guide for common xunit v2→v3 patternsAll changes to production/source code (coreclr JIT, nativeaot CoreLib, System.Text.RegularExpressions, native libs, AndroidAppBuilder) have been reverted per reviewer feedback. Only test code, test infrastructure, and documentation changes remain.
See #125019 for full context and discussion.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.