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>
This comment has been minimized.
This comment has been minimized.
Instead of excluding System.Runtime.Tests from all TargetsMobile, only exclude from Apple (crashes) and browser/wasi (xunit v2 error). Android does not crash — it runs 0 tests gracefully. Revert sendtohelixhelp.proj change (RunSmokeTestsOnly not available in Helix send context). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The iOS-specific ItemGroups at lines 799 and 808 of tests.proj unconditionally included System.Runtime.Tests for iOS builds with ArchiveTests=true. This bypassed the SmokeTestProject flow which properly excludes System.Runtime.Tests on Apple platforms (due to XHarness xunit v2 incompatibility with xunit v3). Add Condition="'$(RunSmokeTestsOnly)' != 'true'" to the System.Runtime.Tests ProjectReference includes in both ItemGroups. When RunSmokeTestsOnly=true, the SmokeTestProject items at line 584 (which have proper TargetOS exclusion conditions) control which tests are included. The iOS functional tests (CoreCLR Interpreter/R2R) in the same ItemGroups remain included since they don't use XHarness test runners and pass successfully. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The xunit v3 AOT source generator emits MemberData factory code that references open type parameters (e.g. ICollection_Generic_Tests<T>) in non-generic generated classes, causing CS0246 errors. Fix by: - Adding MemberType = typeof(TestBase) to MemberData attributes so the generator references the non-generic declaring type - Moving EnumerableTestData, ListTestData, GetEnumerableTestData, and SetTestData from generic TestBase<T> to non-generic TestBase (they don't use T) - Creating CollectionTestData class for project-specific data methods (IndexOfTestData, ValidCollectionSizes_GreaterThanOne, etc.) that were on generic classes but don't use the type parameter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix CS0246 for System.IO.FileSystem.Tests NativeAOT build: - Move GetSyncAsyncOptions from generic RandomAccess_Base<T> to FileSystemTest - Add MemberType=typeof(FileSystemTest) for TrailingCharacters in InfoGetSetAttributes<T> - Add MemberType=typeof(FileSystemTest) for GetSyncAsyncOptions in RandomAccess_Base<T> Re-enable NativeAOT smoke tests that build+link successfully: - System.Collections.Tests (CS0246 fixed in prior commit) - System.IO.FileSystem.Tests (CS0246 fixed in this commit) - System.Runtime.Tests (no AOT errors) - System.Runtime.Intrinsics.Tests (no AOT errors) - System.Threading.Tests (no AOT errors) - System.Numerics.Vectors.Tests (no AOT errors) - System.Runtime.InteropServices.Tests (no AOT errors) Still disabled (3 of 11): - System.IO.Compression.Tests (pre-existing CS0246 — new encoder/decoder types) - System.Linq.Tests (ILC crash, exit code 134) - System.Linq.Expressions.Tests (CS0619 obsolete DataAttribute.GetData) - System.Reflection.Tests (CS0122/CS1525 non-public nested types) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Work around xunit v3 AOT source generator issues: - Linq.Expressions: add XUNIT_AOT conditional compilation for custom DataAttribute subclasses (PerCompilationTypeAttribute, InlinePerCompilationTypeAttribute) that call obsolete GetData (CS0619) - Reflection: remove default parameter value causing CS4010/CS0103, convert multidimensional array typeof() InlineData to MemberData (CS0270/CS1525), make protected nested types public (CS0122) - Re-enable both projects in NativeAOT smoke tests (10 of 11 enabled) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
- Make RSNoCtor/RSCtor ref structs public (CS0122 in generated code) - Make SignatureTypeTests.GenericType<T> public (CS0122 in generated code) - Conditionally exclude [Trait] attribute in AOT mode (CS0117: FactTestCaseFactory does not contain a definition for 'Traits') Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ime-governance-docs # Conflicts: # src/libraries/Microsoft.Extensions.Options/tests/Microsoft.Extensions.Options.Tests/Microsoft.Extensions.Options.Tests.csproj # src/libraries/Microsoft.Win32.SystemEvents/tests/Microsoft.Win32.SystemEvents.Tests.csproj # src/libraries/System.Collections/tests/System.Collections.Tests.csproj # src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj # src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj # src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj # src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj # src/libraries/System.Linq.Queryable/tests/System.Linq.Queryable.Tests.csproj # src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj # src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj # src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj # src/libraries/System.Net.WebProxy/tests/System.Net.WebProxy.Tests.csproj # src/libraries/System.Reflection.DispatchProxy/tests/System.Reflection.DispatchProxy.Tests.csproj # src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj # src/libraries/System.Reflection.TypeExtensions/tests/System.Reflection.TypeExtensions.Tests.csproj # src/libraries/System.Runtime/tests/System.Runtime.InteropServices.RuntimeInformation.Tests/System.Runtime.InteropServices.RuntimeInformation.Tests.csproj
…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>
🤖 Copilot Code Review — PR #126277Note This review was generated by GitHub Copilot using multi-model analysis (Claude Opus 4.6 primary + GPT-5.3-Codex cross-review + two specialized Haiku sub-agents for infrastructure and test code). Holistic AssessmentMotivation: Migrating library tests from xunit v2 to xunit v3 is a necessary infrastructure investment. xunit v3 drops the separate console runner in favor of self-hosted executables (MTP), adds Approach: The approach is generally sound — moving package references from xunit v2 to v3, converting Summary: Detailed Findings❌ Placeholder
|
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.