Forge
csharpdeeb25a2
1#nullable enable
2
3using CascadeIDE.Contracts;
4
5namespace CascadeIDE.Cockpit.ComputingUnits.Launch;
6
7/// <summary>
8/// CCU «profile -> project path»: читает launch profile и пытается разрешить существующий .csproj.
9/// Никаких UI-эффектов; только снимок для дальнейшей orchestration-логики.
10/// </summary>
11[ComputingUnit]
12public sealed class LaunchProfileProjectResolveUnit : ICockpitComputeUnit
13{
14 public static LaunchProfileProjectResolveUnit Default { get; } = new();
15
16 private LaunchProfileProjectResolveUnit()
17 {
18 }
19
20 public LaunchProfileProjectResolveSnapshot Compose(
21 string solutionPath,
22 string? profileName,
23 string solutionDirectory)
24 {
25 if (!LaunchProfilesStore.TryResolveProfileForLaunch(solutionPath, profileName, out var profile, out _))
26 return LaunchProfileProjectResolveSnapshot.Empty;
27
28 string? csprojFullPath = null;
29 if (!string.IsNullOrWhiteSpace(profile.ProjectRelativeToSolution))
30 _ = LaunchProjectPathResolver.TryGetExistingCsprojFullPath(solutionDirectory, profile.ProjectRelativeToSolution, out csprojFullPath);
31
32 return new LaunchProfileProjectResolveSnapshot(profile, csprojFullPath);
33 }
34}
35
36public readonly record struct LaunchProfileProjectResolveSnapshot(
37 LaunchProfileData? Profile,
38 string? ProjectCsprojFullPath) : ICockpitComputeUnitPayload
39{
40 public static LaunchProfileProjectResolveSnapshot Empty => new(Profile: null, ProjectCsprojFullPath: null);
41
42 public bool HasProfile => Profile is not null;
43}
44
View only · write via MCP/CIDE