diff --git a/src/SharpIDE.Godot/DiAutoload.cs b/src/SharpIDE.Godot/DiAutoload.cs index ef7285b..0f4dd1c 100644 --- a/src/SharpIDE.Godot/DiAutoload.cs +++ b/src/SharpIDE.Godot/DiAutoload.cs @@ -45,6 +45,7 @@ public partial class DiAutoload : Node services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddHttpClient(); services.AddLogging(builder => diff --git a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs index ad8334b..aa0f7fd 100644 --- a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs +++ b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs @@ -18,7 +18,6 @@ public partial class BottomPanelManager : Panel { field = value; _problemsPanel.Solution = value; - _nugetPanel.Solution = value; } } diff --git a/src/SharpIDE.Godot/Features/Nuget/NugetPanel.cs b/src/SharpIDE.Godot/Features/Nuget/NugetPanel.cs index d9b2407..defb50a 100644 --- a/src/SharpIDE.Godot/Features/Nuget/NugetPanel.cs +++ b/src/SharpIDE.Godot/Features/Nuget/NugetPanel.cs @@ -13,10 +13,11 @@ public partial class NugetPanel : Control private OptionButton _solutionOrProjectOptionButton = null!; private NugetPackageDetails _nugetPackageDetails = null!; - - public SharpIdeSolutionModel? Solution { get; set; } + + private SharpIdeSolutionModel? _solution; [Inject] private readonly NugetClientService _nugetClientService = null!; + [Inject] private readonly SharpIdeSolutionAccessor _sharpIdeSolutionAccessor; private readonly PackedScene _packageEntryScene = ResourceLoader.Load("uid://cqc2xlt81ju8s"); private readonly Texture2D _csprojIcon = ResourceLoader.Load("uid://cqt30ma6xgder"); @@ -43,19 +44,23 @@ public partial class NugetPanel : Control { _ = Task.GodotRun(async () => { - await Task.Delay(300); + if (_solution is null) + { + await _sharpIdeSolutionAccessor.SolutionReadyTcs.Task; + _solution = _sharpIdeSolutionAccessor.SolutionModel; + } await this.InvokeAsync(() => { - foreach (var project in Solution!.AllProjects) + foreach (var project in _solution!.AllProjects) { _solutionOrProjectOptionButton.AddIconItem(_csprojIcon, project.Name); } }); - var result = await _nugetClientService.GetTop100Results(Solution!.DirectoryPath); + var result = await _nugetClientService.GetTop100Results(_solution!.DirectoryPath); _ = Task.GodotRun(async () => { - var project = Solution.AllProjects.First(s => s.Name == "ProjectA"); + var project = _solution.AllProjects.First(s => s.Name == "ProjectA"); await project.MsBuildEvaluationProjectTask; var installedPackages = await ProjectEvaluation.GetPackageReferencesForProject(project); var idePackageResult = await _nugetClientService.GetPackagesForInstalledPackages(project.ChildNodeBasePath, installedPackages); diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index a26739b..13bd05e 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -48,6 +48,7 @@ public partial class IdeRoot : Control [Inject] private readonly IdeOpenTabsFileManager _openTabsFileManager = null!; [Inject] private readonly RoslynAnalysis _roslynAnalysis = null!; [Inject] private readonly SharpIdeSolutionModificationService _sharpIdeSolutionModificationService = null!; + [Inject] private readonly SharpIdeSolutionAccessor _sharpIdeSolutionAccessor = null!; [Inject] private readonly IdeNavigationHistoryService _navigationHistoryService = null!; [Inject] private readonly ILogger _logger = null!; @@ -147,6 +148,8 @@ public partial class IdeRoot : Control await _nodeReadyTcs.Task; // Do not use injected services until after _nodeReadyTcs - Services aren't injected until _Ready _logger.LogInformation("Solution model fully created in {ElapsedMilliseconds} ms", timer.ElapsedMilliseconds); + _sharpIdeSolutionAccessor.SolutionModel = solutionModel; + _sharpIdeSolutionAccessor.SolutionReadyTcs.SetResult(); _solutionExplorerPanel.SolutionModel = solutionModel; _codeEditorPanel.Solution = solutionModel; _bottomPanelManager.Solution = solutionModel; diff --git a/src/SharpIDE.Godot/SharpIdeSolutionAccessor.cs b/src/SharpIDE.Godot/SharpIdeSolutionAccessor.cs new file mode 100644 index 0000000..0f6f774 --- /dev/null +++ b/src/SharpIDE.Godot/SharpIdeSolutionAccessor.cs @@ -0,0 +1,9 @@ +using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; + +namespace SharpIDE.Godot; + +public class SharpIdeSolutionAccessor +{ + public SharpIdeSolutionModel SolutionModel { get; set; } = null!; + public TaskCompletionSource SolutionReadyTcs { get; } = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); +} \ No newline at end of file