Skip to content

Commit 0da40bb

Browse files
committed
import winui-app for testing purposes
1 parent 8299d31 commit 0da40bb

File tree

11 files changed

+228
-0
lines changed

11 files changed

+228
-0
lines changed

test/WinUITestApp/App.xaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application
3+
x:Class="winui_app.App"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:winui_app">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11+
<!-- Other merged dictionaries here -->
12+
</ResourceDictionary.MergedDictionaries>
13+
<!-- Other app resources here -->
14+
<ResourceDictionary.ThemeDictionaries>
15+
<ResourceDictionary x:Key="Light">
16+
<BitmapImage x:Key="SentryLogo" UriSource="Assets/sentry-wordmark-dark-300x90.png"/>
17+
</ResourceDictionary>
18+
<ResourceDictionary x:Key="Dark">
19+
<BitmapImage x:Key="SentryLogo" UriSource="Assets/sentry-wordmark-light-300x90.png"/>
20+
</ResourceDictionary>
21+
</ResourceDictionary.ThemeDictionaries>
22+
</ResourceDictionary>
23+
</Application.Resources>
24+
</Application>

test/WinUITestApp/App.xaml.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Microsoft.UI.Xaml;
2+
using Sentry.Protocol;
3+
using System.Security;
4+
5+
namespace winui_app
6+
{
7+
public partial class App : Application
8+
{
9+
private Window? _window;
10+
11+
public App()
12+
{
13+
SentrySdk.Init(options =>
14+
{
15+
options.Dsn = "http://key@127.0.0.1:9999/123";
16+
options.Debug = true;
17+
options.IsGlobalModeEnabled = true;
18+
});
19+
UnhandledException += OnUnhandledException;
20+
21+
InitializeComponent();
22+
}
23+
24+
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
25+
{
26+
_window = new MainWindow();
27+
_window.Activate();
28+
}
29+
30+
[SecurityCritical]
31+
private void OnUnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
32+
{
33+
var exception = e.Exception;
34+
if (exception != null)
35+
{
36+
exception.Data[Mechanism.HandledKey] = false;
37+
exception.Data[Mechanism.MechanismKey] = "Application.UnhandledException";
38+
SentrySdk.CaptureException(exception);
39+
SentrySdk.FlushAsync(TimeSpan.FromSeconds(2)).GetAwaiter().GetResult();
40+
}
41+
}
42+
}
43+
}
Loading
Loading

test/WinUITestApp/MainWindow.xaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Window
3+
x:Class="winui_app.MainWindow"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:winui_app"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d"
10+
Title="winui-app">
11+
12+
<Window.SystemBackdrop>
13+
<MicaBackdrop />
14+
</Window.SystemBackdrop>
15+
16+
<StackPanel
17+
HorizontalAlignment="Center"
18+
VerticalAlignment="Center"
19+
Spacing="24">
20+
21+
<Image Source="{StaticResource SentryLogo}"
22+
HorizontalAlignment="Center"
23+
Stretch="None"/>
24+
25+
<StackPanel Orientation="Horizontal"
26+
HorizontalAlignment="Center"
27+
Spacing="24">
28+
<Button Content="Crash (Managed)"
29+
Click="OnManagedCrashClick"/>
30+
<Button Content="Crash (Native)"
31+
Click="OnNativeCrashClick"/>
32+
</StackPanel>
33+
</StackPanel>
34+
</Window>

test/WinUITestApp/MainWindow.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.UI.Xaml;
2+
using Windows.Graphics;
3+
4+
namespace winui_app
5+
{
6+
public sealed partial class MainWindow : Window
7+
{
8+
public MainWindow()
9+
{
10+
InitializeComponent();
11+
AppWindow.Resize(new SizeInt32(800, 600));
12+
}
13+
14+
private void OnManagedCrashClick(object sender, RoutedEventArgs e)
15+
{
16+
#pragma warning disable CS0618 // Type or member is obsolete
17+
SentrySdk.CauseCrash(CrashType.Managed);
18+
#pragma warning restore CS0618
19+
}
20+
21+
private void OnNativeCrashClick(object sender, RoutedEventArgs e)
22+
{
23+
#pragma warning disable CS0618 // Type or member is obsolete
24+
SentrySdk.CauseCrash(CrashType.Native);
25+
#pragma warning restore CS0618
26+
}
27+
}
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<PublishProtocol>FileSystem</PublishProtocol>
8+
<Platform>ARM64</Platform>
9+
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
10+
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
11+
<SelfContained>true</SelfContained>
12+
<PublishSingleFile>False</PublishSingleFile>
13+
</PropertyGroup>
14+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<PublishProtocol>FileSystem</PublishProtocol>
8+
<Platform>x64</Platform>
9+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
10+
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
11+
<SelfContained>true</SelfContained>
12+
<PublishSingleFile>False</PublishSingleFile>
13+
</PropertyGroup>
14+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"profiles": {
3+
"winui-app": {
4+
"commandName": "Project"
5+
}
6+
}
7+
}

test/WinUITestApp/WinUITestApp.csproj

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>WinExe</OutputType>
4+
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
5+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
6+
<RootNamespace>winui_app</RootNamespace>
7+
<ApplicationManifest>app.manifest</ApplicationManifest>
8+
<Platforms>x64;ARM64</Platforms>
9+
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
10+
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
11+
<UseWinUI>true</UseWinUI>
12+
<Nullable>enable</Nullable>
13+
<ImplicitUsings>enable</ImplicitUsings>
14+
<WindowsPackageType>None</WindowsPackageType>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<Content Include="Assets\sentry-wordmark-dark-300x90.png">
19+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
</Content>
21+
<Content Include="Assets\sentry-wordmark-light-300x90.png">
22+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
23+
</Content>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<Manifest Include="$(ApplicationManifest)" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
32+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<ProjectReference Include="..\..\src\Sentry\Sentry.csproj" />
37+
</ItemGroup>
38+
39+
<PropertyGroup>
40+
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
41+
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
42+
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
43+
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
44+
</PropertyGroup>
45+
</Project>

0 commit comments

Comments
 (0)