Forge
csharpdeeb25a2
1#nullable enable
2using System.Diagnostics.CodeAnalysis;
3using CascadeIDE.Contracts;
4
5namespace CascadeIDE.Features.Launch.DataAcquisition;
6
7/// <summary>
8/// DAL external adapter: резолв и проверка пути к .csproj в файловой системе.
9/// </summary>
10[IoBoundary]
11public static class LaunchProjectPathResolver
12{
13 public static bool TryGetExistingCsprojFullPath(
14 string solutionDirectory,
15 string projectRelativeToSolution,
16 [NotNullWhen(true)] out string? csprojFullPath)
17 {
18 csprojFullPath = null;
19 if (string.IsNullOrWhiteSpace(projectRelativeToSolution))
20 return false;
21 var full = CanonicalFilePath.Normalize(Path.Combine(solutionDirectory, projectRelativeToSolution));
22 if (!File.Exists(full))
23 return false;
24 csprojFullPath = full;
25 return true;
26 }
27
28 /// <summary>Возвращает нормализованный путь, если файл существует; иначе <see langword="null"/>.</summary>
29 public static string? NormalizeExistingProjectFileFullPath(string? projectFullPath)
30 {
31 if (string.IsNullOrWhiteSpace(projectFullPath))
32 return null;
33 var full = CanonicalFilePath.Normalize(projectFullPath);
34 return File.Exists(full) ? full : null;
35 }
36}
37
View only · write via MCP/CIDE