diff --git a/Directory.Build.props b/Directory.Build.props
index 7928b323f..08e472cc9 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -13,6 +13,13 @@
false
+
+
+ true
+
+
+ false
+ false
\ No newline at end of file
diff --git a/Directory.Packages.props b/Directory.Packages.props
index cd46cb5c8..fea945873 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -19,7 +19,6 @@
-
diff --git a/sample/src/DeviceTestingKitApp/App.xaml.cs b/sample/src/DeviceTestingKitApp/App.xaml.cs
index e2c85c2b8..19cb2083b 100644
--- a/sample/src/DeviceTestingKitApp/App.xaml.cs
+++ b/sample/src/DeviceTestingKitApp/App.xaml.cs
@@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
+ }
- MainPage = new AppShell();
+ protected override Window CreateWindow(IActivationState? activationState)
+ {
+ return new Window(new AppShell());
}
}
diff --git a/sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj b/sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj
index d1106902a..6a91f8e36 100644
--- a/sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj
+++ b/sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj
@@ -21,6 +21,12 @@
1.0
1
+
+
+ false
+
+
+ $(WarningsNotAsErrors);XC0022;XC0025
@@ -79,4 +85,12 @@
+
+
+
+
+
+
+
diff --git a/src/DeviceRunners.Cli/DeviceRunners.Cli.csproj b/src/DeviceRunners.Cli/DeviceRunners.Cli.csproj
index c54412bf0..c25a4a463 100644
--- a/src/DeviceRunners.Cli/DeviceRunners.Cli.csproj
+++ b/src/DeviceRunners.Cli/DeviceRunners.Cli.csproj
@@ -17,7 +17,6 @@
-
diff --git a/src/DeviceRunners.UITesting.Maui/DeviceRunners.UITesting.Maui.csproj b/src/DeviceRunners.UITesting.Maui/DeviceRunners.UITesting.Maui.csproj
index 93fea68e9..14c8d4939 100644
--- a/src/DeviceRunners.UITesting.Maui/DeviceRunners.UITesting.Maui.csproj
+++ b/src/DeviceRunners.UITesting.Maui/DeviceRunners.UITesting.Maui.csproj
@@ -5,6 +5,8 @@
true
true
true
+
+ CA2255
diff --git a/src/DeviceRunners.VisualRunners.Core/DeviceRunners.VisualRunners.Core.csproj b/src/DeviceRunners.VisualRunners.Core/DeviceRunners.VisualRunners.Core.csproj
index 8e2c5f4b2..7b31a9094 100644
--- a/src/DeviceRunners.VisualRunners.Core/DeviceRunners.VisualRunners.Core.csproj
+++ b/src/DeviceRunners.VisualRunners.Core/DeviceRunners.VisualRunners.Core.csproj
@@ -4,7 +4,6 @@
net9.0;net10.0
DeviceRunners.VisualRunners
Core cross-platform types for DeviceRunners visual test runners (result channels, formatters, test events).
- true
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/Pages/CreditsPage.xaml b/src/DeviceRunners.VisualRunners.Maui/App/Pages/CreditsPage.xaml
index f6512bd19..eba916089 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/Pages/CreditsPage.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/Pages/CreditsPage.xaml
@@ -1,8 +1,10 @@
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/Pages/DiagnosticsPage.xaml b/src/DeviceRunners.VisualRunners.Maui/App/Pages/DiagnosticsPage.xaml
index aa81ffac9..f9a3fd2f4 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/Pages/DiagnosticsPage.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/Pages/DiagnosticsPage.xaml
@@ -1,8 +1,10 @@
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml b/src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml
index 43629eec6..df6b6c543 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml
@@ -1,8 +1,10 @@
-
+
-
+
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestAssemblyPage.xaml b/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestAssemblyPage.xaml
index 1222221a8..5cec94d24 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestAssemblyPage.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestAssemblyPage.xaml
@@ -4,6 +4,7 @@
xmlns:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.TestAssemblyPage"
+ x:DataType="vr:TestAssemblyViewModel"
Title="{Binding DisplayName}">
-
+
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestResultPage.xaml b/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestResultPage.xaml
index 1bb40a494..ac4ce181d 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestResultPage.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestResultPage.xaml
@@ -1,8 +1,10 @@
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerApp.xaml b/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerApp.xaml
index 7f7279fce..da5e3efc3 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerApp.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerApp.xaml
@@ -66,14 +66,14 @@
-
+
-
+
-
+
diff --git a/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerAppShell.xaml b/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerAppShell.xaml
index ef5b5220a..ad1f22961 100644
--- a/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerAppShell.xaml
+++ b/src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerAppShell.xaml
@@ -7,7 +7,7 @@
xmlns:pages="clr-namespace:DeviceRunners.VisualRunners.Maui.Pages">
-
+
pendingLock
var deviceExecSink = new DeviceExecutionSink(xunitTestCases, _resultChannelManager);
- IExecutionSink resultsSink = new DelegatingExecutionSummarySink(deviceExecSink, () => cancellationToken.IsCancellationRequested);
+ var sinkOptions = new ExecutionSinkOptions
+ {
+ CancelThunk = () => cancellationToken.IsCancellationRequested,
+ };
if (longRunningSeconds > 0)
{
@@ -127,9 +130,12 @@ void RunTests(XunitTestAssemblyInfo assemblyInfo, IList pendingLock
assemblyInfo.AssemblyFileName,
executionOptions.GetDiagnosticMessagesOrDefault());
- resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagSink);
+ sinkOptions.LongRunningTestTime = TimeSpan.FromSeconds(longRunningSeconds);
+ sinkOptions.DiagnosticMessageSink = MessageSinkAdapter.Wrap(diagSink);
}
+ using var resultsSink = new ExecutionSink(deviceExecSink, sinkOptions);
+
var assm = new XunitProjectAssembly { AssemblyFilename = assemblyInfo.AssemblyFileName };
deviceExecSink.OnMessage(new TestAssemblyExecutionStarting(assm, executionOptions));
diff --git a/src/DeviceRunners.VisualRunners/Utils/FileSystemUtils.cs b/src/DeviceRunners.VisualRunners/Utils/FileSystemUtils.cs
index be9bcb2a1..171d2bdd1 100644
--- a/src/DeviceRunners.VisualRunners/Utils/FileSystemUtils.cs
+++ b/src/DeviceRunners.VisualRunners/Utils/FileSystemUtils.cs
@@ -32,7 +32,8 @@ public class FileSystemUtils
// Android: We can only check the assets folder
try
{
- return Application.Context.Assets.Open(filename);
+ var assets = Application.Context.Assets ?? throw new InvalidOperationException("Android AssetManager is not available.");
+ return assets.Open(filename);
}
catch (Java.IO.FileNotFoundException)
{
@@ -91,7 +92,7 @@ public static string GetAssemblyFileName(Assembly assm)
return Path.Combine(root, filename);
#elif ANDROID
// this is required to exist (although not actually used) so we create a dummy file
- var root = Android.App.Application.Context.CacheDir.AbsolutePath;
+ var root = Android.App.Application.Context.CacheDir?.AbsolutePath ?? throw new InvalidOperationException("Android CacheDir is not available.");
var path = Path.Combine(root, filename);
if (!File.Exists(path))
File.Create(path).Close();
diff --git a/src/DeviceRunners.VisualRunners/Utils/FilteredCollectionView.cs b/src/DeviceRunners.VisualRunners/Utils/FilteredCollectionView.cs
index f30596fdc..445a3a625 100644
--- a/src/DeviceRunners.VisualRunners/Utils/FilteredCollectionView.cs
+++ b/src/DeviceRunners.VisualRunners/Utils/FilteredCollectionView.cs
@@ -36,7 +36,7 @@ public TFilterArg FilterArgument
get { return filterArgument; }
set
{
- if (filterArgument.Equals(value))
+ if (EqualityComparer.Default.Equals(filterArgument, value))
{
return;
}
@@ -58,7 +58,7 @@ public void Dispose()
filteredList.Clear();
}
- int IList.Add(object value)
+ int IList.Add(object? value)
{
throw new NotSupportedException();
}
@@ -68,24 +68,24 @@ void IList.Clear()
throw new NotSupportedException();
}
- bool IList.Contains(object value)
+ bool IList.Contains(object? value)
{
- return Contains((T)value);
+ return Contains((T)value!);
}
- int IList.IndexOf(object value)
+ int IList.IndexOf(object? value)
{
- return IndexOf((T)value);
+ return IndexOf((T)value!);
}
- void IList.Insert(int index, object value)
+ void IList.Insert(int index, object? value)
{
throw new NotSupportedException();
}
bool IList.IsFixedSize => false;
- void IList.Remove(object value)
+ void IList.Remove(object? value)
{
throw new NotSupportedException();
}
@@ -95,7 +95,7 @@ void IList.RemoveAt(int index)
throw new NotSupportedException();
}
- object IList.this[int index]
+ object? IList.this[int index]
{
get { return this[index]; }
set { throw new NotSupportedException(); }
@@ -197,26 +197,26 @@ void DataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventAr
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
- foreach (T item in e.NewItems)
+ foreach (T item in e.NewItems!)
{
OnAdded(item);
}
break;
case NotifyCollectionChangedAction.Remove:
- foreach (T item in e.OldItems)
+ foreach (T item in e.OldItems!)
{
OnRemoved(item);
}
break;
case NotifyCollectionChangedAction.Replace:
- foreach (T item in e.OldItems)
+ foreach (T item in e.OldItems!)
{
OnRemoved(item);
}
- foreach (T item in e.NewItems)
+ foreach (T item in e.NewItems!)
{
OnAdded(item);
}
@@ -227,9 +227,9 @@ void DataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventAr
}
}
- void DataSource_ItemChanged(object sender, PropertyChangedEventArgs e)
+ void DataSource_ItemChanged(object? sender, PropertyChangedEventArgs e)
{
- var item = (T)sender;
+ var item = (T)sender!;
var index = filteredList.IndexOf(item);
if (filter(item, FilterArgument))
{
diff --git a/src/DeviceRunners.VisualRunners/ViewModels/HomeViewModel.cs b/src/DeviceRunners.VisualRunners/ViewModels/HomeViewModel.cs
index c6f8bc4b6..562c5a34d 100644
--- a/src/DeviceRunners.VisualRunners/ViewModels/HomeViewModel.cs
+++ b/src/DeviceRunners.VisualRunners/ViewModels/HomeViewModel.cs
@@ -16,6 +16,7 @@ public class HomeViewModel : AbstractBaseViewModel
bool _isLoaded;
bool _isBusy;
+ TestAssemblyViewModel? _selectedTestAssembly;
public HomeViewModel(
IVisualTestRunnerConfiguration options,
@@ -36,7 +37,6 @@ public HomeViewModel(
Diagnostics = diagnosticsViewModel;
RunEverythingCommand = new Command(RunEverythingExecute, () => !_isBusy);
- NavigateToTestAssemblyCommand = new Command(NavigateToTestAssemblyExecute);
}
public DiagnosticsViewModel? Diagnostics { get; }
@@ -45,7 +45,20 @@ public HomeViewModel(
public ICommand RunEverythingCommand { get; }
- public ICommand NavigateToTestAssemblyCommand { get; }
+ public TestAssemblyViewModel? SelectedTestAssembly
+ {
+ get => _selectedTestAssembly;
+ set
+ {
+ if (Set(ref _selectedTestAssembly, value) && value is not null)
+ {
+ TestAssemblySelected?.Invoke(this, value);
+ // Clear selection so re-entering the page doesn't re-navigate
+ _selectedTestAssembly = null;
+ RaisePropertyChanged(nameof(SelectedTestAssembly));
+ }
+ }
+ }
public event EventHandler? TestAssemblySelected;
@@ -127,12 +140,4 @@ async void RunEverythingExecute()
{
await RunEverythingAsync();
}
-
- void NavigateToTestAssemblyExecute(TestAssemblyViewModel? vm)
- {
- if (vm is null)
- return;
-
- TestAssemblySelected?.Invoke(this, vm);
- }
}
diff --git a/src/DeviceRunners.VisualRunners/ViewModels/TestAssemblyViewModel.cs b/src/DeviceRunners.VisualRunners/ViewModels/TestAssemblyViewModel.cs
index 175810b0d..0f027be84 100644
--- a/src/DeviceRunners.VisualRunners/ViewModels/TestAssemblyViewModel.cs
+++ b/src/DeviceRunners.VisualRunners/ViewModels/TestAssemblyViewModel.cs
@@ -12,6 +12,7 @@ public class TestAssemblyViewModel : AbstractBaseViewModel
readonly List _results;
CancellationTokenSource? _filterCancellationTokenSource;
+ TestCaseViewModel? _selectedTestCase;
TestState _result;
TestState _resultFilter;
TestResultStatus _runStatus;
@@ -34,7 +35,6 @@ public TestAssemblyViewModel(ITestAssemblyInfo testAssembly, ITestRunner testRun
RunAllTestsCommand = new Command(RunAllTestsExecute, () => !_isBusy);
RunFilteredTestsCommand = new Command(RunFilteredTestsExecute, () => !_isBusy);
- NavigateToResultCommand = new Command(NavigateToResultExecute, tc => !_isBusy);
DisplayName = Path.GetFileNameWithoutExtension(testAssembly.AssemblyFileName);
@@ -85,7 +85,21 @@ public TestAssemblyViewModel(ITestAssemblyInfo testAssembly, ITestRunner testRun
public ICommand RunFilteredTestsCommand { get; }
- public ICommand NavigateToResultCommand { get; }
+ public TestCaseViewModel? SelectedTestCase
+ {
+ get => _selectedTestCase;
+ set
+ {
+ if (Set(ref _selectedTestCase, value) && value is not null)
+ {
+ if (!_isBusy)
+ NavigateToResultExecute(value);
+ // Clear selection so re-entering the page doesn't re-navigate
+ _selectedTestCase = null;
+ RaisePropertyChanged(nameof(SelectedTestCase));
+ }
+ }
+ }
public event EventHandler? TestResultSelected;
@@ -231,11 +245,8 @@ async void RunFilteredTestsExecute()
}
}
- async void NavigateToResultExecute(TestCaseViewModel? testCase)
+ async void NavigateToResultExecute(TestCaseViewModel testCase)
{
- if (testCase == null)
- return;
-
await _runner.RunTestsAsync(testCase.TestCaseInfo);
TestResultSelected?.Invoke(this, testCase.TestResult);
diff --git a/src/DeviceRunners.XHarness.Maui/App/Pages/HomePage.xaml.cs b/src/DeviceRunners.XHarness.Maui/App/Pages/HomePage.xaml.cs
index 951ca8f44..7e9812491 100644
--- a/src/DeviceRunners.XHarness.Maui/App/Pages/HomePage.xaml.cs
+++ b/src/DeviceRunners.XHarness.Maui/App/Pages/HomePage.xaml.cs
@@ -29,6 +29,7 @@ protected override async void OnAppearing()
first = false;
- await ViewModel.RunTestsAsync();
+ if (ViewModel is not null)
+ await ViewModel.RunTestsAsync();
}
}
diff --git a/src/DeviceRunners.XHarness.Maui/Platforms/Android/XHarnessInstrumentation.cs b/src/DeviceRunners.XHarness.Maui/Platforms/Android/XHarnessInstrumentation.cs
index d9be6dc94..5ee5d4aea 100644
--- a/src/DeviceRunners.XHarness.Maui/Platforms/Android/XHarnessInstrumentation.cs
+++ b/src/DeviceRunners.XHarness.Maui/Platforms/Android/XHarnessInstrumentation.cs
@@ -14,10 +14,11 @@ protected XHarnessInstrumentation(IntPtr handle, JniHandleOwnership ownership)
protected override HomeViewModel GetHomeViewModel(Android.App.Application app)
{
- if (app is not MauiApplication mauiApp)
+ if (app is not MauiApplication)
throw new InvalidOperationException("The .NET MAUI instrumentation implementation only supports MauiApplication.");
- var services = mauiApp.Services;
+ var services = IPlatformApplication.Current?.Services
+ ?? throw new InvalidOperationException("Platform application services are not available.");
return services.GetRequiredService();
}
}
diff --git a/test/TestProject.Tests/XunitTests.cs b/test/TestProject.Tests/XunitTests.cs
index b0b32d30c..d7ba93cd1 100644
--- a/test/TestProject.Tests/XunitTests.cs
+++ b/test/TestProject.Tests/XunitTests.cs
@@ -35,6 +35,6 @@ public void SimpleTest_Skipped()
[InlineData(3)]
public void DataTest(int number)
{
- Assert.True(true);
+ Assert.True(number > 0);
}
}