Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET MAUI support? #297

Open
mrlacey opened this issue Feb 4, 2025 · 3 comments
Open

.NET MAUI support? #297

mrlacey opened this issue Feb 4, 2025 · 3 comments

Comments

@mrlacey
Copy link

mrlacey commented Feb 4, 2025

Apparently, .NET MAUI projects are not supported. (stryker-mutator/stryker-net#3181 (comment))
Is this a known issue?
Are there plans to support it?
Is this documented anywhere?

@slang25
Copy link
Contributor

slang25 commented Feb 5, 2025

I've had a little test with Buildalyzer and StrykerBugRepro, it looks like it will build with Buildalyzer, but only if the net9.0 tfm is specified with the TargetFramework property. I'm testing it like this:

var analyzer = manager.GetProject(path);
var envFactory = new EnvironmentFactory(manager, analyzer.ProjectFile);
var buildEnv =  envFactory.GetBuildEnvironment("net9.0", new EnvironmentOptions
{
    GlobalProperties = { ["TargetFramework"] = "net9.0" } // omitting this fails the build
});
var results = analyzer.Build(buildEnv!);
results.OverallSuccess.ShouldBeTrue();

I'm not sure if Buildalyzer should set this property automatically or if stryker should pass it in, however if I delete the platform specific TFMs from the MAUI app, then stryker gets past the initial build, but now it fails on the mutations compilation with:

Stryker.NET encountered a compile error in .../StrykerBugRepro/StrykerBugRepro/App.xaml.cs (at 5:9) with message: The name 'InitializeComponent' does not exist in the current context (Source code: InitializeComponent)

I'm not sure what's happening here to be honest.

@slang25
Copy link
Contributor

slang25 commented Feb 5, 2025

So to break this into actionable things:

  • When Stryker detects a multi-TFM project with a single TFM test project, it should use the test project TFM (passing that to Buildalyzer)
  • Buildalyzer should probably set the TargetFramework property automatically so that multi-target projects build just the requested TFM
  • Buildalyzer shouldn't fail for multi-target builds anyway, even though this isn't what you want to build with Stryker, Buildalyzer should not freak out because of an unexpected output for native TFMs. Specifically here I'm seeing the maccatalyst build fail, and I think this is because the build is doing more stuff, like running the linker, but it's partly a design-time build so the linker fails (as there is no built dll), so I think if we want MAUI builds to work seamlessly for all TFMs (which isn't what you want here for Stryker, but could still be useful to someone) then we should have Buildalyzer detect the native TFMs and disable design-time build settings.
  • That last issue with InitializeComponent needs investigating, I think this might be a Stryker issue (although not sure)

@slang25
Copy link
Contributor

slang25 commented Feb 6, 2025

Ok, so I went to add the target framework change I mentioned above (bullet point 2), and it's actually already a thing. There is a Build overload that takes a TFM, so if I do this:

var analyzer = manager.GetProject(path);
var results = analyzer.Build("net9.0");
results.OverallSuccess.ShouldBeTrue();

it also passes. So this will be a change that Stryker can implement. I'll take a quick look at that now 👀

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

No branches or pull requests

2 participants