Fixes #4116. NativeAot and SelfContained projects aren't working well in release mode (#4117)

* Fixes #4116. NativeAot and SelfContained projects aren't working well in release mode

* Revert delete nuget package because it fail in the git actions

* Trying automatize the nuget package installation

* Fixing UserProfile

* Trying fix push package for Unix OS

* Still triying to push nuget to the Unix

* Trying delete nuget package in the Pack target

* Trying fix git actions for release build

* Fix projects path

* Still fixing restore

* Add restore force parameter

* Build NativeAot and SelfContained projects before solution

* Build solution without restore

* Restore solutions packages before build

* Call dotnet restore before build the AOT and self-contained projects

* Remove unneeded run

* Revert "Remove unneeded run"

This reverts commit e04498d1ce.

* Trying fix racing fail unit tests

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
BDisp
2025-06-04 19:23:44 +01:00
committed by GitHub
parent 4812d46e5f
commit 8fef16d35f
9 changed files with 93 additions and 23 deletions

View File

@@ -25,7 +25,10 @@ public class ApplicationV2Tests
[Fact]
public void Init_CreatesKeybindings ()
{
var orig = ApplicationImpl.Instance;
var v2 = NewApplicationV2 ();
ApplicationImpl.ChangeInstance (v2);
Application.KeyBindings.Clear ();
@@ -36,12 +39,17 @@ public class ApplicationV2Tests
Assert.NotEmpty (Application.KeyBindings.GetBindings ());
v2.Shutdown ();
ApplicationImpl.ChangeInstance (orig);
}
[Fact]
public void Init_DriverIsFacade ()
{
var orig = ApplicationImpl.Instance;
var v2 = NewApplicationV2 ();
ApplicationImpl.ChangeInstance (v2);
Assert.Null (Application.Driver);
v2.Init ();
@@ -53,11 +61,15 @@ public class ApplicationV2Tests
v2.Shutdown ();
Assert.Null (Application.Driver);
ApplicationImpl.ChangeInstance (orig);
}
[Fact]
public void Init_ExplicitlyRequestWin ()
{
var orig = ApplicationImpl.Instance;
Assert.Null (Application.Driver);
var netInput = new Mock<INetInput> (MockBehavior.Strict);
var netOutput = new Mock<IConsoleOutput> (MockBehavior.Strict);
@@ -77,6 +89,7 @@ public class ApplicationV2Tests
() => netOutput.Object,
() => winInput.Object,
() => winOutput.Object);
ApplicationImpl.ChangeInstance (v2);
Assert.Null (Application.Driver);
v2.Init (null, "v2win");
@@ -90,11 +103,15 @@ public class ApplicationV2Tests
Assert.Null (Application.Driver);
winInput.VerifyAll ();
ApplicationImpl.ChangeInstance (orig);
}
[Fact]
public void Init_ExplicitlyRequestNet ()
{
var orig = ApplicationImpl.Instance;
var netInput = new Mock<INetInput> (MockBehavior.Strict);
var netOutput = new Mock<IConsoleOutput> (MockBehavior.Strict);
var winInput = new Mock<IWindowsInput> (MockBehavior.Strict);
@@ -112,6 +129,7 @@ public class ApplicationV2Tests
() => netOutput.Object,
() => winInput.Object,
() => winOutput.Object);
ApplicationImpl.ChangeInstance (v2);
Assert.Null (Application.Driver);
v2.Init (null, "v2net");
@@ -125,6 +143,8 @@ public class ApplicationV2Tests
Assert.Null (Application.Driver);
netInput.VerifyAll ();
ApplicationImpl.ChangeInstance (orig);
}
private void SetupRunInputMockMethodToBlock (Mock<IWindowsInput> winInput)
@@ -159,12 +179,17 @@ public class ApplicationV2Tests
[Fact]
public void NoInitThrowOnRun ()
{
var orig = ApplicationImpl.Instance;
Assert.Null (Application.Driver);
var app = NewApplicationV2 ();
ApplicationImpl.ChangeInstance (app);
var ex = Assert.Throws<NotInitializedException> (() => app.Run (new Window ()));
Assert.Equal ("Run cannot be accessed before Initialization", ex.Message);
app.Shutdown();
ApplicationImpl.ChangeInstance (orig);
}
[Fact]
@@ -449,6 +474,8 @@ public class ApplicationV2Tests
[Fact]
public void Shutdown_Called_Repeatedly_DoNotDuplicateDisposeOutput ()
{
var orig = ApplicationImpl.Instance;
var netInput = new Mock<INetInput> ();
SetupRunInputMockMethodToBlock (netInput);
Mock<IConsoleOutput>? outputMock = null;
@@ -459,6 +486,7 @@ public class ApplicationV2Tests
() => (outputMock = new Mock<IConsoleOutput> ()).Object,
Mock.Of<IWindowsInput>,
Mock.Of<IConsoleOutput>);
ApplicationImpl.ChangeInstance (v2);
v2.Init (null, "v2net");
@@ -466,11 +494,17 @@ public class ApplicationV2Tests
v2.Shutdown ();
v2.Shutdown ();
outputMock!.Verify (o => o.Dispose (), Times.Once);
ApplicationImpl.ChangeInstance (orig);
}
[Fact]
public void Init_Called_Repeatedly_WarnsAndIgnores ()
{
var orig = ApplicationImpl.Instance;
var v2 = NewApplicationV2 ();
ApplicationImpl.ChangeInstance (v2);
Assert.Null (Application.Driver);
v2.Init ();
@@ -496,12 +530,12 @@ public class ApplicationV2Tests
// Restore the original null logger to be polite to other tests
Logging.Logger = beforeLogger;
ApplicationImpl.ChangeInstance (orig);
}
// QUESTION: What does this test really test? It's poorly named.
[Fact]
public void Open_CallsContinueWithOnUIThread ()
public void Open_Calls_ContinueWith_On_UIThread ()
{
var orig = ApplicationImpl.Instance;