Skip to content

Conversation

mandel-macaque
Copy link
Member

Port the rgen tests to xunit 3 to improve the devloop by allowing to perform several asserts in a single exception. This allows to be able to assert all the fields of a struct making working with failed asserts in complex structs much easier. To achieve that we had to:

  1. Port to xunit3 to be able to access the test current context to deal with multiple asserts. This includes updating our custom attributes.
  2. Update all async methods to use the test context cancelation token, should $make tests more reliable when we are using async. The xunit analyzer was screaming at us.
  3. Add some methods to test complex structs (more to come).

This will make working with the rgen tests a lot easier when they fail.

Port the rgen tests to xunit 3 to improve the devloop by allowing to
perform several asserts in a single exception. This allows to be able to
assert all the fields of a struct making working with failed asserts in
complex structs much easier. To achieve that we had to:

1. Port to xunit3 to be able to access the test current context to deal with
   multiple asserts. This includes updating our custom attributes.
2. Update all async methods to use the test context cancelation token, should
   $make tests more reliable when we are using async. The xunit analyzer
   was screaming at us.
3. Add some methods to test complex structs (more to come).

This will make working with the rgen tests a lot easier when they fail.
Copy link
Contributor

@Copilot 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 updates the rgen test projects to use xUnit 3 to improve the developer workflow by enabling multiple assertions to be checked in a single test failure. The main changes include migrating from xUnit 2 to xUnit 3, updating async methods to use test context cancellation tokens, and adding helper methods for testing complex structures.

Key Changes

  • Migration from xUnit 2 to xUnit 3 with updated test attributes and framework usage
  • Addition of cancellation token support for all async test operations using TestContext.Current.CancellationToken
  • Introduction of custom assertion methods (AssertEx) for multi-scope testing of complex structures

Reviewed Changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/rgen/xunit.runner.json Configuration file for xUnit runner settings
tests/rgen//Microsoft..Tests.csproj Updated package references from xUnit 2 to xUnit 3
tests/rgen/Microsoft.Macios.Generator.Tests/AssertEx.cs New custom assertion class with multi-scope testing capabilities
tests/rgen/Directory.Build.props Centralized package version management for test projects
tests/common/ConfigurationXUnit.cs Updated test data attributes for xUnit 3 compatibility
tests/rgen/**/*Tests.cs Updated test methods to use cancellation tokens with Roslyn APIs
src/rgen/Microsoft.Macios.Generator/Availability/*.cs Minor refactoring of availability system properties
src/rgen/Microsoft.Macios.Generator/DictionaryComparer.cs Updated generic constraints for readonly dictionary support
src/rsp/dotnet/*-defines-dotnet.rsp Added new framework defines for platform support
Comments suppressed due to low confidence (1)

src/rgen/Microsoft.Macios.Generator/Availability/PlatformAvailability.cs:1

  • This line declares a variable x that is assigned but never used. It should be removed as it serves no purpose.
// Copyright (c) Microsoft Corporation.


try {
Assert.True (condition);
} catch (EqualException ex) {
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The catch block catches EqualException but Assert.True throws TrueException when the condition is false, not EqualException. This should catch TrueException instead.

Suggested change
} catch (EqualException ex) {
} catch (TrueException ex) {

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@mandel-macaque mandel-macaque force-pushed the dev/mandel/xunit-3-bump-rgen branch from 37707a0 to 7d0c01b Compare September 24, 2025 16:06
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #eca1685] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #eca1685] Build passed (Build packages) ✅

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

MethodInfo testMethod,
DisposalTracker disposalTracker)
{
var classInstance = Activator.CreateInstance (dataAttributeType);
Copy link
Member

Choose a reason for hiding this comment

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

This would be more AOT-friendly, unless I'm missing why it wouldn't work:

Suggested change
var classInstance = Activator.CreateInstance (dataAttributeType);
var classInstance = new T ();

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #eca1685] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #eca1685] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #eca1685] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #eca1685] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #eca1685] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #eca1685] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #eca1685] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

2 tests crashed, 2 tests failed, 101 tests passed.

Failures

❌ generator tests

1 tests failed, 4 tests passed.
  • Roslyn Codefixers tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

❌ introspection tests

🔥 Failed catastrophically on VSTS: test results - introspection (no summary found).

Html Report (VSDrops) Download

❌ monotouch tests (iOS)

🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found).

Html Report (VSDrops) Download

❌ xcframework tests

1 tests failed, 3 tests passed.
  • xcframework-test/tvOS - simulator/Debug: Crashed

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: eca1685d39faafcaad1943af044c8bfabfdf4859 [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants