Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure MockApplication is created on the main thread on iOS
  • Loading branch information
jamescrosswell committed Jun 11, 2025
commit f306014b35272d86c0df0d8350bec0bc8bb6fbdc
13 changes: 11 additions & 2 deletions test/Sentry.Maui.Tests/Mocks/MockApplication.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Foundation;

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in test/Sentry.Maui.Tests/Mocks/MockApplication.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)
using Microsoft.Maui.Controls.Internals;

namespace Sentry.Maui.Tests.Mocks;
Expand Down Expand Up @@ -39,11 +40,19 @@
public static MockApplication Create()
{
// The base constructor will try to set the mock as the current application, which we don't want in tests.

lock (LockObj)
{
var previous = Current;
var application = new MockApplication();
MockApplication application = null;
#if __IOS__
// Ensure the constructor is called on the main thread
if (!NSThread.IsMain)
{
NSRunLoop.Main.InvokeOnMainThread(() => application = new MockApplication());
}
#else
application = new MockApplication();
#endif
Current = previous;
return application;
}
Expand Down
Loading