Skip to content

Fixes #4102. Add AOT version of Tests #4134

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

Draft
wants to merge 20 commits into
base: v2_develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a04a198
Fixes 4132. .editorconfig has ambiguous configuration with same files
BDisp Jun 7, 2025
0d17f08
Add UnitTests.AOT project and necessary adjustments
BDisp Jun 7, 2025
3d727a7
Fix inexistent folder
BDisp Jun 7, 2025
2e94f52
Add more debug properties settings to the NativeAot project
BDisp Jun 7, 2025
196712b
Add UnitTests.AOT to the unit-tests.yml
BDisp Jun 7, 2025
afd6cfa
Add coverlet.runsettings file
BDisp Jun 7, 2025
c0a68c3
Exclude *.runsettings from link
BDisp Jun 7, 2025
9b1452c
Add SkipIfAOTFactAttribute class to skip UnitTests.AOT from running M…
BDisp Jun 7, 2025
7c62696
Changing something to re-run got actions
BDisp Jun 8, 2025
c400e06
Merge branch 'v2_develop' into v2_4102_add-aot-unit-tests
tig Jun 9, 2025
6adfc96
Merge branch 'v2_4102_add-aot-unit-tests' of github.com:BDisp/Termina…
tig Jun 9, 2025
7f070a7
Tweaked FactSkipIfAOTAttribute
tig Jun 9, 2025
51f8225
Merge pull request #211 from tig/BDisp-v2_4102_add-aot-unit-tests
BDisp Jun 9, 2025
025ec91
Fixes #4143. ReactiveExample throw System.NotSupportedException: 'Ind…
BDisp Jun 11, 2025
b9c1895
Merge branch 'v2_4143_reactiveexample-exception-fix' into v2_4102_add…
BDisp Jun 11, 2025
d75456e
Link ExampleWindow.cs, copy launchSettings and add status bar to all …
BDisp Jun 11, 2025
93abd7f
Merge branch 'v2_develop' into v2_4102_add-aot-unit-tests
BDisp Jun 11, 2025
82a2427
Resolving merge conflicts
BDisp Jun 12, 2025
79847af
Remove complexity from examples as requested
BDisp Jun 12, 2025
16803af
Merge branch 'v2_develop' into v2_4102_add-aot-unit-tests
tig Jun 12, 2025
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
4 changes: 4 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jobs:

# mv -v Tests/UnitTests/TestResults/*/*.* TestResults/UnitTests/

- name: Run UnitTests.AOT
run: |
dotnet test Tests/UnitTests.AOT --no-build --verbosity normal --collect:"XPlat Code Coverage" --settings Tests/UnitTests.AOT/coverlet.runsettings --diag:logs/UnitTests.AOT/${{ runner.os }}/logs.txt --blame --blame-crash --blame-hang --blame-hang-timeout 60s --blame-crash-collect-always -- xunit.stopOnFail=true

- name: Upload Test Logs
if: always()
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Examples/CommunityToolkitExample/LoginView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CommunityToolkit.Mvvm.Messaging;
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;

namespace CommunityToolkitExample;

Expand Down
1 change: 0 additions & 1 deletion Examples/CommunityToolkitExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Terminal.Gui.Configuration;
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;


namespace CommunityToolkitExample;
Expand Down
93 changes: 0 additions & 93 deletions Examples/Example/Example.cs

This file was deleted.

5 changes: 5 additions & 0 deletions Examples/Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<Version>2.0</Version>
<InformationalVersion>2.0</InformationalVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
</ItemGroup>
Expand Down
76 changes: 76 additions & 0 deletions Examples/Example/ExampleWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;

// Defines a top-level window with border and title
public class ExampleWindow : Window
{
public static string? UserName { get; set; }

Check warning on line 9 in Examples/Example/ExampleWindow.cs

View workflow job for this annotation

GitHub Actions / build_release

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

public ExampleWindow ()
{
Title = $"Example App ({Application.QuitKey} to quit)";

// Create input components and labels
var usernameLabel = new Label { Text = "Username:" };

var userNameText = new TextField
{
// Position text field adjacent to the label
X = Pos.Right (usernameLabel) + 1,

// Fill remaining horizontal space
Width = Dim.Fill ()
};

var passwordLabel = new Label
{
Text = "Password:", X = Pos.Left (usernameLabel), Y = Pos.Bottom (usernameLabel) + 1
};

var passwordText = new TextField
{
Secret = true,

// align with the text box above
X = Pos.Left (userNameText),
Y = Pos.Top (passwordLabel),
Width = Dim.Fill ()
};

// Create login button
var btnLogin = new Button
{
Text = "Login",
Y = Pos.Bottom (passwordLabel) + 1,

// center the login button horizontally
X = Pos.Center (),
IsDefault = true
};

// When login button is clicked display a message popup
btnLogin.Accepting += (s, e) =>
{
if (userNameText.Text == "admin" && passwordText.Text == "password")
{
MessageBox.Query ("Logging In", "Login Successful", "Ok");
UserName = userNameText.Text;
Application.RequestStop ();
}
else
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
// When Accepting is handled, set e.Handled to true to prevent further processing.
e.Handled = true;
};

Height = Dim.Fill ();
Width = Dim.Fill ();

// Add the views to the Window
Add (usernameLabel, userNameText, passwordLabel, passwordText, btnLogin);
}
}
21 changes: 21 additions & 0 deletions Examples/Example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements

