diff --git a/.generated.NoMobile.sln b/.generated.NoMobile.sln
index e212ca2dd2..45e1b1caa9 100644
--- a/.generated.NoMobile.sln
+++ b/.generated.NoMobile.sln
@@ -103,14 +103,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6987A1CC-6
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidTestApp", "test\AndroidTestApp\AndroidTestApp.csproj", "{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MauiTestUtils", "MauiTestUtils", "{A11512A4-26BD-4936-B7A6-6FCE2E78FA80}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests.Runners.SourceGen", "test\MauiTestUtils\DeviceTests.Runners.SourceGen\TestUtils.DeviceTests.Runners.SourceGen.csproj", "{7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests.Runners", "test\MauiTestUtils\DeviceTests.Runners\TestUtils.DeviceTests.Runners.csproj", "{1C6F1CB1-2339-4E8B-9941-80998B940DCC}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests", "test\MauiTestUtils\DeviceTests\TestUtils.DeviceTests.csproj", "{E92F0A4E-2653-4341-8732-2AC9CF766739}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Android.AssemblyReader.Tests", "test\Sentry.Android.AssemblyReader.Tests\Sentry.Android.AssemblyReader.Tests.csproj", "{3C543CED-F801-4843-BA48-76142843E1B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNet.Tests", "test\Sentry.AspNet.Tests\Sentry.AspNet.Tests.csproj", "{7ABAA536-7BEC-46D7-9C61-82440DDC9AA8}"
@@ -178,6 +170,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{233D34AB-9
README.md = README.md
CHANGELOG.md = CHANGELOG.md
CONTRIBUTING.md = CONTRIBUTING.md
+ Directory.Build.props = Directory.Build.props
+ Directory.Build.targets = Directory.Build.targets
+ global.json = global.json
+ nuget.config = nuget.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.Blazor.WebAssembly", "src\Sentry.AspNetCore.Blazor.WebAssembly\Sentry.AspNetCore.Blazor.WebAssembly.csproj", "{8298202C-9983-4D0A-851D-805539EE481A}"
@@ -372,18 +368,6 @@ Global
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Release|Any CPU.Build.0 = Release|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Release|Any CPU.Build.0 = Release|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Release|Any CPU.Build.0 = Release|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Release|Any CPU.Build.0 = Release|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -559,10 +543,6 @@ Global
{854EBD1B-73EE-4B93-89DF-E70436FF14CB} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{5F253D7F-BF27-46F5-9382-73A66EC247BF} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
- {A11512A4-26BD-4936-B7A6-6FCE2E78FA80} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
- {E92F0A4E-2653-4341-8732-2AC9CF766739} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
{3C543CED-F801-4843-BA48-76142843E1B9} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{7ABAA536-7BEC-46D7-9C61-82440DDC9AA8} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{D7D1EA68-ACE3-4DF3-A33C-EBB5B74701F5} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
diff --git a/.github/workflows/device-tests-android.yml b/.github/workflows/device-tests-android.yml
index 9cfd9ae645..bdd90b5f5d 100644
--- a/.github/workflows/device-tests-android.yml
+++ b/.github/workflows/device-tests-android.yml
@@ -51,8 +51,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- # These are all a bit flaky. We used to run versions 27-31... now we just run 27 and 31
- api-level: [27, 31]
+ # We run against both an older and a newer API
+ api-level: [27, 33]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
diff --git a/Sentry-CI-Build-macOS.slnf b/Sentry-CI-Build-macOS.slnf
index 876cfd1d69..cc40fdf79f 100644
--- a/Sentry-CI-Build-macOS.slnf
+++ b/Sentry-CI-Build-macOS.slnf
@@ -67,6 +67,7 @@
"test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj",
"test\\Sentry.Hangfire.Tests\\Sentry.Hangfire.Tests.csproj",
"test\\Sentry.Log4Net.Tests\\Sentry.Log4Net.Tests.csproj",
+ "test\\Sentry.Maui.Device.TestApp\\Sentry.Maui.Device.TestApp.csproj",
"test\\Sentry.Maui.Tests\\Sentry.Maui.Tests.csproj",
"test\\Sentry.NLog.Tests\\Sentry.NLog.Tests.csproj",
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
diff --git a/Sentry.sln b/Sentry.sln
index e212ca2dd2..45e1b1caa9 100644
--- a/Sentry.sln
+++ b/Sentry.sln
@@ -103,14 +103,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6987A1CC-6
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidTestApp", "test\AndroidTestApp\AndroidTestApp.csproj", "{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MauiTestUtils", "MauiTestUtils", "{A11512A4-26BD-4936-B7A6-6FCE2E78FA80}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests.Runners.SourceGen", "test\MauiTestUtils\DeviceTests.Runners.SourceGen\TestUtils.DeviceTests.Runners.SourceGen.csproj", "{7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests.Runners", "test\MauiTestUtils\DeviceTests.Runners\TestUtils.DeviceTests.Runners.csproj", "{1C6F1CB1-2339-4E8B-9941-80998B940DCC}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtils.DeviceTests", "test\MauiTestUtils\DeviceTests\TestUtils.DeviceTests.csproj", "{E92F0A4E-2653-4341-8732-2AC9CF766739}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Android.AssemblyReader.Tests", "test\Sentry.Android.AssemblyReader.Tests\Sentry.Android.AssemblyReader.Tests.csproj", "{3C543CED-F801-4843-BA48-76142843E1B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNet.Tests", "test\Sentry.AspNet.Tests\Sentry.AspNet.Tests.csproj", "{7ABAA536-7BEC-46D7-9C61-82440DDC9AA8}"
@@ -178,6 +170,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{233D34AB-9
README.md = README.md
CHANGELOG.md = CHANGELOG.md
CONTRIBUTING.md = CONTRIBUTING.md
+ Directory.Build.props = Directory.Build.props
+ Directory.Build.targets = Directory.Build.targets
+ global.json = global.json
+ nuget.config = nuget.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.Blazor.WebAssembly", "src\Sentry.AspNetCore.Blazor.WebAssembly\Sentry.AspNetCore.Blazor.WebAssembly.csproj", "{8298202C-9983-4D0A-851D-805539EE481A}"
@@ -372,18 +368,6 @@ Global
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A}.Release|Any CPU.Build.0 = Release|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779}.Release|Any CPU.Build.0 = Release|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC}.Release|Any CPU.Build.0 = Release|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E92F0A4E-2653-4341-8732-2AC9CF766739}.Release|Any CPU.Build.0 = Release|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C543CED-F801-4843-BA48-76142843E1B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -559,10 +543,6 @@ Global
{854EBD1B-73EE-4B93-89DF-E70436FF14CB} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{5F253D7F-BF27-46F5-9382-73A66EC247BF} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{99E2D1A4-1853-49F9-96B6-59C70FA3DE3A} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
- {A11512A4-26BD-4936-B7A6-6FCE2E78FA80} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
- {7C1A1318-137E-4E1E-ADB3-C0CE2B10F779} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
- {1C6F1CB1-2339-4E8B-9941-80998B940DCC} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
- {E92F0A4E-2653-4341-8732-2AC9CF766739} = {A11512A4-26BD-4936-B7A6-6FCE2E78FA80}
{3C543CED-F801-4843-BA48-76142843E1B9} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{7ABAA536-7BEC-46D7-9C61-82440DDC9AA8} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{D7D1EA68-ACE3-4DF3-A33C-EBB5B74701F5} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
diff --git a/SentryMobile.slnf b/SentryMobile.slnf
index e20fae4d84..b5d76fafbd 100644
--- a/SentryMobile.slnf
+++ b/SentryMobile.slnf
@@ -12,9 +12,6 @@
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
"src\\Sentry.Maui\\Sentry.Maui.csproj",
"src\\Sentry\\Sentry.csproj",
- "test\\MauiTestUtils\\DeviceTests.Runners.SourceGen\\TestUtils.DeviceTests.Runners.SourceGen.csproj",
- "test\\MauiTestUtils\\DeviceTests.Runners\\TestUtils.DeviceTests.Runners.csproj",
- "test\\MauiTestUtils\\DeviceTests\\TestUtils.DeviceTests.csproj",
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
"test\\Sentry.Maui.Device.TestApp\\Sentry.Maui.Device.TestApp.csproj",
diff --git a/nuget.config b/nuget.config
index 48792e6dcb..aec3c1420a 100644
--- a/nuget.config
+++ b/nuget.config
@@ -8,6 +8,9 @@
+
+
+
@@ -26,5 +29,8 @@
+
+
+
diff --git a/scripts/generate-solution-filters-config.yaml b/scripts/generate-solution-filters-config.yaml
index 5af0c03ff0..adc0d61fd6 100644
--- a/scripts/generate-solution-filters-config.yaml
+++ b/scripts/generate-solution-filters-config.yaml
@@ -53,7 +53,6 @@ filterConfigs:
patterns:
- "**/*AndroidTestApp.csproj"
- "**/*DeviceTests*.csproj"
- - "**/*Maui.Device.TestApp.csproj"
- "**/*SourceGen.csproj"
- "**/Sentry.Samples.Android.csproj"
@@ -159,7 +158,6 @@ filterConfigs:
- "test/**/Sentry.Maui.Tests.csproj"
- "test/**/Sentry.Testing.csproj"
- "test/**/Sentry.Tests.csproj"
- - "test/MauiTestUtils/**/*.csproj"
- outputPath: SentryNoMobile.slnf
solution: .generated.NoMobile.sln
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/AnalyzerReleases.Shipped.md b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/AnalyzerReleases.Shipped.md
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/AnalyzerReleases.Unshipped.md b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/AnalyzerReleases.Unshipped.md
deleted file mode 100644
index 4a4a177305..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/AnalyzerReleases.Unshipped.md
+++ /dev/null
@@ -1,5 +0,0 @@
-### New Rules
-
-Rule ID | Category | Severity | Notes
---------|----------|----------|--------------------
-TST1001 | Logging | Info | Logging messages
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/CodeBehindGenerator.cs b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/CodeBehindGenerator.cs
deleted file mode 100644
index 6272f898ca..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/CodeBehindGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Microsoft.CodeAnalysis;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.SourceGen;
-
-[Generator]
-public class CodeBehindGenerator : ISourceGenerator
-{
- public void Initialize(GeneratorInitializationContext context)
- {
- //#if DEBUG
- //if (!System.Diagnostics.Debugger.IsAttached)
- // System.Diagnostics.Debugger.Launch();
- //#endif
- }
-
- public void Execute(GeneratorExecutionContext context)
- {
- if (!context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.TargetFramework", out var targetFramework))
- return;
-
- context.Log($"TargetFramework: {targetFramework}");
-
- var generator = new RunnerGenerator(context, targetFramework);
-
- generator?.Generate();
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/GeneratorDiagnostics.cs b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/GeneratorDiagnostics.cs
deleted file mode 100644
index a017ed449b..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/GeneratorDiagnostics.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Diagnostics;
-using Microsoft.CodeAnalysis;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.SourceGen;
-
-internal static class GeneratorDiagnostics
-{
- public static readonly DiagnosticDescriptor LoggingMessage = new DiagnosticDescriptor(
- id: "TST1001",
- title: "Logging Message",
- messageFormat: "{0}",
- category: "Logging",
- DiagnosticSeverity.Info,
- isEnabledByDefault: true);
-
- [Conditional("DEBUG")]
- public static void Log(this GeneratorExecutionContext context, string message) =>
- context.ReportDiagnostic(Diagnostic.Create(LoggingMessage, Location.None, message));
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/RunnerGenerator.cs b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/RunnerGenerator.cs
deleted file mode 100644
index 651f21a25a..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/RunnerGenerator.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-using System;
-using System.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.SourceGen;
-
-public class RunnerGenerator
-{
- public RunnerGenerator(GeneratorExecutionContext context, string targetFramework)
- {
- Context = context;
-
- TargetFramework = targetFramework;
-
- context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.ApplicationId", out var applicationId);
- context.Log($"ApplicationId: {applicationId}");
- ApplicationId = applicationId ?? throw new Exception("ApplicationId needs to be set.");
-
- context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.ApplicationTitle", out var applicationTitle);
- context.Log($"ApplicationTitle: {applicationTitle}");
- ApplicationTitle = applicationTitle ?? "Tests";
-
- context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.RootNamespace", out var rootNamespace);
- context.Log($"RootNamespace: {rootNamespace}");
- RootNamespace = rootNamespace ?? "TestRunnerNamespace";
-
- ContainsSplashScreen = false;
- foreach (var file in context.AdditionalFiles)
- {
- var options = context.AnalyzerConfigOptions.GetOptions(file);
- if (options.TryGetValue("build_metadata.AdditionalFiles.IsMauiSplashScreen", out var isMauiSplashScreen) && bool.TryParse(isMauiSplashScreen, out var isSplash) && isSplash)
- {
- ContainsSplashScreen = true;
- break;
- }
- }
- context.Log($"ContainsSplashScreen: {ContainsSplashScreen}");
- }
-
- public GeneratorExecutionContext Context { get; }
-
- public string TargetFramework { get; }
-
- public string RootNamespace { get; }
-
- public string ApplicationId { get; }
-
- public string ApplicationTitle { get; }
-
- public bool ContainsSplashScreen { get; }
-
- public void Generate()
- {
- Context.Log($"Generating runners...");
-
- if (TargetFramework.IndexOf("-android", StringComparison.OrdinalIgnoreCase) != -1)
- {
- var code = GenerateAndroidSource();
- var name = "TestRunner.Android.sg.cs";
-
- AddSource(name, code);
- }
- else if (TargetFramework.IndexOf("-ios", StringComparison.OrdinalIgnoreCase) != -1)
- {
- var code = GenerateIosSource();
- var name = "TestRunner.iOS.sg.cs";
-
- AddSource(name, code);
- }
- else if (TargetFramework.IndexOf("-maccatalyst", StringComparison.OrdinalIgnoreCase) != -1)
- {
- var code = GenerateIosSource();
- var name = "TestRunner.MacCatalyst.sg.cs";
-
- AddSource(name, code);
- }
- }
-
- protected void AddSource(string filename, string contents)
- {
- Context.Log($"AddSource: {filename}");
- Context.AddSource(filename, SourceText.From(contents, Encoding.UTF8));
- }
-
- private string GenerateAndroidSource()
- {
- var mauiProgramName = "MauiProgram";
- var mauiProgramFullName = @"global::" + RootNamespace + "." + mauiProgramName;
- var splash = ContainsSplashScreen ? @"Theme = ""@style/Maui.SplashTheme""," : "";
-
- var appName = "MainApplication";
- var visualActivityName = "MainActivity";
-
- var instrumentationName = "TestInstrumentation";
- var headlessActivityName = "TestActivity";
-
- return @"
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_APPLICATION_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Android.App.Application]
- partial class " + appName + @" : global::Microsoft.Maui.MauiApplication
- {
- public " + appName + @"(global::System.IntPtr handle, global::Android.Runtime.JniHandleOwnership ownership)
- : base(handle, ownership)
- {
- }
-
- protected override global::Microsoft.Maui.Hosting.MauiApp CreateMauiApp() => " + mauiProgramFullName + @".CreateMauiApp();
- }
-}
-#endif
-
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_ACTIVITY_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Android.App.Activity(
- " + splash + @"
- MainLauncher = true,
- ConfigurationChanges =
- global::Android.Content.PM.ConfigChanges.ScreenSize |
- global::Android.Content.PM.ConfigChanges.Orientation |
- global::Android.Content.PM.ConfigChanges.UiMode |
- global::Android.Content.PM.ConfigChanges.ScreenLayout |
- global::Android.Content.PM.ConfigChanges.SmallestScreenSize)]
- partial class " + visualActivityName + @" : global::Microsoft.Maui.MauiAppCompatActivity
- {
- }
-}
-#endif
-
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_INSTRUMENTATION_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Android.App.Instrumentation(Name = """ + ApplicationId + "." + instrumentationName + @""")]
- public partial class " + instrumentationName + @" : global::Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner.MauiTestInstrumentation
- {
- protected " + instrumentationName + @"(global::System.IntPtr handle, global::Android.Runtime.JniHandleOwnership transfer)
- : base(handle, transfer)
- {
- }
- }
-}
-#endif
-
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_ACTIVITY_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Android.App.Activity(
- Name = """ + ApplicationId + "." + headlessActivityName + @""",
- Theme = ""@style/Maui.MainTheme.NoActionBar"",
- ConfigurationChanges =
- global::Android.Content.PM.ConfigChanges.ScreenSize |
- global::Android.Content.PM.ConfigChanges.Orientation |
- global::Android.Content.PM.ConfigChanges.UiMode |
- global::Android.Content.PM.ConfigChanges.ScreenLayout |
- global::Android.Content.PM.ConfigChanges.SmallestScreenSize)]
- public partial class " + headlessActivityName + @" : global::Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner.MauiTestActivity
- {
- }
-}
-#endif
-";
- }
-
- private string GenerateIosSource()
- {
- var mauiProgramName = "MauiProgram";
- var mauiProgramFullName = @"global::" + RootNamespace + "." + mauiProgramName;
- var visualDelegateName = "VisualRunnerAppDelegate";
- var headlessDelegateName = "HeadlessRunnerAppDelegate";
-
- return @"
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_ENTRYPOINT_GENERATION && !SKIP_RUNNER_PROGRAM_GENERATION
-namespace " + RootNamespace + @"
-{
- partial class Program
- {
- static void Main(global::System.String[] args)
- {
-#if !SKIP_HEADLESS_RUNNER_APP_DELEGATE_GENERATION
- if (global::Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner.MauiTestApplicationDelegate.IsHeadlessRunner(args))
- {
- global::UIKit.UIApplication.Main(args, null, typeof(global::" + RootNamespace + @"." + headlessDelegateName + @"));
- }
- else
-#endif
- {
-#if !SKIP_VISUAL_RUNNER_APP_DELEGATE_GENERATION
- global::UIKit.UIApplication.Main(args, null, typeof(global::" + RootNamespace + @"." + visualDelegateName + @"));
-#endif
- }
- }
- }
-}
-#endif
-
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_ENTRYPOINT_GENERATION && !SKIP_VISUAL_RUNNER_APP_DELEGATE_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Foundation.Register(""" + visualDelegateName + @""")]
- partial class " + visualDelegateName + @" : global::Microsoft.Maui.MauiUIApplicationDelegate
- {
- protected override global::Microsoft.Maui.Hosting.MauiApp CreateMauiApp() => " + mauiProgramFullName + @".CreateMauiApp();
- }
-}
-#endif
-
-#if !SKIP_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_ENTRYPOINT_GENERATION && !SKIP_HEADLESS_RUNNER_APP_DELEGATE_GENERATION
-namespace " + RootNamespace + @"
-{
- [global::Foundation.Register(""" + headlessDelegateName + @""")]
- partial class " + headlessDelegateName + @" : global::Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner.MauiTestApplicationDelegate
- {
-
- protected override global::Microsoft.Maui.Hosting.MauiApp CreateMauiApp() => " + mauiProgramFullName + @".CreateMauiApp();
- }
-}
-#endif
-";
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/TestUtils.DeviceTests.Runners.SourceGen.csproj b/test/MauiTestUtils/DeviceTests.Runners.SourceGen/TestUtils.DeviceTests.Runners.SourceGen.csproj
deleted file mode 100644
index 928c94c1b9..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners.SourceGen/TestUtils.DeviceTests.Runners.SourceGen.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- netstandard2.0
- enable
- Microsoft.Maui.TestUtils
- Microsoft.Maui.TestUtils.DeviceTests.Runners.SourceGen
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/MauiTestUtils/DeviceTests.Runners/AppHostBuilderExtensions.cs b/test/MauiTestUtils/DeviceTests.Runners/AppHostBuilderExtensions.cs
deleted file mode 100644
index a6916c1caa..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/AppHostBuilderExtensions.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-#nullable enable
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Maui.Controls.Hosting;
-using Microsoft.Maui.Hosting;
-using Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-using Microsoft.Maui.TestUtils.DeviceTests.Runners.VisualRunner;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public static class AppHostBuilderExtensions
-{
- public static MauiAppBuilder ConfigureTests(this MauiAppBuilder appHostBuilder, TestOptions options)
- {
- appHostBuilder.Services.AddSingleton(options);
-
- return appHostBuilder;
- }
-
- public static MauiAppBuilder UseVisualRunner(this MauiAppBuilder appHostBuilder)
- {
- appHostBuilder.UseMauiApp(svc => new MauiVisualRunnerApp(
- svc.GetRequiredService(),
- svc.GetRequiredService().CreateLogger("TestRun")));
-
- return appHostBuilder;
- }
-
- public static MauiAppBuilder UseHeadlessRunner(this MauiAppBuilder appHostBuilder, HeadlessRunnerOptions options)
- {
- appHostBuilder.Services.AddSingleton(options);
-
-#if __ANDROID__ || __IOS__ || MACCATALYST
- appHostBuilder.Services.AddTransient(svc => new HeadlessTestRunner(
- svc.GetRequiredService(),
- svc.GetRequiredService()));
-#endif
-
- return appHostBuilder;
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/Assets/credits.html b/test/MauiTestUtils/DeviceTests.Runners/Assets/credits.html
deleted file mode 100644
index 65a209fcf7..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/Assets/credits.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- xUnit Device Runner
- Copyright © 2015
- Outercurve Foundation
- All rights reserved.
-
-
- Author: Claire Novotny
-
-
- About xUnit
-
-
-
\ No newline at end of file
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/HeadlessTestRunner.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/HeadlessTestRunner.cs
deleted file mode 100644
index cd489fa90d..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/HeadlessTestRunner.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-#nullable enable
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Android.App;
-using Android.OS;
-using Microsoft.DotNet.XHarness.TestRunners.Common;
-using Microsoft.DotNet.XHarness.TestRunners.Xunit;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-internal class HeadlessTestRunner : AndroidApplicationEntryPoint
-{
- private readonly HeadlessRunnerOptions _runnerOptions;
- private readonly TestOptions _options;
- private readonly string _resultsPath;
-
- public HeadlessTestRunner(HeadlessRunnerOptions runnerOptions, TestOptions options)
- {
- _runnerOptions = runnerOptions;
- _options = options;
-
- var cache = Application.Context.CacheDir!.AbsolutePath;
- _resultsPath = Path.Combine(cache, _runnerOptions.TestResultsFilename);
- }
-
- protected override bool LogExcludedTests => true;
-
- public override TextWriter? Logger => null;
-
- public override string TestsResultsFinalPath => _resultsPath;
-
- protected override int? MaxParallelThreads => System.Environment.ProcessorCount;
-
- protected override IDevice Device { get; } = new TestDevice();
-
- protected override IEnumerable GetTestAssemblies() =>
- _options.Assemblies
- .Distinct()
- .Select(assembly =>
- {
- // Android needs this file to "exist" but it uses the assembly actually.
- var path = Path.Combine(Application.Context.CacheDir!.AbsolutePath, assembly.GetName().Name + ".dll");
- if (!File.Exists(path))
- File.Create(path).Close();
-
- return new TestAssemblyInfo(assembly, path);
- });
-
- protected override void TerminateWithSuccess() { }
-
- protected override TestRunner GetTestRunner(LogWriter logWriter)
- {
- var testRunner = base.GetTestRunner(logWriter);
- if (_options.SkipCategories?.Count > 0)
- testRunner.SkipCategories(_options.SkipCategories);
- return testRunner;
- }
-
- public async Task RunTestsAsync()
- {
- var bundle = new Bundle();
-
- TestsCompleted += OnTestsCompleted;
-
- await RunAsync();
-
- TestsCompleted -= OnTestsCompleted;
-
- if (File.Exists(TestsResultsFinalPath))
- bundle.PutString("test-results-path", TestsResultsFinalPath);
-
- if (bundle.GetLong("return-code", -1) == -1)
- bundle.PutLong("return-code", 1);
-
- return bundle;
-
- void OnTestsCompleted(object? sender, TestRunResult results)
- {
- var message =
- $"Tests run: {results.ExecutedTests} " +
- $"Passed: {results.PassedTests} " +
- $"Inconclusive: {results.InconclusiveTests} " +
- $"Failed: {results.FailedTests} " +
- $"Ignored: {results.SkippedTests}";
-
- bundle.PutString("test-execution-summary", message);
-
- bundle.PutLong("return-code", results.FailedTests == 0 ? 0 : 1);
- }
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestActivity.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestActivity.cs
deleted file mode 100644
index bc59b3b583..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestActivity.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-#nullable enable
-using System;
-using System.Threading.Tasks;
-using Android.OS;
-using AndroidX.AppCompat.App;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-public abstract class MauiTestActivity : AppCompatActivity
-{
- public TaskCompletionSource TaskCompletionSource { get; } = new TaskCompletionSource();
-
- protected override void OnCreate(Bundle? savedInstanceState)
- {
- base.OnCreate(savedInstanceState);
-
- // Do the work on the background thread to avoid a keyDispatchingTimedOut ANR
- Task.Run(async () =>
- {
- try
- {
- var runner = MauiTestInstrumentation.Current.Services.GetRequiredService();
-
- var bundle = await runner.RunTestsAsync();
-
- TaskCompletionSource.TrySetResult(bundle);
- }
- catch (Exception ex)
- {
- TaskCompletionSource.TrySetException(ex);
- }
-
- Finish();
- });
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestInstrumentation.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestInstrumentation.cs
deleted file mode 100644
index e3ae2b8d8d..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/Android/MauiTestInstrumentation.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-#nullable enable
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Provider;
-using Android.Runtime;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-public abstract class MauiTestInstrumentation : Instrumentation
-{
- private readonly TaskCompletionSource _waitForApplication = new();
- private Java.Lang.Class _activityClass = null!;
-
- protected MauiTestInstrumentation(IntPtr handle, JniHandleOwnership ownership)
- : base(handle, ownership)
- {
- Current = this;
- }
-
- public static MauiTestInstrumentation Current { get; private set; } = null!;
-
- public Bundle? Arguments { get; private set; }
-
- public IServiceProvider Services { get; private set; } = null!;
-
- public TestOptions Options { get; private set; } = null!;
-
- public HeadlessRunnerOptions RunnerOptions { get; private set; } = null!;
-
- public Context? CurrentExecutionContext { get; private set; }
-
- public override void OnCreate(Bundle? arguments)
- {
- _activityClass = Java.Lang.Class.ForName(Context!.PackageName + ".TestActivity");
- Arguments = arguments;
-
- base.OnCreate(arguments);
-
- Start();
- }
-
- public override void CallApplicationOnCreate(Application? app)
- {
- base.CallApplicationOnCreate(app);
-
- if (app == null)
- _waitForApplication.SetException(new ArgumentNullException(nameof(app)));
- else
- _waitForApplication.SetResult(app);
- }
-
- public override async void OnStart()
- {
- base.OnStart();
-
- await _waitForApplication.Task;
-
- Services = MauiApplication.Current.Services;
- Options = Services.GetRequiredService();
- RunnerOptions = Services.GetRequiredService();
-
- var resultsFilename = Arguments?.GetString("results-file-name");
- if (!string.IsNullOrWhiteSpace(resultsFilename))
- RunnerOptions.TestResultsFilename = resultsFilename;
-
- var bundle = await RunTestsAsync();
-
- CopyFile(bundle);
-
- Finish(Result.Ok, bundle);
- }
-
- private void CopyFile(Bundle bundle)
- {
- var resultsFile = bundle.GetString("test-results-path");
- if (resultsFile == null)
- return;
-
- var guid = Guid.NewGuid().ToString("N");
- var name = Path.GetFileName(resultsFile);
-
- string finalPath;
- if (!OperatingSystem.IsAndroidVersionAtLeast(30))
- {
- var root = Application.Context.GetExternalFilesDir(null)!.AbsolutePath!;
- var dir = Path.Combine(root, guid);
-
- if (!Directory.Exists(dir))
- Directory.CreateDirectory(dir);
-
- finalPath = Path.Combine(dir, name);
- File.Copy(resultsFile, finalPath, true);
- }
- else
- {
- var downloads = Android.OS.Environment.DirectoryDownloads!;
- var relative = Path.Combine(downloads, Context!.PackageName!, guid);
-
- var values = new ContentValues();
- values.Put(MediaStore.IMediaColumns.DisplayName, name);
- values.Put(MediaStore.IMediaColumns.MimeType, "text/xml");
- values.Put(MediaStore.IMediaColumns.RelativePath, relative);
-
- var resolver = Context!.ContentResolver!;
- var uri = resolver.Insert(MediaStore.Downloads.ExternalContentUri, values)!;
- using (var dest = resolver.OpenOutputStream(uri)!)
- using (var source = File.OpenRead(resultsFile))
- source.CopyTo(dest);
-
-#pragma warning disable CS0618 // Type or member is obsolete
- var root = Android.OS.Environment.ExternalStorageDirectory!.AbsolutePath;
-#pragma warning restore CS0618 // Type or member is obsolete
- finalPath = Path.Combine(root, relative, name);
- }
-
- bundle.PutString("test-results-path", finalPath);
- }
-
- private Task RunTestsAsync()
- {
- if (RunnerOptions.RequiresUIContext)
- {
- var intent = new Intent(TargetContext, _activityClass);
- intent.AddFlags(ActivityFlags.NewTask);
-
- var activity = StartActivitySync(intent);
- if (activity is not MauiTestActivity testActivity)
- throw new InvalidOperationException($"Unexpected activity type '{activity?.GetType().FullName ?? ""}'.");
-
- CurrentExecutionContext = activity;
-
- return testActivity.TaskCompletionSource.Task;
- }
- else
- {
- CurrentExecutionContext = TargetContext;
-
- var runner = Services.GetRequiredService();
-
- return runner.RunTestsAsync();
- }
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/TestDevice.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/TestDevice.cs
deleted file mode 100644
index 6407569987..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/TestDevice.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-#nullable enable
-using System;
-using System.Globalization;
-using Microsoft.DotNet.XHarness.TestRunners.Common;
-using Microsoft.Maui.ApplicationModel;
-using Microsoft.Maui.Devices;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-internal class TestDevice : IDevice
-{
- public string BundleIdentifier => AppInfo.PackageName;
-
- public string UniqueIdentifier => Guid.NewGuid().ToString("N");
-
- public string Name => DeviceInfo.Name;
-
- public string Model => DeviceInfo.Model;
-
- public string SystemName => DeviceInfo.Platform.ToString();
-
- public string SystemVersion => DeviceInfo.VersionString;
-
- public string Locale => CultureInfo.CurrentCulture.Name;
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/HeadlessTestRunner.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/HeadlessTestRunner.cs
deleted file mode 100644
index 130be2f4e4..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/HeadlessTestRunner.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-#nullable enable
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.DotNet.XHarness.TestRunners.Common;
-using Microsoft.DotNet.XHarness.TestRunners.Xunit;
-using UIKit;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-internal class HeadlessTestRunner : iOSApplicationEntryPoint
-{
- private readonly HeadlessRunnerOptions _runnerOptions;
- private readonly TestOptions _options;
-
- public HeadlessTestRunner(HeadlessRunnerOptions runnerOptions, TestOptions options)
- {
- _runnerOptions = runnerOptions;
- _options = options;
- }
-
- protected override bool LogExcludedTests => true;
-
- protected override int? MaxParallelThreads => Environment.ProcessorCount;
-
- protected override IDevice Device { get; } = new TestDevice();
-
- protected override IEnumerable GetTestAssemblies() =>
- _options.Assemblies
- .Distinct()
- .Select(assembly => new TestAssemblyInfo(assembly, assembly.Location));
-
- protected override void TerminateWithSuccess()
- {
- var s = new ObjCRuntime.Selector("terminateWithSuccess");
- UIApplication.SharedApplication.PerformSelector(s, UIApplication.SharedApplication, 0);
- }
-
- protected override TestRunner GetTestRunner(LogWriter logWriter)
- {
- var testRunner = base.GetTestRunner(logWriter);
- if (_options.SkipCategories?.Count > 0)
- testRunner.SkipCategories(_options.SkipCategories);
- return testRunner;
- }
-
- public async Task RunTestsAsync()
- {
- TestsCompleted += OnTestsCompleted;
-
- await RunAsync();
-
- TestsCompleted -= OnTestsCompleted;
-
- void OnTestsCompleted(object? sender, TestRunResult results)
- {
- var message =
- $"Tests run: {results.ExecutedTests} " +
- $"Passed: {results.PassedTests} " +
- $"Inconclusive: {results.InconclusiveTests} " +
- $"Failed: {results.FailedTests} " +
- $"Ignored: {results.SkippedTests}";
-
- Console.WriteLine(message);
- }
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestApplicationDelegate.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestApplicationDelegate.cs
deleted file mode 100644
index 93700cb64c..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestApplicationDelegate.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-#nullable enable
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Foundation;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Maui.Hosting;
-using ObjCRuntime;
-using UIKit;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-public abstract class MauiTestApplicationDelegate : UIApplicationDelegate
-{
- // TODO: https://github.com/xamarin/xamarin-macios/issues/12555
- private static readonly string[] EnvVarNames = {
- "NUNIT_AUTOSTART",
- "NUNIT_AUTOEXIT",
- "NUNIT_ENABLE_NETWORK",
- "DISABLE_SYSTEM_PERMISSION_TESTS",
- "NUNIT_HOSTNAME",
- "NUNIT_TRANSPORT",
- "NUNIT_LOG_FILE",
- "NUNIT_HOSTPORT",
- "USE_TCP_TUNNEL",
- "RUN_END_TAG",
- "NUNIT_ENABLE_XML_OUTPUT",
- "NUNIT_ENABLE_XML_MODE",
- "NUNIT_XML_VERSION",
- "NUNIT_SORTNAMES",
- "NUNIT_RUN_ALL",
- "NUNIT_SKIPPED_METHODS",
- "NUNIT_SKIPPED_CLASSES",
- };
- private static readonly Dictionary EnvVars = new();
-
- static MauiTestApplicationDelegate()
- {
- // copy into dictionary for later
- foreach (var envvar in EnvVarNames)
- {
- EnvVars[envvar] = Environment.GetEnvironmentVariable(envvar);
- }
- }
-
- private static void SetEnvironmentVariables()
- {
- // read from dictionary
- foreach (var envvar in EnvVars)
- {
- Console.WriteLine($" {envvar.Key} = '{envvar.Value}'");
- Environment.SetEnvironmentVariable(envvar.Key, envvar.Value);
- }
- }
-
- public static bool IsHeadlessRunner(string[] args)
- {
- // usually means this is from xharness
- return args?.Length > 0 || Environment.GetEnvironmentVariable("NUNIT_AUTOEXIT")?.Length > 0;
- }
-
- protected MauiTestApplicationDelegate()
- {
- Current = this;
- }
-
- public static MauiTestApplicationDelegate Current { get; private set; } = null!;
-
- public IServiceProvider Services { get; private set; } = null!;
-
- public TestOptions Options { get; private set; } = null!;
-
- public HeadlessRunnerOptions RunnerOptions { get; private set; } = null!;
-
- public override UIWindow? Window { get; set; }
-
- protected abstract MauiApp CreateMauiApp();
-
- public override bool WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
- {
- Runtime.MarshalManagedException += (object sender, MarshalManagedExceptionEventArgs args) =>
- {
- Console.WriteLine("Marshaling managed exception");
- Console.WriteLine(" Exception: {0}", args.Exception);
- Console.WriteLine(" Mode: {0}", args.ExceptionMode);
-
- };
-
- Runtime.MarshalObjectiveCException += (object sender, MarshalObjectiveCExceptionEventArgs args) =>
- {
- Console.WriteLine("Marshaling Objective-C exception");
- Console.WriteLine(" Exception: {0}", args.Exception);
- Console.WriteLine(" Mode: {0}", args.ExceptionMode);
- };
-
- var mauiApp = CreateMauiApp();
- Services = mauiApp.Services;
-
- SetEnvironmentVariables();
-
- Options = Services.GetRequiredService();
- RunnerOptions = Services.GetRequiredService();
-
- return true;
- }
-
- public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
- {
- var tcs = new TaskCompletionSource();
-
- Window = new UIWindow(UIScreen.MainScreen.Bounds)
- {
- RootViewController = new MauiTestViewController(tcs.Task)
- };
-
- Window.MakeKeyAndVisible();
-
- tcs.TrySetResult();
-
- return true;
- }
-
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestViewController.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestViewController.cs
deleted file mode 100644
index 7e520cc6c9..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestViewController.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-#nullable enable
-using System.Threading.Tasks;
-using Microsoft.Extensions.DependencyInjection;
-using UIKit;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-public class MauiTestViewController : UIViewController
-{
- private Task? _task;
-
- public MauiTestViewController()
- {
- }
-
- public MauiTestViewController(Task task)
- {
- _task = task;
- }
-
- public override async void ViewDidLoad()
- {
- base.ViewDidLoad();
-
- if (_task is not null)
- await _task;
-
- var runner = MauiTestApplicationDelegate.Current.Services.GetRequiredService();
-
- await runner.RunTestsAsync();
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunnerOptions.cs b/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunnerOptions.cs
deleted file mode 100644
index 3c332a02ea..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/HeadlessRunnerOptions.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-#nullable enable
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public class HeadlessRunnerOptions
-{
- public string TestResultsFilename { get; set; } = "TestResults.xml";
-
- public bool RequiresUIContext { get; set; } = true;
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/TestDispatcher.cs b/test/MauiTestUtils/DeviceTests.Runners/TestDispatcher.cs
deleted file mode 100644
index bcefa60f0e..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/TestDispatcher.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-#nullable enable
-using System;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Maui.Dispatching;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public static class TestDispatcher
-{
- private static IDispatcher? s_dispatcher;
- private static IDispatcherProvider? s_provider;
-
- public static IDispatcherProvider Provider
- {
- get
- {
- if (s_provider is null)
- s_provider = TestServices.Services.GetService();
-
- if (s_provider is null)
- throw new InvalidOperationException($"Test app did not provide a dispatcher.");
-
- return s_provider;
- }
- }
-
- public static IDispatcher Current
- {
- get
- {
- if (s_dispatcher is null)
- s_dispatcher = TestServices.Services.GetService();
-
- if (s_dispatcher is null)
- throw new InvalidOperationException($"Test app did not provide a dispatcher.");
-
- return s_dispatcher;
- }
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/TestOptions.cs b/test/MauiTestUtils/DeviceTests.Runners/TestOptions.cs
deleted file mode 100644
index 9c519c5478..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/TestOptions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-#nullable enable
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public class TestOptions
-{
- ///
- /// The list of assemblies that contain tests.
- ///
- public List Assemblies { get; set; } = new List();
-
- ///
- /// The list of categories to skip in the form:
- /// [category-name]=[skip-when-value]
- ///
- public List SkipCategories { get; set; } = new List();
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/TestServices.cs b/test/MauiTestUtils/DeviceTests.Runners/TestServices.cs
deleted file mode 100644
index 4a29be0f60..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/TestServices.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-#nullable enable
-using System;
-using Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public static class TestServices
-{
- private static IServiceProvider? s_services = null;
-
- public static IServiceProvider Services
- {
- get
- {
- if (s_services is null)
- {
-#if __ANDROID__
- s_services = MauiTestInstrumentation.Current?.Services ?? MauiApplication.Current.Services;
-#elif __IOS__
- s_services = MauiTestApplicationDelegate.Current?.Services ?? MauiUIApplicationDelegate.Current.Services;
-#elif WINDOWS
- s_services = MauiWinUIApplication.Current.Services;
-#endif
- }
-
- if (s_services is null)
- throw new InvalidOperationException($"Test app could not find services.");
-
- return s_services;
- }
- }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj b/test/MauiTestUtils/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj
deleted file mode 100644
index 7a02b2f989..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
- $(TargetFrameworks);net7.0-android
- $(TargetFrameworks);net7.0-windows10.0.19041.0
- $(TargetFrameworks);net7.0-ios
- $(TargetFrameworks);net7.0-maccatalyst
-
- true
- Microsoft.Maui.TestUtils.DeviceTests.Runners
- Microsoft.Maui.TestUtils.DeviceTests.Runners
-
- true
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TestAssemblyPage.xaml
-
-
-
-
diff --git a/test/MauiTestUtils/DeviceTests.Runners/TestWindow.cs b/test/MauiTestUtils/DeviceTests.Runners/TestWindow.cs
deleted file mode 100644
index 38d167180b..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/TestWindow.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-#nullable enable
-using System;
-using System.Linq;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Maui.TestUtils.DeviceTests.Runners.HeadlessRunner;
-
-#if __IOS__ || MACCATALYST
-using PlatformView = UIKit.UIWindow;
-#elif MONOANDROID
-using PlatformView = Android.App.Activity;
-#elif WINDOWS
-using PlatformView = Microsoft.UI.Xaml.Window;
-#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID)
-using PlatformView = System.Object;
-#endif
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners;
-
-public static class TestWindow
-{
- private static PlatformView? s_platformWindow;
-
- public static PlatformView PlatformWindow
- {
- get
- {
- if (s_platformWindow is null)
- {
-#if __ANDROID__
- s_platformWindow = MauiTestInstrumentation.Current?.CurrentExecutionContext as PlatformView;
-#elif __IOS__
- s_platformWindow = MauiTestApplicationDelegate.Current?.Window;
-#endif
- }
-
- if (s_platformWindow is null)
- {
- var application = TestServices.Services.GetService();
- s_platformWindow = application?.Windows.FirstOrDefault()?.Handler?.PlatformView as PlatformView;
- }
-
- if (s_platformWindow is null)
- throw new InvalidOperationException($"Test app did not provide a window.");
-
- return s_platformWindow;
- }
- }
-}
-
diff --git a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/AssemblyRunInfo.cs b/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/AssemblyRunInfo.cs
deleted file mode 100644
index 363e0bdf14..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/AssemblyRunInfo.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-#nullable enable
-using System;
-using System.Collections.Generic;
-using Xunit;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.VisualRunner;
-
-public class AssemblyRunInfo
-{
- public AssemblyRunInfo(string assemblyFileName, TestAssemblyConfiguration configuration, IList testCases)
- {
- AssemblyFileName = assemblyFileName ?? throw new ArgumentNullException(nameof(assemblyFileName));
- Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
- TestCases = testCases ?? throw new ArgumentNullException(nameof(testCases));
- }
-
- public string AssemblyFileName { get; }
-
- public TestAssemblyConfiguration Configuration { get; }
-
- public IList TestCases { get; }
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/Converters/RunStatusToColorConverter.cs b/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/Converters/RunStatusToColorConverter.cs
deleted file mode 100644
index fd540f8bf3..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/Converters/RunStatusToColorConverter.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-#nullable enable
-using System;
-using System.Globalization;
-using Microsoft.Maui.Controls;
-using Microsoft.Maui.Graphics;
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.VisualRunner;
-
-internal class RunStatusToColorConverter : IValueConverter
-{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is not RunStatus status || Application.Current == null)
- return Colors.Red;
-
- return status switch
- {
- RunStatus.Ok => Application.Current.Resources["VisualRunnerSuccessfulTestsColor"],
- RunStatus.Failed => Application.Current.Resources["VisualRunnerFailedTestsColor"],
- RunStatus.NoTests => Application.Current.Resources["VisualRunnerNoTestsColor"],
- RunStatus.NotRun => Application.Current.Resources["VisualRunnerNotRunTestsColor"],
- RunStatus.Skipped => Application.Current.Resources["VisualRunnerSkippedTestsColor"],
- _ => throw new ArgumentOutOfRangeException(nameof(value)),
- };
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
- throw new NotImplementedException();
-}
diff --git a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/DeviceRunner.cs b/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/DeviceRunner.cs
deleted file mode 100644
index 92f5c8dde9..0000000000
--- a/test/MauiTestUtils/DeviceTests.Runners/VisualRunner/DeviceRunner.cs
+++ /dev/null
@@ -1,345 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Logging;
-using Microsoft.Maui.Controls.Xaml;
-using Xunit;
-
-[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
-
-namespace Microsoft.Maui.TestUtils.DeviceTests.Runners.VisualRunner;
-
-public class DeviceRunner : ITestListener, ITestRunner
-{
- private readonly SynchronizationContext context = SynchronizationContext.Current;
- private readonly AsyncLock executionLock = new AsyncLock();
- private readonly ITestNavigation _navigation;
- private readonly TestRunLogger _logger;
- private volatile bool cancelled;
-
- public DeviceRunner(IReadOnlyCollection testAssemblies, ITestNavigation navigation, ILogger logger)
- {
- TestAssemblies = testAssemblies;
- _navigation = navigation;
- _logger = new TestRunLogger(logger);
- }
-
- public IReadOnlyCollection TestAssemblies { get; }
-
- public void RecordResult(TestResultViewModel result)
- {
- _logger.LogTestResult(result);
- }
-
- public Task RunAsync(TestCaseViewModel test)
- {
- return RunAsync(new[] { test });
- }
-
- public Task RunAsync(IEnumerable tests, string message = null)
- {
- var groups = tests
- .GroupBy(t => t.AssemblyFileName)
- .Select(g => new AssemblyRunInfo(
- g.Key,
- GetConfiguration(Path.GetFileNameWithoutExtension(g.Key)),
- g.ToList()))
- .ToList();
-
- return RunAsync(groups, message);
- }
-
- public async Task RunAsync(IReadOnlyList runInfos, string message = null)
- {
- using (await executionLock.LockAsync())
- {
- if (message == null)
- {
- message = runInfos.Count > 1 || runInfos.FirstOrDefault()?.TestCases.Count > 1
- ? "Run Multiple Tests"
- : runInfos.FirstOrDefault()?.TestCases.FirstOrDefault()?.DisplayName;
- }
-
- _logger.LogTestStart(message);
-
- try
- {
- await RunTests(() => runInfos);
- }
- finally
- {
- _logger.LogTestComplete();
- }
- }
- }
-
- public event Action OnDiagnosticMessage;
-
- public Task> DiscoverAsync()
- {
- var tcs = new TaskCompletionSource>();
-
- RunAsync(() =>
- {
- try
- {
- var runInfos = DiscoverTestsInAssemblies();
- var list = runInfos.Select(ri => new TestAssemblyViewModel(ri, _navigation, this)).ToList();
-
- tcs.SetResult(list);
- }
- catch (Exception e)
- {
- tcs.SetException(e);
- }
- });
-
- return tcs.Task;
- }
-
- private IEnumerable DiscoverTestsInAssemblies()
- {
- var result = new List();
-
- try
- {
- foreach (var assm in TestAssemblies)
- {
-#if WINDOWS
- var nameWithoutExt = assm.GetName().Name;
- var assemblyFileName = Storage.FileSystemUtils.PlatformGetFullAppPackageFilePath($"{nameWithoutExt}.dll");
-#elif ANDROID
- // this is required to exist, but is not used
- var assemblyFileName = assm.GetName().Name + ".dll";
- assemblyFileName = Path.Combine(Android.App.Application.Context.CacheDir.AbsolutePath, assemblyFileName);
- if (!File.Exists(assemblyFileName))
- File.Create(assemblyFileName).Close();
-#else
- var assemblyFileName = assm.Location;
-#endif
-
- var configuration = GetConfiguration(assemblyFileName);
- var discoveryOptions = TestFrameworkOptions.ForDiscovery(configuration);
-
- try
- {
- if (cancelled)
- break;
-
- using (var framework = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName, null, false))
- using (var sink = new TestDiscoverySink(() => cancelled))
- {
- framework.Find(false, sink, discoveryOptions);
- sink.Finished.WaitOne();
-
- result.Add(new AssemblyRunInfo(
- assemblyFileName,
- configuration,
- sink.TestCases.Select(tc => new TestCaseViewModel(assemblyFileName, tc)).ToList()));
- }
- }
- catch (Exception e)
- {
- Debug.WriteLine(e);
- }
- }
- }
- catch (Exception e)
- {
- Debug.WriteLine(e);
- }
-
- return result;
- }
-
- private static TestAssemblyConfiguration GetConfiguration(string assemblyName)
- {
- var stream = GetConfigurationStreamForAssembly(assemblyName);
- if (stream != null)
- {
- using (stream)
- {
- return ConfigReader.Load(stream);
- }
- }
-
- return new TestAssemblyConfiguration();
- }
-
- private static Stream GetConfigurationStreamForAssembly(string assemblyName)
- {
-#if __ANDROID__
- var assets = Android.App.Application.Context.Assets;
- var allAssets = assets.List(string.Empty);
-
- if (allAssets.Contains($"{assemblyName}.xunit.runner.json"))
- return assets.Open($"{assemblyName}.xunit.runner.json");
-
- if (allAssets.Contains("xunit.runner.json"))
- return assets.Open("xunit.runner.json");
-#else
-
- // See if there's a directory with the assm name. this might be the case for appx
- if (Directory.Exists(assemblyName))
- {
- if (File.Exists(Path.Combine(assemblyName, $"{assemblyName}.xunit.runner.json")))
- {
- return File.OpenRead(Path.Combine(assemblyName, $"{assemblyName}.xunit.runner.json"));
- }
-
- if (File.Exists(Path.Combine(assemblyName, "xunit.runner.json")))
- {
- return File.OpenRead(Path.Combine(assemblyName, "xunit.runner.json"));
- }
- }
-
- // Fallback to working dir
-
- // look for a file called assemblyName.xunit.runner.json first
- if (File.Exists($"{assemblyName}.xunit.runner.json"))
- {
- return File.OpenRead($"{assemblyName}.xunit.runner.json");
- }
-
- if (File.Exists("xunit.runner.json"))
- {
- return File.OpenRead("xunit.runner.json");
- }
-#endif
-
- return null;
- }
-
- private Task RunTests(Func> testCaseAccessor)
- {
- var tcs = new TaskCompletionSource