add solution accessor
This commit is contained in:
@@ -45,6 +45,7 @@ public partial class DiAutoload : Node
|
||||
services.AddScoped<RoslynAnalysis>();
|
||||
services.AddScoped<IdeFileOperationsService>();
|
||||
services.AddScoped<SharpIdeSolutionModificationService>();
|
||||
services.AddScoped<SharpIdeSolutionAccessor>();
|
||||
|
||||
services.AddHttpClient();
|
||||
services.AddLogging(builder =>
|
||||
|
||||
@@ -18,7 +18,6 @@ public partial class BottomPanelManager : Panel
|
||||
{
|
||||
field = value;
|
||||
_problemsPanel.Solution = value;
|
||||
_nugetPanel.Solution = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<PackedScene>("uid://cqc2xlt81ju8s");
|
||||
private readonly Texture2D _csprojIcon = ResourceLoader.Load<Texture2D>("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);
|
||||
|
||||
@@ -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<IdeRoot> _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;
|
||||
|
||||
9
src/SharpIDE.Godot/SharpIdeSolutionAccessor.cs
Normal file
9
src/SharpIDE.Godot/SharpIdeSolutionAccessor.cs
Normal file
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user