Skip to content

test: Mark test projects as AOT compatible and switch to xunit.v3.aot with MTP testrunner - #297

Merged
ralfbiedert merged 2 commits into
ralfbiedert:masterfrom
OleRoss:fix/disable-runtime-marshalling
Jul 17, 2026
Merged

test: Mark test projects as AOT compatible and switch to xunit.v3.aot with MTP testrunner #297
ralfbiedert merged 2 commits into
ralfbiedert:masterfrom
OleRoss:fix/disable-runtime-marshalling

Conversation

@OleRoss

@OleRoss OleRoss commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This is the first step to introduce the fixes necessary for #293.

The final goal is to add DisableRuntimeMarshalling to all the test projects. However, when I did that, additional issues arose from, e.g., function pointers that depended on runtime marshaling as well, not just the Vec<T> use case in #293.

Therefore, I decided to split the work into multiple smaller PRs and start with a common foundation: The AOT-compatible test project.

I migrated to xunit.v3.aot (still in prerelease) and fixed some warnings. The AOT package requires the new MicrosoftTestingPlatform, which is why some of the dotnet test commands were adjusted.

Note: I did not want to change the CI, so the tests still run normally in the CI. I only published and ran them locally.

@OleRoss
OleRoss marked this pull request as ready for review July 16, 2026 12:06
Comment thread global.json

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is this?

@OleRoss OleRoss Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This configures the dotnet test to use the new MTP runner.

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

You can find the related documentation from Microsoft here.

From what I understand from the xunit.v3 aot docs, it should be possible to continue using VSTest, but since it's the default, I think it makes sense to use MTP all the way.

Edit: I tried to move it into the C# crate, but if you run dotnet test from the repo root, it has no effect, so it should stay there, unfortunately.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ah, actually, would it work wrapping the C# runner via a just command and then make it pick up the file from a C#-related path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you mean moving the global.json file to crates/backend_csharp and then modifying the just file to

    cd crates/backend_csharp && dotnet test --project tests/reference_project/Tests/Tests.csproj

? That should be possible as well, I think

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, something to the effect. I think it's ugly if a random backend litters the crate root for unit tests.

@OleRoss
OleRoss force-pushed the fix/disable-runtime-marshalling branch from 75ecad5 to 9594953 Compare July 17, 2026 10:25
@ralfbiedert

Copy link
Copy Markdown
Owner

Thanks!

@ralfbiedert
ralfbiedert merged commit b87299a into ralfbiedert:master Jul 17, 2026
4 checks passed
@ralfbiedert

Copy link
Copy Markdown
Owner

I migrated to xunit.v3.aot (still in prerelease) and fixed some warnings. The AOT package requires the new MicrosoftTestingPlatform, which is why some of the dotnet test commands were adjusted.

FYI, this seems to have broken Rider unit testing; no unit tests are detected anymore for me, e.g., here should be a "Run Test" marker:

image

@OleRoss

OleRoss commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Hi, can you try to "Enable Testing Platform support"?
image

It works for me

@ralfbiedert

Copy link
Copy Markdown
Owner

Yes, worked, thanks a lot!

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.

2 participants