diff --git a/Docs/Notes/2023-08_Ide.md b/Docs/Notes/2023-08_Ide.md index 9f351631f..f42f8c55a 100644 --- a/Docs/Notes/2023-08_Ide.md +++ b/Docs/Notes/2023-08_Ide.md @@ -1,6 +1,4 @@ -2023-08-15 | Luthetus.Ide | Notes - -This file is ordered with the most recent date as the first entry. +2023-08 | Luthetus.Ide | Notes --- diff --git a/Docs/Notes/2023-09_Ide.md b/Docs/Notes/2023-09_Ide.md new file mode 100644 index 000000000..88d22ecfa --- /dev/null +++ b/Docs/Notes/2023-09_Ide.md @@ -0,0 +1,20 @@ +2023-09 | Luthetus.Ide | Notes + +--- + +## 2023-09-02 + +### .NET sln +.NET sln needs to be an immutable type +which is accessed through a `DotNetSolutionKey`. + +All modifications to a .NET sln need be done via the `DotNetSolutionReducer`. + +One can view the current state of a `DotNetSolution` by looking up into the `DotNetSolutionCollection` using a `DotNetSolutionKey`. + +### Background Tasks +The current implementation of IBackgroundTaskQueue for the WASM host is incorrect. + +I realized that each enqueue'd task was being invoked immediately, even if a prior task was still running. + +This logic needs to be fixed, I think I've seen some oddities going on in the WASM app, and this might explain a few of them. \ No newline at end of file diff --git a/Source/Host/Luthetus.Ide.Photino/Program.cs b/Source/Host/Luthetus.Ide.Photino/Program.cs index a7b436cfb..1cd737730 100644 --- a/Source/Host/Luthetus.Ide.Photino/Program.cs +++ b/Source/Host/Luthetus.Ide.Photino/Program.cs @@ -2,11 +2,13 @@ using Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; using Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; using Luthetus.Ide.RazorLib; +using Luthetus.TextEditor.RazorLib; using Luthetus.TextEditor.RazorLib.HostedServiceCase.CompilerServiceCase; using Luthetus.TextEditor.RazorLib.HostedServiceCase.TextEditorCase; using Microsoft.Extensions.DependencyInjection; using Photino.Blazor; using System; +using System.Reflection.PortableExecutable; using System.Threading; using System.Threading.Tasks; @@ -19,21 +21,14 @@ static void Main(string[] args) { var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args); - appBuilder.Services - .AddLogging(); + appBuilder.Services.AddLogging(); - appBuilder.Services.AddLuthetusIdeRazorLibServices(true); + appBuilder.Services.AddLuthetusIdeRazorLibServices(options => options with + { + IsNativeApplication = true, + }); - // The code: - // builder.Services.AddHostedService(); - // - // is not working for the Photino Blazor app. - // So manual starting of the service is done. - appBuilder.Services.AddSingleton(); - appBuilder.Services.AddSingleton(); - appBuilder.Services.AddSingleton(); - appBuilder.Services.AddSingleton(); - appBuilder.Services.AddSingleton(); + appBuilder.Services.AddLuthetusIdePhotino(); appBuilder.RootComponents.Add("app"); @@ -41,19 +36,9 @@ static void Main(string[] args) var backgroundTasksCancellationTokenSource = new CancellationTokenSource(); - var commonQueuedHostedService = app.Services.GetRequiredService(); - var textEditorQueuedHostedService = app.Services.GetRequiredService(); - var compilerServiceQueuedHostedService = app.Services.GetRequiredService(); - var fileSystemQueuedHostedService = app.Services.GetRequiredService(); - var terminalQueuedHostedService = app.Services.GetRequiredService(); - var cancellationToken = backgroundTasksCancellationTokenSource.Token; - _ = Task.Run(async () => await commonQueuedHostedService.StartAsync(cancellationToken)); - _ = Task.Run(async () => await textEditorQueuedHostedService.StartAsync(cancellationToken)); - _ = Task.Run(async () => await compilerServiceQueuedHostedService.StartAsync(cancellationToken)); - _ = Task.Run(async () => await fileSystemQueuedHostedService.StartAsync(cancellationToken)); - _ = Task.Run(async () => await terminalQueuedHostedService.StartAsync(cancellationToken)); + InvokeWorkers(app.Services, cancellationToken); // customize window app.MainWindow @@ -74,4 +59,19 @@ static void Main(string[] args) app.Run(); } + + private static void InvokeWorkers(IServiceProvider serviceProvider, CancellationToken cancellationToken) + { + var commonQueuedHostedService = serviceProvider.GetRequiredService(); + var textEditorQueuedHostedService = serviceProvider.GetRequiredService(); + var compilerServiceQueuedHostedService = serviceProvider.GetRequiredService(); + var fileSystemQueuedHostedService = serviceProvider.GetRequiredService(); + var terminalQueuedHostedService = serviceProvider.GetRequiredService(); + + _ = Task.Run(async () => await commonQueuedHostedService.StartAsync(cancellationToken)); + _ = Task.Run(async () => await textEditorQueuedHostedService.StartAsync(cancellationToken)); + _ = Task.Run(async () => await compilerServiceQueuedHostedService.StartAsync(cancellationToken)); + _ = Task.Run(async () => await fileSystemQueuedHostedService.StartAsync(cancellationToken)); + _ = Task.Run(async () => await terminalQueuedHostedService.StartAsync(cancellationToken)); + } } diff --git a/Source/Host/Luthetus.Ide.Photino/ServiceCollectionExtensions.cs b/Source/Host/Luthetus.Ide.Photino/ServiceCollectionExtensions.cs new file mode 100644 index 000000000..9e6dadf2c --- /dev/null +++ b/Source/Host/Luthetus.Ide.Photino/ServiceCollectionExtensions.cs @@ -0,0 +1,27 @@ +using Luthetus.Common.RazorLib.BackgroundTaskCase.Usage; +using Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; +using Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; +using Luthetus.TextEditor.RazorLib.HostedServiceCase.CompilerServiceCase; +using Luthetus.TextEditor.RazorLib.HostedServiceCase.TextEditorCase; +using Microsoft.Extensions.DependencyInjection; + +namespace Luthetus.TextEditor.RazorLib; + +public static class ServiceCollectionExtensions +{ + public static IServiceCollection AddLuthetusIdePhotino( + this IServiceCollection services) + { + // The code: + // builder.Services.AddHostedService(); + // + // is not working for the Photino Blazor app. + // So manual starting of the service is done. + return services + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton(); + } +} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/ILuthetusIdeComponentRenderers.cs b/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/ILuthetusIdeComponentRenderers.cs index 6190f3689..0afb2230c 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/ILuthetusIdeComponentRenderers.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/ILuthetusIdeComponentRenderers.cs @@ -18,6 +18,4 @@ public interface ILuthetusIdeComponentRenderers public Type? GitDisplayRendererType { get; } public Type? RemoveCSharpProjectFromSolutionRendererType { get; } public Type? InputFileRendererType { get; } - public Type? CompilerServiceBackgroundTaskDisplayRendererType { get; } - public Type? FileSystemBackgroundTaskDisplayRendererType { get; } } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/LuthetusIdeComponentRenderers.cs b/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/LuthetusIdeComponentRenderers.cs index 9a3bc7699..f25164e1b 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/LuthetusIdeComponentRenderers.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/ComponentRenderers/LuthetusIdeComponentRenderers.cs @@ -13,8 +13,6 @@ public LuthetusIdeComponentRenderers( Type? gitDisplayRendererType, Type? removeCSharpProjectFromSolutionRendererType, Type? inputFileRendererType, - Type? compilerServiceBackgroundTaskDisplayRendererType, - Type? fileSystemBackgroundTaskDisplayRendererType, Type? treeViewCSharpProjectDependenciesRendererType, Type? treeViewCSharpProjectNugetPackageReferencesRendererType, Type? treeViewCSharpProjectToProjectReferencesRendererType, @@ -32,8 +30,6 @@ public LuthetusIdeComponentRenderers( GitDisplayRendererType = gitDisplayRendererType; RemoveCSharpProjectFromSolutionRendererType = removeCSharpProjectFromSolutionRendererType; InputFileRendererType = inputFileRendererType; - CompilerServiceBackgroundTaskDisplayRendererType = compilerServiceBackgroundTaskDisplayRendererType; - FileSystemBackgroundTaskDisplayRendererType = fileSystemBackgroundTaskDisplayRendererType; TreeViewCSharpProjectDependenciesRendererType = treeViewCSharpProjectDependenciesRendererType; TreeViewCSharpProjectNugetPackageReferencesRendererType = treeViewCSharpProjectNugetPackageReferencesRendererType; TreeViewCSharpProjectToProjectReferencesRendererType = treeViewCSharpProjectToProjectReferencesRendererType; @@ -58,6 +54,4 @@ public LuthetusIdeComponentRenderers( public Type? GitDisplayRendererType { get; } public Type? RemoveCSharpProjectFromSolutionRendererType { get; } public Type? InputFileRendererType { get; } - public Type? CompilerServiceBackgroundTaskDisplayRendererType { get; } - public Type? FileSystemBackgroundTaskDisplayRendererType { get; } } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskMonitor.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskMonitor.cs deleted file mode 100644 index 0e1102752..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskMonitor.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; -using Luthetus.Common.RazorLib.Notification; -using Luthetus.Common.RazorLib.Store.NotificationCase; -using Luthetus.Ide.ClassLib.ComponentRenderers; -using Luthetus.Ide.ClassLib.ComponentRenderers.Types; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; - -public class FileSystemBackgroundTaskMonitor : IFileSystemBackgroundTaskMonitor -{ - private readonly ILuthetusIdeComponentRenderers _luthetusIdeComponentRenderers; - - public FileSystemBackgroundTaskMonitor( - ILuthetusIdeComponentRenderers luthetusIdeComponentRenderers) - { - _luthetusIdeComponentRenderers = luthetusIdeComponentRenderers; - } - - public IBackgroundTask? ExecutingBackgroundTask { get; private set; } - - public event Action? ExecutingBackgroundTaskChanged; - - public void SetExecutingBackgroundTask(IBackgroundTask? backgroundTask) - { - ExecutingBackgroundTask = backgroundTask; - ExecutingBackgroundTaskChanged?.Invoke(); - - if (backgroundTask is not null && - backgroundTask.ShouldNotifyWhenStartingWorkItem && - backgroundTask.Dispatcher is not null && - _luthetusIdeComponentRenderers.CompilerServiceBackgroundTaskDisplayRendererType is not null) - { - var notificationRecord = new NotificationRecord( - NotificationKey.NewNotificationKey(), - $"Starting: {backgroundTask.Name}", - _luthetusIdeComponentRenderers.CompilerServiceBackgroundTaskDisplayRendererType, - new Dictionary - { - { - nameof(IFileSystemBackgroundTaskDisplayRendererType.BackgroundTask), - backgroundTask - } - }, - null, - true, - null); - - backgroundTask.Dispatcher.Dispatch(new NotificationRecordsCollection.RegisterAction( - notificationRecord)); - } - } -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueueSingleThreaded.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueueSingleThreaded.cs deleted file mode 100644 index 263431386..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueueSingleThreaded.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; -using Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; - -public class FileSystemBackgroundTaskQueueSingleThreaded : IFileSystemBackgroundTaskQueue -{ - public void QueueBackgroundWorkItem( - IBackgroundTask backgroundTask) - { - _ = Task.Run(async () => - { - await backgroundTask - .InvokeWorkItem(CancellationToken.None); - }); - } - - public Task DequeueAsync( - CancellationToken cancellationToken) - { - return Task.FromResult(default(IBackgroundTask?)); - } -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskQueue.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskQueue.cs deleted file mode 100644 index 76e8c40eb..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskQueue.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; - -public interface IFileSystemBackgroundTaskQueue : IBackgroundTaskQueue -{ - -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskMonitor.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/ILuthetusIdeFileSystemBackgroundTaskService.cs similarity index 60% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskMonitor.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/ILuthetusIdeFileSystemBackgroundTaskService.cs index 67b2c5db7..719c14ce9 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/IFileSystemBackgroundTaskMonitor.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/ILuthetusIdeFileSystemBackgroundTaskService.cs @@ -2,7 +2,6 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; -public interface IFileSystemBackgroundTaskMonitor : IBackgroundTaskMonitor +public interface ILuthetusIdeFileSystemBackgroundTaskService : IBackgroundTaskService { - } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueue.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskService.cs similarity index 69% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueue.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskService.cs index 02c09a124..a4b537398 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemBackgroundTaskQueue.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskService.cs @@ -3,11 +3,15 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; -public class FileSystemBackgroundTaskQueue : IFileSystemBackgroundTaskQueue +public class LuthetusIdeFileSystemBackgroundTaskService : ILuthetusIdeFileSystemBackgroundTaskService { private readonly ConcurrentQueue _backgroundTasks = new(); private readonly SemaphoreSlim _workItemsQueueSemaphoreSlim = new(0); + public event Action? ExecutingBackgroundTaskChanged; + + public IBackgroundTask? ExecutingBackgroundTask { get; private set; } + public void QueueBackgroundWorkItem( IBackgroundTask backgroundTask) { @@ -34,4 +38,10 @@ public void QueueBackgroundWorkItem( return backgroundTask; } -} \ No newline at end of file + + public void SetExecutingBackgroundTask(IBackgroundTask? backgroundTask) + { + ExecutingBackgroundTask = backgroundTask; + ExecutingBackgroundTaskChanged?.Invoke(); + } +} diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemQueuedHostedService.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskServiceWorker.cs similarity index 82% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemQueuedHostedService.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskServiceWorker.cs index 50c02af92..8a25f6b3d 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/FileSystemQueuedHostedService.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/FileSystem/LuthetusIdeFileSystemBackgroundTaskServiceWorker.cs @@ -8,25 +8,22 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; -public class FileSystemQueuedHostedService : BackgroundService +public class LuthetusIdeFileSystemBackgroundTaskServiceWorker : BackgroundService { private readonly ILuthetusCommonComponentRenderers _luthetusCommonComponentRenderers; private readonly ILogger _logger; - public FileSystemQueuedHostedService( - IFileSystemBackgroundTaskQueue taskQueue, - IFileSystemBackgroundTaskMonitor taskMonitor, + public LuthetusIdeFileSystemBackgroundTaskServiceWorker( + ILuthetusIdeFileSystemBackgroundTaskService backgroundTaskService, ILuthetusCommonComponentRenderers luthetusCommonComponentRenderers, ILoggerFactory loggerFactory) { _luthetusCommonComponentRenderers = luthetusCommonComponentRenderers; - TaskQueue = taskQueue; - TaskMonitor = taskMonitor; - _logger = loggerFactory.CreateLogger(); + BackgroundTaskService = backgroundTaskService; + _logger = loggerFactory.CreateLogger(); } - public IBackgroundTaskQueue TaskQueue { get; } - public IBackgroundTaskMonitor TaskMonitor { get; } + public IBackgroundTaskService BackgroundTaskService { get; } protected async override Task ExecuteAsync( CancellationToken cancellationToken) @@ -35,14 +32,14 @@ protected async override Task ExecuteAsync( while (!cancellationToken.IsCancellationRequested) { - var backgroundTask = await TaskQueue + var backgroundTask = await BackgroundTaskService .DequeueAsync(cancellationToken); if (backgroundTask is not null) { try { - TaskMonitor.SetExecutingBackgroundTask(backgroundTask); + BackgroundTaskService.SetExecutingBackgroundTask(backgroundTask); var task = backgroundTask.InvokeWorkItem(cancellationToken); } @@ -81,7 +78,7 @@ protected async override Task ExecuteAsync( } finally { - TaskMonitor.SetExecutingBackgroundTask(null); + BackgroundTaskService.SetExecutingBackgroundTask(null); } } } diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskMonitor.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ILuthetusIdeTerminalBackgroundTaskService.cs similarity index 60% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskMonitor.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ILuthetusIdeTerminalBackgroundTaskService.cs index b07d620ce..59d8abc21 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskMonitor.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ILuthetusIdeTerminalBackgroundTaskService.cs @@ -2,7 +2,7 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; -public interface ITerminalBackgroundTaskMonitor : IBackgroundTaskMonitor +public interface ILuthetusIdeTerminalBackgroundTaskService : IBackgroundTaskService { } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskQueue.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskQueue.cs deleted file mode 100644 index 9dbcc9035..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/ITerminalBackgroundTaskQueue.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; - -public interface ITerminalBackgroundTaskQueue : IBackgroundTaskQueue -{ - -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueue.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskService.cs similarity index 69% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueue.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskService.cs index 03f181db9..80a3c7a77 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueue.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskService.cs @@ -3,11 +3,15 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; -public class TerminalBackgroundTaskQueue : ITerminalBackgroundTaskQueue +public class LuthetusIdeTerminalBackgroundTaskService : ILuthetusIdeTerminalBackgroundTaskService { private readonly ConcurrentQueue _backgroundTasks = new(); private readonly SemaphoreSlim _workItemsQueueSemaphoreSlim = new(0); + public event Action? ExecutingBackgroundTaskChanged; + + public IBackgroundTask? ExecutingBackgroundTask { get; private set; } + public void QueueBackgroundWorkItem( IBackgroundTask backgroundTask) { @@ -34,4 +38,10 @@ public void QueueBackgroundWorkItem( return backgroundTask; } + + public void SetExecutingBackgroundTask(IBackgroundTask? backgroundTask) + { + ExecutingBackgroundTask = backgroundTask; + ExecutingBackgroundTaskChanged?.Invoke(); + } } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalQueuedHostedService.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskServiceWorker.cs similarity index 81% rename from Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalQueuedHostedService.cs rename to Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskServiceWorker.cs index 05645dbcd..0f9550355 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalQueuedHostedService.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/LuthetusIdeTerminalBackgroundTaskServiceWorker.cs @@ -8,25 +8,22 @@ namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; -public class TerminalQueuedHostedService : BackgroundService +public class LuthetusIdeTerminalBackgroundTaskServiceWorker : BackgroundService { private readonly ILuthetusCommonComponentRenderers _luthetusCommonComponentRenderers; private readonly ILogger _logger; - public TerminalQueuedHostedService( - ITerminalBackgroundTaskQueue taskQueue, - ITerminalBackgroundTaskMonitor taskMonitor, + public LuthetusIdeTerminalBackgroundTaskServiceWorker( + ILuthetusIdeTerminalBackgroundTaskService backgroundTaskService, ILuthetusCommonComponentRenderers luthetusCommonComponentRenderers, ILoggerFactory loggerFactory) { _luthetusCommonComponentRenderers = luthetusCommonComponentRenderers; - TaskQueue = taskQueue; - TaskMonitor = taskMonitor; - _logger = loggerFactory.CreateLogger(); + BackgroundTaskService = backgroundTaskService; + _logger = loggerFactory.CreateLogger(); } - public IBackgroundTaskQueue TaskQueue { get; } - public IBackgroundTaskMonitor TaskMonitor { get; } + public IBackgroundTaskService BackgroundTaskService { get; } protected async override Task ExecuteAsync( CancellationToken cancellationToken) @@ -35,14 +32,13 @@ protected async override Task ExecuteAsync( while (!cancellationToken.IsCancellationRequested) { - var backgroundTask = await TaskQueue - .DequeueAsync(cancellationToken); + var backgroundTask = await BackgroundTaskService.DequeueAsync(cancellationToken); if (backgroundTask is not null) { try { - TaskMonitor.SetExecutingBackgroundTask(backgroundTask); + BackgroundTaskService.SetExecutingBackgroundTask(backgroundTask); var task = backgroundTask.InvokeWorkItem(cancellationToken); } @@ -81,7 +77,7 @@ protected async override Task ExecuteAsync( } finally { - TaskMonitor.SetExecutingBackgroundTask(null); + BackgroundTaskService.SetExecutingBackgroundTask(null); } } } diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskMonitor.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskMonitor.cs deleted file mode 100644 index 00237fe31..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskMonitor.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; -using Luthetus.Common.RazorLib.Notification; -using Luthetus.Common.RazorLib.Store.NotificationCase; -using Luthetus.Ide.ClassLib.ComponentRenderers; -using Luthetus.Ide.ClassLib.ComponentRenderers.Types; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; - -public class TerminalBackgroundTaskMonitor : ITerminalBackgroundTaskMonitor -{ - private readonly ILuthetusIdeComponentRenderers _luthetusIdeComponentRenderers; - - public TerminalBackgroundTaskMonitor( - ILuthetusIdeComponentRenderers luthetusIdeComponentRenderers) - { - _luthetusIdeComponentRenderers = luthetusIdeComponentRenderers; - } - - public IBackgroundTask? ExecutingBackgroundTask { get; private set; } - - public event Action? ExecutingBackgroundTaskChanged; - - public void SetExecutingBackgroundTask(IBackgroundTask? backgroundTask) - { - ExecutingBackgroundTask = backgroundTask; - ExecutingBackgroundTaskChanged?.Invoke(); - - if (backgroundTask is not null && - backgroundTask.ShouldNotifyWhenStartingWorkItem && - backgroundTask.Dispatcher is not null && - _luthetusIdeComponentRenderers.CompilerServiceBackgroundTaskDisplayRendererType is not null) - { - var notificationRecord = new NotificationRecord( - NotificationKey.NewNotificationKey(), - $"Starting: {backgroundTask.Name}", - _luthetusIdeComponentRenderers.CompilerServiceBackgroundTaskDisplayRendererType, - new Dictionary - { - { - nameof(IFileSystemBackgroundTaskDisplayRendererType.BackgroundTask), - backgroundTask - } - }, - null, - true, - null); - - backgroundTask.Dispatcher.Dispatch(new NotificationRecordsCollection.RegisterAction( - notificationRecord)); - } - } -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueueSingleThreaded.cs b/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueueSingleThreaded.cs deleted file mode 100644 index fb02babe5..000000000 --- a/Source/Lib/Luthetus.Ide.ClassLib/HostedServiceCase/Terminal/TerminalBackgroundTaskQueueSingleThreaded.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; - -namespace Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; - -public class TerminalBackgroundTaskQueueSingleThreaded : ITerminalBackgroundTaskQueue -{ - public void QueueBackgroundWorkItem( - IBackgroundTask backgroundTask) - { - _ = Task.Run(async () => - { - await backgroundTask - .InvokeWorkItem(CancellationToken.None); - }); - } - - public Task DequeueAsync( - CancellationToken cancellationToken) - { - return Task.FromResult(default(IBackgroundTask?)); - } -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Menu/MenuOptionsFactory.cs b/Source/Lib/Luthetus.Ide.ClassLib/Menu/MenuOptionsFactory.cs index 288d27a58..ab3074612 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Menu/MenuOptionsFactory.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Menu/MenuOptionsFactory.cs @@ -31,7 +31,7 @@ public class MenuOptionsFactory : IMenuOptionsFactory private readonly IFileSystemProvider _fileSystemProvider; private readonly IEnvironmentProvider _environmentProvider; private readonly IClipboardService _clipboardService; - private readonly ICommonBackgroundTaskQueue _commonBackgroundTaskQueue; + private readonly ILuthetusCommonBackgroundTaskService _luthetusCommonBackgroundTaskService; public MenuOptionsFactory( ILuthetusIdeComponentRenderers luthetusIdeComponentRenderers, @@ -39,14 +39,14 @@ public MenuOptionsFactory( IFileSystemProvider fileSystemProvider, IEnvironmentProvider environmentProvider, IClipboardService clipboardService, - ICommonBackgroundTaskQueue commonBackgroundTaskQueue) + ILuthetusCommonBackgroundTaskService luthetusCommonBackgroundTaskService) { _luthetusIdeComponentRenderers = luthetusIdeComponentRenderers; _luthetusCommonComponentRenderers = luthetusCommonComponentRenderers; _fileSystemProvider = fileSystemProvider; _environmentProvider = environmentProvider; _clipboardService = clipboardService; - _commonBackgroundTaskQueue = commonBackgroundTaskQueue; + _luthetusCommonBackgroundTaskService = luthetusCommonBackgroundTaskService; } public MenuOptionRecord NewEmptyFile( @@ -410,7 +410,7 @@ await _fileSystemProvider.File.WriteAllTextAsync( null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private void PerformNewDirectoryAction( @@ -441,7 +441,7 @@ await _fileSystemProvider.Directory.CreateDirectoryAsync( null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private void PerformDeleteFileAction( @@ -473,7 +473,7 @@ await _fileSystemProvider.File.DeleteAsync( null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private void PerformCopyFileAction( @@ -499,7 +499,7 @@ await _clipboardService null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private void PerformCutFileAction( @@ -525,7 +525,7 @@ await _clipboardService null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private void PerformPasteFileAction( @@ -618,7 +618,7 @@ await _fileSystemProvider.File.CopyAsync( null, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } private IAbsoluteFilePath? PerformRenameAction( @@ -734,7 +734,7 @@ await terminalSession.EnqueueCommandAsync( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } public void PerformAddProjectToProjectReferenceAction( @@ -812,7 +812,7 @@ public void PerformAddProjectToProjectReferenceAction( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } public void PerformRemoveProjectToProjectReferenceAction( @@ -864,7 +864,7 @@ public void PerformRemoveProjectToProjectReferenceAction( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } public void PerformMoveProjectToSolutionFolderAction( @@ -926,7 +926,7 @@ public void PerformMoveProjectToSolutionFolderAction( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } public void PerformRemoveNuGetPackageReferenceFromProjectAction( @@ -979,7 +979,7 @@ public void PerformRemoveNuGetPackageReferenceFromProjectAction( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } /// diff --git a/Source/Lib/Luthetus.Ide.ClassLib/ServiceCollectionExtensions.cs b/Source/Lib/Luthetus.Ide.ClassLib/ServiceCollectionExtensions.cs index 3547f9b1a..860e9c730 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/ServiceCollectionExtensions.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/ServiceCollectionExtensions.cs @@ -26,6 +26,8 @@ public static IServiceCollection AddLuthetusIdeClassLibServices( this IServiceCollection services) { services + .AddSingleton() + .AddSingleton() .AddScoped() .AddScoped() .AddScoped() @@ -35,19 +37,9 @@ public static IServiceCollection AddLuthetusIdeClassLibServices( .AddScoped() .AddScoped() .AddScoped() - .AddScoped(); - - services - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton(); - - services + .AddScoped() .AddScoped() - .AddScoped(); - - services + .AddScoped() .AddScoped(); services diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/DotNetSolutionCase/DotNetSolutionState.Effector.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/DotNetSolutionCase/DotNetSolutionState.Effector.cs index c5d7cb3d7..4a11f3a8a 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/DotNetSolutionCase/DotNetSolutionState.Effector.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/DotNetSolutionCase/DotNetSolutionState.Effector.cs @@ -23,7 +23,7 @@ private class Effector private readonly ILuthetusCommonComponentRenderers _luthetusCommonComponentRenderers; private readonly ITreeViewService _treeViewService; private readonly IState _dotNetSolutionStateWrap; - private readonly ICompilerServiceBackgroundTaskQueue _compilerServiceBackgroundTaskQueue; + private readonly ILuthetusTextEditorCompilerServiceBackgroundTaskService _compilerServiceBackgroundTaskQueue; public Effector( IFileSystemProvider fileSystemProvider, @@ -32,7 +32,7 @@ public Effector( ILuthetusCommonComponentRenderers luthetusCommonComponentRenderers, ITreeViewService treeViewService, IState dotNetSolutionStateWrap, - ICompilerServiceBackgroundTaskQueue compilerServiceBackgroundTaskQueue) + ILuthetusTextEditorCompilerServiceBackgroundTaskService compilerServiceBackgroundTaskQueue) { _fileSystemProvider = fileSystemProvider; _environmentProvider = environmentProvider; diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/EditorCase/EditorState.Effector.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/EditorCase/EditorState.Effector.cs index 20dfd1bc1..16d539742 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/EditorCase/EditorState.Effector.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/EditorCase/EditorState.Effector.cs @@ -41,7 +41,7 @@ private class Effector private readonly ITextEditorService _textEditorService; private readonly ILuthetusIdeComponentRenderers _luthetusIdeComponentRenderers; private readonly IFileSystemProvider _fileSystemProvider; - private readonly ICommonBackgroundTaskQueue _commonBackgroundTaskQueue; + private readonly ILuthetusCommonBackgroundTaskService _luthetusCommonBackgroundTaskService; private readonly XmlCompilerService _xmlCompilerService; private readonly DotNetSolutionCompilerService _dotNetCompilerService; private readonly CSharpProjectCompilerService _cSharpProjectCompilerService; @@ -57,7 +57,7 @@ public Effector( ITextEditorService textEditorService, ILuthetusIdeComponentRenderers luthetusIdeComponentRenderers, IFileSystemProvider fileSystemProvider, - ICommonBackgroundTaskQueue commonBackgroundTaskQueue, + ILuthetusCommonBackgroundTaskService luthetusCommonBackgroundTaskService, XmlCompilerService xmlCompilerService, DotNetSolutionCompilerService dotNetCompilerService, CSharpProjectCompilerService cSharpProjectCompilerService, @@ -72,7 +72,7 @@ public Effector( _textEditorService = textEditorService; _luthetusIdeComponentRenderers = luthetusIdeComponentRenderers; _fileSystemProvider = fileSystemProvider; - _commonBackgroundTaskQueue = commonBackgroundTaskQueue; + _luthetusCommonBackgroundTaskService = luthetusCommonBackgroundTaskService; _xmlCompilerService = xmlCompilerService; _dotNetCompilerService = dotNetCompilerService; _cSharpProjectCompilerService = cSharpProjectCompilerService; @@ -264,7 +264,7 @@ private async Task CheckIfContentsWereModifiedAsync( dispatcher, CancellationToken.None); - _commonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); }) }, { diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/FileSystemCase/FileSystemState.Effector.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/FileSystemCase/FileSystemState.Effector.cs index 93abae799..49d848e97 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/FileSystemCase/FileSystemState.Effector.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/FileSystemCase/FileSystemState.Effector.cs @@ -15,18 +15,18 @@ private class Effector { private readonly IFileSystemProvider _fileSystemProvider; private readonly ILuthetusCommonComponentRenderers _luthetusCommonComponentRenderers; - private readonly IFileSystemBackgroundTaskQueue _fileSystemBackgroundTaskQueue; + private readonly ILuthetusIdeFileSystemBackgroundTaskService _luthetusIdeFileSystemBackgroundTaskService; private readonly object _syncRoot = new object(); public Effector( IFileSystemProvider fileSystemProvider, ILuthetusCommonComponentRenderers luthetusCommonComponentRenderers, - IFileSystemBackgroundTaskQueue fileSystemBackgroundTaskQueue) + ILuthetusIdeFileSystemBackgroundTaskService luthetusIdeFileSystemBackgroundTaskService) { _fileSystemProvider = fileSystemProvider; _luthetusCommonComponentRenderers = luthetusCommonComponentRenderers; - _fileSystemBackgroundTaskQueue = fileSystemBackgroundTaskQueue; + _luthetusIdeFileSystemBackgroundTaskService = luthetusIdeFileSystemBackgroundTaskService; } [EffectMethod] @@ -106,7 +106,7 @@ await _fileSystemProvider.File.WriteAllTextAsync( dispatcher, CancellationToken.None); - _fileSystemBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + _luthetusIdeFileSystemBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } return Task.CompletedTask; diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Actions.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Actions.cs index ecd8d40d9..55acf725e 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Actions.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Actions.cs @@ -10,14 +10,42 @@ namespace Luthetus.Ide.ClassLib.Store.InputFileCase; public partial record InputFileState { - public record RequestInputFileStateFormAction(string Message, Func OnAfterSubmitFunc, Func> SelectionIsValidFunc, ImmutableArray InputFilePatterns); - public record SetSelectedTreeViewModelAction(TreeViewAbsoluteFilePath? SelectedTreeViewModel); - public record SetOpenedTreeViewModelAction(TreeViewAbsoluteFilePath TreeViewModel, ILuthetusIdeComponentRenderers LuthetusIdeComponentRenderers, ILuthetusCommonComponentRenderers LuthetusCommonComponentRenderers, IFileSystemProvider FileSystemProvider, IEnvironmentProvider EnvironmentProvider); - public record SetSelectedInputFilePatternAction(InputFilePattern InputFilePattern); - public record SetSearchQueryAction(string SearchQuery); + public record RequestInputFileStateFormAction( + string Message, + Func OnAfterSubmitFunc, + Func> SelectionIsValidFunc, + ImmutableArray InputFilePatterns); + + public record SetSelectedTreeViewModelAction( + TreeViewAbsoluteFilePath? SelectedTreeViewModel); + + public record SetOpenedTreeViewModelAction( + TreeViewAbsoluteFilePath TreeViewModel, + ILuthetusIdeComponentRenderers LuthetusIdeComponentRenderers, + ILuthetusCommonComponentRenderers LuthetusCommonComponentRenderers, + IFileSystemProvider FileSystemProvider, + IEnvironmentProvider EnvironmentProvider); + + public record SetSelectedInputFilePatternAction( + InputFilePattern InputFilePattern); + + public record SetSearchQueryAction( + string SearchQuery); + public record MoveBackwardsInHistoryAction; + public record MoveForwardsInHistoryAction; - public record OpenParentDirectoryAction(ILuthetusIdeComponentRenderers LuthetusIdeComponentRenderers, ILuthetusCommonComponentRenderers LuthetusCommonComponentRenderers, IFileSystemProvider FileSystemProvider, IEnvironmentProvider EnvironmentProvider, ICommonBackgroundTaskQueue CommonBackgroundTaskQueue); - public record RefreshCurrentSelectionAction(ICommonBackgroundTaskQueue CommonBackgroundTaskQueue); - public record StartInputFileStateFormAction(RequestInputFileStateFormAction RequestInputFileStateFormAction); + + public record OpenParentDirectoryAction( + ILuthetusIdeComponentRenderers LuthetusIdeComponentRenderers, + ILuthetusCommonComponentRenderers LuthetusCommonComponentRenderers, + IFileSystemProvider FileSystemProvider, + IEnvironmentProvider EnvironmentProvider, + ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService); + + public record RefreshCurrentSelectionAction( + ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService); + + public record StartInputFileStateFormAction( + RequestInputFileStateFormAction RequestInputFileStateFormAction); } \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Reducer.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Reducer.cs index 714904c0f..69d2cbca9 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Reducer.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/InputFileCase/InputFileState.Reducer.cs @@ -144,7 +144,7 @@ public static InputFileState ReduceOpenParentDirectoryAction( null, CancellationToken.None); - openParentDirectoryAction.CommonBackgroundTaskQueue + openParentDirectoryAction.LuthetusCommonBackgroundTaskService .QueueBackgroundWorkItem(backgroundTask); } @@ -184,7 +184,7 @@ public static InputFileState ReduceRefreshCurrentSelectionAction( null, CancellationToken.None); - refreshCurrentSelectionAction.CommonBackgroundTaskQueue + refreshCurrentSelectionAction.LuthetusCommonBackgroundTaskService .QueueBackgroundWorkItem(backgroundTask); return inInputFileState; diff --git a/Source/Lib/Luthetus.Ide.ClassLib/Store/TerminalCase/TerminalSession.cs b/Source/Lib/Luthetus.Ide.ClassLib/Store/TerminalCase/TerminalSession.cs index 3e4ff5cbc..cb55ba54c 100644 --- a/Source/Lib/Luthetus.Ide.ClassLib/Store/TerminalCase/TerminalSession.cs +++ b/Source/Lib/Luthetus.Ide.ClassLib/Store/TerminalCase/TerminalSession.cs @@ -22,7 +22,7 @@ public class TerminalSession { private readonly IDispatcher _dispatcher; private readonly IFileSystemProvider _fileSystemProvider; - private readonly ITerminalBackgroundTaskQueue _terminalBackgroundTaskQueue; + private readonly ILuthetusIdeTerminalBackgroundTaskService _terminalBackgroundTaskQueue; private readonly ILuthetusCommonComponentRenderers _luthetusCommonComponentRenderers; private readonly List _terminalCommandsHistory = new(); private CancellationTokenSource _commandCancellationTokenSource = new(); @@ -38,7 +38,7 @@ public TerminalSession( string? workingDirectoryAbsoluteFilePathString, IDispatcher dispatcher, IFileSystemProvider fileSystemProvider, - ITerminalBackgroundTaskQueue terminalBackgroundTaskQueue, + ILuthetusIdeTerminalBackgroundTaskService terminalBackgroundTaskQueue, ILuthetusCommonComponentRenderers luthetusCommonComponentRenderers) { _dispatcher = dispatcher; diff --git a/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor b/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor deleted file mode 100644 index 92ce6d588..000000000 --- a/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor +++ /dev/null @@ -1,36 +0,0 @@ -
- -
- Adhoc Display -
- -
- -
- -
- -
- - @@BackgroundTaskMonitor.ExecutingBackgroundTask: - -   - - @if (CommonBackgroundTaskMonitor.ExecutingBackgroundTask is null) - { - @: null - } - else - { - @CommonBackgroundTaskMonitor.ExecutingBackgroundTask.Name - } -
-
- - - diff --git a/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor.cs deleted file mode 100644 index ec1d9b2db..000000000 --- a/Source/Lib/Luthetus.Ide.RazorLib/Adhoc/AdhocDisplay.razor.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Fluxor; -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; -using Luthetus.Common.RazorLib.BackgroundTaskCase.Usage; -using Microsoft.AspNetCore.Components; - -namespace Luthetus.Ide.RazorLib.Adhoc; - -public partial class AdhocDisplay : ComponentBase, IDisposable -{ - [Inject] - private ICommonBackgroundTaskQueue CommonBackgroundTaskQueue { get; set; } = null!; - [Inject] - private ICommonBackgroundTaskMonitor CommonBackgroundTaskMonitor { get; set; } = null!; - [Inject] - private IDispatcher Dispatcher { get; set; } = null!; - - private CancellationTokenSource _cancellationTokenSource = new(); - - protected override void OnInitialized() - { - CommonBackgroundTaskMonitor.ExecutingBackgroundTaskChanged += BackgroundTaskMonitorOnExecutingBackgroundTaskChanged; - - base.OnInitialized(); - } - - private async void BackgroundTaskMonitorOnExecutingBackgroundTaskChanged() - { - await InvokeAsync(StateHasChanged); - } - - private void EnqueueTaskOnClick() - { - _cancellationTokenSource.Cancel(); - var token = _cancellationTokenSource.Token; - _cancellationTokenSource = new(); - - var backgroundTask = new BackgroundTask( - async cancellationToken => await WorkItem(cancellationToken), - "Execute App", - "Executes dotnet run", - true, - cancellationToken => Task.CompletedTask, - Dispatcher, - BackgroundTaskKey.NewBackgroundTaskKey(), - token); - - CommonBackgroundTaskQueue.QueueBackgroundWorkItem( - backgroundTask); - } - - private async Task WorkItem( - CancellationToken cancellationToken) - { - throw new ApplicationException("yayaya"); - cancellationToken.ThrowIfCancellationRequested(); - - await Task.Delay(1_500, cancellationToken); - - cancellationToken.ThrowIfCancellationRequested(); - } - - public void Dispose() - { - CommonBackgroundTaskMonitor.ExecutingBackgroundTaskChanged -= BackgroundTaskMonitorOnExecutingBackgroundTaskChanged; - - _cancellationTokenSource.Cancel(); - } -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor new file mode 100644 index 000000000..4f0161e16 --- /dev/null +++ b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor @@ -0,0 +1 @@ +

@BackgroundTaskQueue.GetType().Name

\ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor.cs new file mode 100644 index 000000000..f9c1e3d68 --- /dev/null +++ b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServiceDisplay.razor.cs @@ -0,0 +1,10 @@ +using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; +using Microsoft.AspNetCore.Components; + +namespace Luthetus.Ide.RazorLib.BackgroundServiceCase; + +public partial class BackgroundServiceDisplay : ComponentBase +{ + [Parameter, EditorRequired] + public IBackgroundTaskService BackgroundTaskQueue { get; set; } = null!; +} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor new file mode 100644 index 000000000..912b8e0bb --- /dev/null +++ b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor.cs new file mode 100644 index 000000000..3a30b24af --- /dev/null +++ b/Source/Lib/Luthetus.Ide.RazorLib/BackgroundServiceCase/BackgroundServicesPanelDisplay.razor.cs @@ -0,0 +1,24 @@ +using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; +using Luthetus.Common.RazorLib.BackgroundTaskCase.Usage; +using Luthetus.Ide.ClassLib.HostedServiceCase.FileSystem; +using Luthetus.Ide.ClassLib.HostedServiceCase.Terminal; +using Luthetus.TextEditor.RazorLib.HostedServiceCase.CompilerServiceCase; +using Luthetus.TextEditor.RazorLib.HostedServiceCase.TextEditorCase; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.DependencyInjection; + +namespace Luthetus.Ide.RazorLib.BackgroundServiceCase; + +public partial class BackgroundServicesPanelDisplay : ComponentBase +{ + [Inject] + private ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService { get; set; } = null!; + [Inject] + private ILuthetusIdeFileSystemBackgroundTaskService LuthetusIdeFileSystemBackgroundTaskService { get; set; } = null!; + [Inject] + private ILuthetusIdeTerminalBackgroundTaskService LuthetusIdeTerminalBackgroundTaskService { get; set; } = null!; + [Inject] + private ILuthetusTextEditorCompilerServiceBackgroundTaskService LuthetusTextEditorCompilerServiceBackgroundTaskService { get; set; } = null!; + [Inject] + private ILuthetusTextEditorTextEditorBackgroundTaskService LuthetusTextEditorTextEditorBackgroundTaskService { get; set; } = null!; +} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor b/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor deleted file mode 100644 index 6ac8e2786..000000000 --- a/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor +++ /dev/null @@ -1,9 +0,0 @@ -
-
- @BackgroundTask.Name -
- -
- @BackgroundTask.Description -
-
\ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor.cs deleted file mode 100644 index 4e472c23b..000000000 --- a/Source/Lib/Luthetus.Ide.RazorLib/HostedServiceCase/FileSystemBackgroundTaskDisplay.razor.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Luthetus.Common.RazorLib.BackgroundTaskCase.BaseTypes; -using Luthetus.Ide.ClassLib.ComponentRenderers.Types; -using Microsoft.AspNetCore.Components; - -namespace Luthetus.Ide.RazorLib.HostedServiceCase; - -public partial class FileSystemBackgroundTaskDisplay : ComponentBase, IFileSystemBackgroundTaskDisplayRendererType -{ - [Parameter, EditorRequired] - public IBackgroundTask BackgroundTask { get; set; } = null!; -} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/Classes/InputFileTreeViewKeyboardEventHandler.cs b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/Classes/InputFileTreeViewKeyboardEventHandler.cs index 4ec75a137..a7b23d9a0 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/Classes/InputFileTreeViewKeyboardEventHandler.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/Classes/InputFileTreeViewKeyboardEventHandler.cs @@ -24,7 +24,7 @@ public class InputFileTreeViewKeyboardEventHandler : TreeViewKeyboardEventHandle private readonly Func _setInputFileContentTreeViewRootFunc; private readonly Func _focusSearchInputElementFunc; private readonly Func> _getSearchMatchTuplesFunc; - private readonly ICommonBackgroundTaskQueue _commonBackgroundTaskQueue; + private readonly ILuthetusCommonBackgroundTaskService _luthetusCommonBackgroundTaskService; public InputFileTreeViewKeyboardEventHandler( ITreeViewService treeViewService, @@ -37,7 +37,7 @@ public InputFileTreeViewKeyboardEventHandler( Func setInputFileContentTreeViewRootFunc, Func focusSearchInputElementFunc, Func> getSearchMatchTuplesFunc, - ICommonBackgroundTaskQueue commonBackgroundTaskQueue) + ILuthetusCommonBackgroundTaskService luthetusCommonBackgroundTaskService) : base(treeViewService) { _inputFileStateWrap = inputFileStateWrap; @@ -49,7 +49,7 @@ public InputFileTreeViewKeyboardEventHandler( _setInputFileContentTreeViewRootFunc = setInputFileContentTreeViewRootFunc; _focusSearchInputElementFunc = focusSearchInputElementFunc; _getSearchMatchTuplesFunc = getSearchMatchTuplesFunc; - _commonBackgroundTaskQueue = commonBackgroundTaskQueue; + _luthetusCommonBackgroundTaskService = luthetusCommonBackgroundTaskService; } public override void OnKeyDown(ITreeViewCommandParameter treeViewCommandParameter) @@ -149,7 +149,7 @@ private void HandleUpwardButtonOnClick(ITreeViewCommandParameter treeViewCommand _luthetusCommonComponentRenderers, _fileSystemProvider, _environmentProvider, - _commonBackgroundTaskQueue)); + _luthetusCommonBackgroundTaskService)); ChangeContentRootToOpenedTreeView(_inputFileStateWrap.Value); } @@ -157,7 +157,7 @@ private void HandleUpwardButtonOnClick(ITreeViewCommandParameter treeViewCommand private void HandleRefreshButtonOnClick(ITreeViewCommandParameter treeViewCommandParameter) { _dispatcher.Dispatch(new InputFileState.RefreshCurrentSelectionAction( - _commonBackgroundTaskQueue)); + _luthetusCommonBackgroundTaskService)); ChangeContentRootToOpenedTreeView(_inputFileStateWrap.Value); } diff --git a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InputFileDisplay.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InputFileDisplay.razor.cs index f7f080b04..8521c417a 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InputFileDisplay.razor.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InputFileDisplay.razor.cs @@ -35,7 +35,7 @@ public partial class InputFileDisplay : FluxorComponent, IInputFileRendererType [Inject] private IEnvironmentProvider EnvironmentProvider { get; set; } = null!; [Inject] - private ICommonBackgroundTaskQueue CommonBackgroundTaskQueue { get; set; } = null!; + private ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService { get; set; } = null!; /// /// Receives the as @@ -124,7 +124,7 @@ protected override void OnInitialized() } }, () => _searchMatchTuples, - CommonBackgroundTaskQueue); + LuthetusCommonBackgroundTaskService); InitializeElementDimensions(); diff --git a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InternalComponents/InputFileTopNavBar.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InternalComponents/InputFileTopNavBar.razor.cs index 416e85e10..3fbcc4c51 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InternalComponents/InputFileTopNavBar.razor.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/InputFile/InternalComponents/InputFileTopNavBar.razor.cs @@ -25,7 +25,7 @@ public partial class InputFileTopNavBar : ComponentBase [Inject] private IEnvironmentProvider EnvironmentProvider { get; set; } = null!; [Inject] - private ICommonBackgroundTaskQueue CommonBackgroundTaskQueue { get; set; } = null!; + private ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService { get; set; } = null!; [CascadingParameter(Name = "SetInputFileContentTreeViewRootFunc")] public Func SetInputFileContentTreeViewRootFunc { get; set; } = null!; @@ -63,7 +63,7 @@ private async Task HandleUpwardButtonOnClick() LuthetusCommonComponentRenderers, FileSystemProvider, EnvironmentProvider, - CommonBackgroundTaskQueue)); + LuthetusCommonBackgroundTaskService)); await ChangeContentRootToOpenedTreeView(InputFileState); } @@ -71,7 +71,7 @@ private async Task HandleUpwardButtonOnClick() private async Task HandleRefreshButtonOnClick() { Dispatcher.Dispatch(new InputFileState.RefreshCurrentSelectionAction( - CommonBackgroundTaskQueue)); + LuthetusCommonBackgroundTaskService)); await ChangeContentRootToOpenedTreeView(InputFileState); } diff --git a/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeInitializer.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeInitializer.razor.cs index 5bbf297f0..e2520d005 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeInitializer.razor.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeInitializer.razor.cs @@ -7,6 +7,7 @@ using Luthetus.Ide.ClassLib.Panel; using Luthetus.Ide.ClassLib.Store.PanelCase; using Luthetus.Ide.ClassLib.Store.TerminalCase; +using Luthetus.Ide.RazorLib.BackgroundServiceCase; using Luthetus.Ide.RazorLib.FolderExplorer; using Luthetus.Ide.RazorLib.Notification; using Luthetus.Ide.RazorLib.NuGet; @@ -29,7 +30,7 @@ public partial class LuthetusIdeInitializer : ComponentBase [Inject] private LuthetusTextEditorOptions LuthetusTextEditorOptions { get; set; } = null!; [Inject] - private ITerminalBackgroundTaskQueue TerminalBackgroundTaskQueue { get; set; } = null!; + private ILuthetusIdeTerminalBackgroundTaskService TerminalBackgroundTaskQueue { get; set; } = null!; [Inject] private ILuthetusCommonComponentRenderers LuthetusCommonComponentRenderers { get; set; } = null!; @@ -126,6 +127,18 @@ private void InitializeRightPanelTabs() Dispatcher.Dispatch(new PanelsCollection.RegisterPanelTabAction( rightPanel.PanelRecordKey, notificationsPanelTab)); + + var backgroundServicesPanelTab = new PanelTab( + PanelTabKey.NewPanelTabKey(), + rightPanel.ElementDimensions, + new(), + typeof(BackgroundServicesPanelDisplay), + typeof(IconFolder), + "Background Tasks"); + + Dispatcher.Dispatch(new PanelsCollection.RegisterPanelTabAction( + rightPanel.PanelRecordKey, + backgroundServicesPanelTab)); } private void InitializeBottomPanelTabs() diff --git a/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeOptions.cs b/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeOptions.cs index a69b2fa5e..2ca6dbd2c 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeOptions.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeOptions.cs @@ -1,4 +1,8 @@ namespace Luthetus.Ide.RazorLib; -public record LuthetusIdeOptions( - bool IsNativeApplication); \ No newline at end of file +public record LuthetusIdeOptions +{ + public bool IsNativeApplication { get; init; } + /// Default value is . If one wishes to configure Luthetus.TextEditor themselves, then set this to false, and invoke prior to invoking Luthetus.TextEditor's + public bool AddLuthetusTextEditor { get; init; } = true; +} \ No newline at end of file diff --git a/Source/Lib/Luthetus.Ide.RazorLib/NuGet/NuGetPackageManager.razor.cs b/Source/Lib/Luthetus.Ide.RazorLib/NuGet/NuGetPackageManager.razor.cs index 1813b0353..32822946a 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/NuGet/NuGetPackageManager.razor.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/NuGet/NuGetPackageManager.razor.cs @@ -22,7 +22,7 @@ public partial class NuGetPackageManager : FluxorComponent, INuGetPackageManager [Inject] private INugetPackageManagerProvider NugetPackageManagerProvider { get; set; } = null!; [Inject] - private ICommonBackgroundTaskQueue CommonBackgroundTaskQueue { get; set; } = null!; + private ILuthetusCommonBackgroundTaskService LuthetusCommonBackgroundTaskService { get; set; } = null!; private bool _performingNugetQuery; private Exception? _exceptionFromNugetQuery; @@ -120,7 +120,7 @@ await NugetPackageManagerProvider Dispatcher, CancellationToken.None); - CommonBackgroundTaskQueue.QueueBackgroundWorkItem(backgroundTask); + LuthetusCommonBackgroundTaskService.QueueBackgroundWorkItem(backgroundTask); } catch (Exception e) { diff --git a/Source/Lib/Luthetus.Ide.RazorLib/ServiceCollectionExtensions.cs b/Source/Lib/Luthetus.Ide.RazorLib/ServiceCollectionExtensions.cs index b1fa09df7..facab7c67 100644 --- a/Source/Lib/Luthetus.Ide.RazorLib/ServiceCollectionExtensions.cs +++ b/Source/Lib/Luthetus.Ide.RazorLib/ServiceCollectionExtensions.cs @@ -5,9 +5,7 @@ using Luthetus.Ide.RazorLib.InputFile; using Luthetus.Ide.RazorLib.NuGet; using Luthetus.Ide.RazorLib.TreeViewImplementations; -using Luthetus.Ide.RazorLib.HostedServiceCase; using Microsoft.Extensions.DependencyInjection; -using Luthetus.TextEditor.RazorLib.HostedServiceCase.CompilerServiceCase; using Luthetus.TextEditor.RazorLib; using Luthetus.Ide.ClassLib.ComponentRenderers; using Luthetus.Ide.ClassLib; @@ -21,26 +19,37 @@ public static class ServiceCollectionExtensions { public static IServiceCollection AddLuthetusIdeRazorLibServices( this IServiceCollection services, - bool isNativeApplication, - Func? configureTextEditorOptions = null) + Func? configure = null) { - services.AddLuthetusTextEditor(inTextEditorOptions => + var ideOptions = new LuthetusIdeOptions(); + + if (configure is not null) + ideOptions = configure.Invoke(ideOptions); + + if (ideOptions.AddLuthetusTextEditor) { - inTextEditorOptions = inTextEditorOptions with + services.AddLuthetusTextEditor(inTextEditorOptions => inTextEditorOptions with { CustomThemeRecords = LuthetusTextEditorCustomThemeFacts.AllCustomThemes, InitialThemeKey = LuthetusTextEditorCustomThemeFacts.DarkTheme.ThemeKey, - }; + }); + } - return configureTextEditorOptions is null - ? inTextEditorOptions - : configureTextEditorOptions.Invoke(inTextEditorOptions); - }); + return services + .AddSingleton(ideOptions) + .AddSingleton(_ideComponentRenderers) + .AddLuthetusIdeFileSystem(ideOptions) + .AddLuthetusIdeClassLibServices(); + } + private static IServiceCollection AddLuthetusIdeFileSystem( + this IServiceCollection services, + LuthetusIdeOptions ideOptions) + { Func environmentProviderFactory; Func fileSystemProviderFactory; - if (isNativeApplication) + if (ideOptions.IsNativeApplication) { environmentProviderFactory = _ => new LocalEnvironmentProvider(); fileSystemProviderFactory = _ => new LocalFileSystemProvider(); @@ -53,36 +62,26 @@ public static IServiceCollection AddLuthetusIdeRazorLibServices( serviceProvider.GetRequiredService()); } - services + return services .AddSingleton(environmentProviderFactory.Invoke) .AddSingleton(fileSystemProviderFactory.Invoke); - - services.AddSingleton(_ => - new LuthetusIdeOptions(isNativeApplication)); - - services.AddSingleton(serviceProvider => - { - return new LuthetusIdeComponentRenderers( - typeof(BooleanPromptOrCancelDisplay), - typeof(FileFormDisplay), - typeof(DeleteFileFormDisplay), - typeof(TreeViewNamespacePathDisplay), - typeof(TreeViewAbsoluteFilePathDisplay), - typeof(TreeViewGitFileDisplay), - typeof(NuGetPackageManager), - typeof(GitChangesDisplay), - typeof(RemoveCSharpProjectFromSolutionDisplay), - typeof(InputFileDisplay), - typeof(CompilerServiceBackgroundTaskDisplay), - typeof(FileSystemBackgroundTaskDisplay), - typeof(TreeViewCSharpProjectDependenciesDisplay), - typeof(TreeViewCSharpProjectNugetPackageReferencesDisplay), - typeof(TreeViewCSharpProjectToProjectReferencesDisplay), - typeof(TreeViewCSharpProjectNugetPackageReferenceDisplay), - typeof(TreeViewCSharpProjectToProjectReferenceDisplay), - typeof(TreeViewSolutionFolderDisplay)); - }); - - return services.AddLuthetusIdeClassLibServices(); } + + private static readonly LuthetusIdeComponentRenderers _ideComponentRenderers = new( + typeof(BooleanPromptOrCancelDisplay), + typeof(FileFormDisplay), + typeof(DeleteFileFormDisplay), + typeof(TreeViewNamespacePathDisplay), + typeof(TreeViewAbsoluteFilePathDisplay), + typeof(TreeViewGitFileDisplay), + typeof(NuGetPackageManager), + typeof(GitChangesDisplay), + typeof(RemoveCSharpProjectFromSolutionDisplay), + typeof(InputFileDisplay), + typeof(TreeViewCSharpProjectDependenciesDisplay), + typeof(TreeViewCSharpProjectNugetPackageReferencesDisplay), + typeof(TreeViewCSharpProjectToProjectReferencesDisplay), + typeof(TreeViewCSharpProjectNugetPackageReferenceDisplay), + typeof(TreeViewCSharpProjectToProjectReferenceDisplay), + typeof(TreeViewSolutionFolderDisplay)); } \ No newline at end of file diff --git a/Source/Tests/Luthetus.Ide.Tests/Basics/FileSystem/LuthetusFileSystemTestingBase.cs b/Source/Tests/Luthetus.Ide.Tests/Basics/FileSystem/LuthetusFileSystemTestingBase.cs index 3c503dd02..b4bcaa05d 100644 --- a/Source/Tests/Luthetus.Ide.Tests/Basics/FileSystem/LuthetusFileSystemTestingBase.cs +++ b/Source/Tests/Luthetus.Ide.Tests/Basics/FileSystem/LuthetusFileSystemTestingBase.cs @@ -1,7 +1,6 @@ using Fluxor; using Luthetus.Common.RazorLib; using Luthetus.Common.RazorLib.Clipboard; -using Luthetus.Common.RazorLib.ComponentRenderers; using Luthetus.Common.RazorLib.FileSystem.Classes.Local; using Luthetus.Common.RazorLib.FileSystem.Interfaces; using Luthetus.Common.RazorLib.Storage; @@ -18,14 +17,9 @@ public class LuthetusFileSystemTestingBase { protected readonly ServiceProvider ServiceProvider; - protected IEnvironmentProvider EnvironmentProvider => - ServiceProvider.GetRequiredService(); - - protected IFileSystemProvider FileSystemProvider => - ServiceProvider.GetRequiredService(); - - protected IDispatcher Dispatcher => - ServiceProvider.GetRequiredService(); + protected IEnvironmentProvider EnvironmentProvider => ServiceProvider.GetRequiredService(); + protected IFileSystemProvider FileSystemProvider => ServiceProvider.GetRequiredService(); + protected IDispatcher Dispatcher => ServiceProvider.GetRequiredService(); public LuthetusFileSystemTestingBase() { @@ -33,45 +27,32 @@ public LuthetusFileSystemTestingBase() services.AddScoped(_ => new DoNothingJsRuntime()); - services.AddScoped(_ => new LuthetusCommonComponentRenderers( - null, - null, - null, - null, - null, - null)); - - services.AddLuthetusTextEditor(inTextEditorOptions => + services.AddLuthetusCommonServices(commonOptions => { - var luthetusCommonOptions = inTextEditorOptions.LuthetusCommonOptions ?? new(); - - var luthetusCommonFactories = luthetusCommonOptions.LuthetusCommonFactories with + var outLuthetusCommonFactories = commonOptions.LuthetusCommonFactories with { ClipboardServiceFactory = _ => new InMemoryClipboardService(true), StorageServiceFactory = _ => new DoNothingStorageService(true) }; - luthetusCommonOptions = luthetusCommonOptions with + return commonOptions with { - LuthetusCommonFactories = luthetusCommonFactories + LuthetusCommonFactories = outLuthetusCommonFactories }; + }); - return inTextEditorOptions with - { - CustomThemeRecords = LuthetusTextEditorCustomThemeFacts.AllCustomThemes, - InitialThemeKey = LuthetusTextEditorCustomThemeFacts.DarkTheme.ThemeKey, - LuthetusCommonOptions = luthetusCommonOptions - }; + services.AddLuthetusTextEditor(inTextEditorOptions => inTextEditorOptions with + { + AddLuthetusCommon = false }); services.AddScoped(_ => new LocalEnvironmentProvider()); services.AddScoped(_ => new LocalFileSystemProvider()); - services.AddFluxor(options => options - .ScanAssemblies( - typeof(LuthetusCommonOptions).Assembly, - typeof(LuthetusTextEditorOptions).Assembly, - typeof(ClassLib.ServiceCollectionExtensions).Assembly)); + services.AddFluxor(options => options.ScanAssemblies( + typeof(LuthetusCommonOptions).Assembly, + typeof(LuthetusTextEditorOptions).Assembly, + typeof(ClassLib.ServiceCollectionExtensions).Assembly)); ServiceProvider = services.BuildServiceProvider();