csharp4405de34 | 1 | #nullable enable |
| 2 | |
| 3 | using System.Security.Cryptography; |
| 4 | using System.Text; |
| 5 | |
| 6 | namespace CascadeIDE.Services.Intercom; |
| 7 | |
| 8 | /// <summary>Стабильный ключ кэша attach-resolve для пары workspace + solution (ADR 0135).</summary> |
| 9 | public static class IntercomAttachResolveScopeKey |
| 10 | { |
| 11 | public static string From(string? workspaceRoot, string? solutionPath) |
| 12 | { |
| 13 | var ws = (workspaceRoot ?? "").Trim().TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); |
| 14 | var sln = (solutionPath ?? "").Trim(); |
| 15 | if (ws.Length == 0 && sln.Length == 0) |
| 16 | return "empty"; |
| 17 | |
| 18 | var payload = ws + "\n" + sln; |
| 19 | var hash = SHA256.HashData(Encoding.UTF8.GetBytes(payload)); |
| 20 | return Convert.ToHexString(hash.AsSpan(0, 8)); |
| 21 | } |
| 22 | } |
| 23 | |
View only · write via MCP/CIDE