diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index df85ddb8c..a95896a28 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -30,5 +30,18 @@ jobs: - name: Pack Release Terminal.Gui run: dotnet pack Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ./local_packages - - name: Build Release Solution - run: dotnet build --configuration Release + - name: Restore AOT and Self-Contained projects + run: | + dotnet restore ./Examples/NativeAot/NativeAot.csproj -f + dotnet restore ./Examples/SelfContained/SelfContained.csproj -f + + - name: Restore Solution Packages + run: dotnet restore + + - name: Build Release AOT and Self-Contained + run: | + dotnet build ./Examples/NativeAot/NativeAot.csproj --configuration Release + dotnet build ./Examples/SelfContained/SelfContained.csproj --configuration Release + + - name: Build Release Solution without restore + run: dotnet build --configuration Release --no-restore diff --git a/Terminal.Gui/Configuration/DeepCloner.cs b/Terminal.Gui/Configuration/DeepCloner.cs index ab0699582..9734d56c9 100644 --- a/Terminal.Gui/Configuration/DeepCloner.cs +++ b/Terminal.Gui/Configuration/DeepCloner.cs @@ -46,22 +46,22 @@ public static class DeepCloner { return default (T?); } - // For AOT environments, use source generation exclusively - if (IsAotEnvironment ()) - { - if (TryUseSourceGeneratedCloner (source, out T? result)) - { - return result; - } + //// For AOT environments, use source generation exclusively + //if (IsAotEnvironment ()) + //{ + // if (TryUseSourceGeneratedCloner (source, out T? result)) + // { + // return result; + // } - // If in AOT but source generation failed, throw an exception - // instead of silently falling back to reflection - //throw new InvalidOperationException ( - // $"Type {typeof (T).FullName} is not properly registered in SourceGenerationContext " + - // $"for AOT-compatible cloning."); - Logging.Error ($"Type {typeof (T).FullName} is not properly registered in SourceGenerationContext " + - $"for AOT-compatible cloning."); - } + // // If in AOT but source generation failed, throw an exception + // // instead of silently falling back to reflection + // //throw new InvalidOperationException ( + // // $"Type {typeof (T).FullName} is not properly registered in SourceGenerationContext " + + // // $"for AOT-compatible cloning."); + // Logging.Error ($"Type {typeof (T).FullName} is not properly registered in SourceGenerationContext " + + // $"for AOT-compatible cloning."); + //} // Use reflection-based approach, which should have better performance in non-AOT environments ConcurrentDictionary visited = new (ReferenceEqualityComparer.Instance); diff --git a/Terminal.Gui/Configuration/SourceGenerationContext.cs b/Terminal.Gui/Configuration/SourceGenerationContext.cs index 15c74cb90..1853693d7 100644 --- a/Terminal.Gui/Configuration/SourceGenerationContext.cs +++ b/Terminal.Gui/Configuration/SourceGenerationContext.cs @@ -36,6 +36,10 @@ namespace Terminal.Gui.Configuration; [JsonSerializable (typeof (Scope))] [JsonSerializable (typeof (AppSettingsScope))] [JsonSerializable (typeof (SettingsScope))] +[JsonSerializable (typeof (ThemeScope))] +[JsonSerializable (typeof (Scope))] +[JsonSerializable (typeof (Scope))] +[JsonSerializable (typeof (Scope))] [JsonSerializable (typeof (ConcurrentDictionary))] [JsonSerializable (typeof (Dictionary))] diff --git a/Terminal.Gui/Terminal.Gui.csproj b/Terminal.Gui/Terminal.Gui.csproj index 32d33f646..0646dce05 100644 --- a/Terminal.Gui/Terminal.Gui.csproj +++ b/Terminal.Gui/Terminal.Gui.csproj @@ -156,7 +156,16 @@ + + + + + + $(MSBuildThisFileDirectory)..\local_packages\ @@ -181,5 +190,9 @@ + + + + diff --git a/Terminal.sln b/Terminal.sln index e1e22c58c..4c8437097 100644 --- a/Terminal.sln +++ b/Terminal.sln @@ -50,8 +50,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{C7A51224-5 EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SelfContained", "Examples\SelfContained\SelfContained.csproj", "{524DEA78-7E7C-474D-B42D-52ED4C04FF14}" + ProjectSection(ProjectDependencies) = postProject + {00F366F8-DEE4-482C-B9FD-6DB0200B79E5} = {00F366F8-DEE4-482C-B9FD-6DB0200B79E5} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeAot", "Examples\NativeAot\NativeAot.csproj", "{E6D716C6-AC94-4150-B10A-44AE13F79344}" + ProjectSection(ProjectDependencies) = postProject + {00F366F8-DEE4-482C-B9FD-6DB0200B79E5} = {00F366F8-DEE4-482C-B9FD-6DB0200B79E5} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Tests\Benchmarks\Benchmarks.csproj", "{242FBD3E-2EC6-4274-BD40-8E62AF9327B2}" EndProject diff --git a/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs b/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs index 95796f130..6fa4c0f1b 100644 --- a/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs +++ b/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs @@ -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 (MockBehavior.Strict); var netOutput = new Mock (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 (MockBehavior.Strict); var netOutput = new Mock (MockBehavior.Strict); var winInput = new Mock (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 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 (() => 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 (); SetupRunInputMockMethodToBlock (netInput); Mock? outputMock = null; @@ -459,6 +486,7 @@ public class ApplicationV2Tests () => (outputMock = new Mock ()).Object, Mock.Of, Mock.Of); + 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; diff --git a/local_packages/Terminal.Gui.2.0.0.nupkg b/local_packages/Terminal.Gui.2.0.0.nupkg index d5f2a04d9..1ad376653 100644 Binary files a/local_packages/Terminal.Gui.2.0.0.nupkg and b/local_packages/Terminal.Gui.2.0.0.nupkg differ diff --git a/local_packages/Terminal.Gui.2.0.0.snupkg b/local_packages/Terminal.Gui.2.0.0.snupkg index cace498d9..2b702f59a 100644 Binary files a/local_packages/Terminal.Gui.2.0.0.snupkg and b/local_packages/Terminal.Gui.2.0.0.snupkg differ diff --git a/nuget.config b/nuget.config index 5ac744e94..4dcc41f23 100644 --- a/nuget.config +++ b/nuget.config @@ -15,8 +15,8 @@ - - - + + +