// This is a simple example application. For the full range of functionality
// see the UICatalog project

using Terminal.Gui.Configuration;
using Terminal.Gui.App;

// Override the default configuration for the application to use the Light theme
ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
ConfigurationManager.Enable(ConfigLocations.All);

// As Run<T> is used to start the application, it will create an instance of ExampleWindow and run it without needing to explicitly call `Application.Init()`.
Application.Run<ExampleWindow> ().Dispose ();

// Before the application exits, reset Terminal.Gui for clean shutdown
Application.Shutdown ();

// To see this output on the screen it must be done after shutdown,
// which restores the previous screen.
Console.WriteLine ($@"Username: {ExampleWindow.UserName}");
7 changes: 7 additions & 0 deletions Examples/NativeAot/NativeAot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<InvariantGlobalization>false</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
<TrimmerRootAssembly Include="Terminal.Gui" />
Expand All @@ -17,4 +21,7 @@
<TrimmerRootAssembly Include="Terminal.Gui" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Example\ExampleWindow.cs" Link="ExampleWindow.cs" />
</ItemGroup>
</Project>
71 changes: 0 additions & 71 deletions Examples/NativeAot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Terminal.Gui.Configuration;
using Terminal.Gui.Views;
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;

namespace NativeAot;

Expand Down Expand Up @@ -48,72 +46,3 @@ private static void Main (string [] args)
Console.WriteLine ($@"Username: {ExampleWindow.UserName}");
}
}

// Defines a top-level window with border and title
public class ExampleWindow : Window
{
public static string? UserName;

public ExampleWindow ()
{
Title = $"Example App ({Application.QuitKey} to quit)";

// Create input components and labels
var usernameLabel = new Label { Text = "Username:" };

var userNameText = new TextField
{
// Position text field adjacent to the label
X = Pos.Right (usernameLabel) + 1,

// Fill remaining horizontal space
Width = Dim.Fill ()
};

var passwordLabel = new Label
{
Text = "Password:", X = Pos.Left (usernameLabel), Y = Pos.Bottom (usernameLabel) + 1
};

var passwordText = new TextField
{
Secret = true,

// align with the text box above
X = Pos.Left (userNameText),
Y = Pos.Top (passwordLabel),
Width = Dim.Fill ()
};

// Create login button
var btnLogin = new Button
{
Text = "Login",
Y = Pos.Bottom (passwordLabel) + 1,

// center the login button horizontally
X = Pos.Center (),
IsDefault = true
};

// When login button is clicked display a message popup
btnLogin.Accepting += (s, e) =>
{
if (userNameText.Text == "admin" && passwordText.Text == "password")
{
MessageBox.Query ("Logging In", "Login Successful", "Ok");
UserName = userNameText.Text;
Application.RequestStop ();
}
else
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
// Anytime Accepting is handled, make sure to set e.Handled to true.
e.Handled = true;
};

// Add the views to the Window
Add (usernameLabel, userNameText, passwordLabel, passwordText, btnLogin);
}
}
13 changes: 0 additions & 13 deletions Examples/NativeAot/Properties/launchSettings.json

This file was deleted.

2 changes: 1 addition & 1 deletion Examples/NativeAot/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Terminal.Gui C# SelfContained
# Terminal.Gui C# NativeAot

This project aims to test the `Terminal.Gui` library to create a simple `native AOT` `self-container` GUI application in C#, ensuring that all its features are available.

Expand Down
1 change: 1 addition & 0 deletions Examples/ReactiveExample/LoginView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Terminal.Gui.Views;
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;

namespace ReactiveExample;

Expand Down
1 change: 1 addition & 0 deletions Examples/ReactiveExample/ReactiveExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="ReactiveUI" />
<PackageReference Include="ReactiveMarbles.ObservableEvents.SourceGenerator" PrivateAssets="all" />
<PackageReference Include="ReactiveUI.SourceGenerators" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
Expand Down
Loading
Loading