| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Linq; |
| | 3 | | using System.Text; |
| | 4 | | using System.Text.Json; |
| | 5 | | using System.Text.RegularExpressions; |
| | 6 | | using Amusoft.DotnetNew.Tests.Interfaces; |
| | 7 | | using Amusoft.DotnetNew.Tests.Templating; |
| | 8 | | using Amusoft.DotnetNew.Tests.Utility; |
| | 9 | |
|
| | 10 | | namespace Amusoft.DotnetNew.Tests.Diagnostics; |
| | 11 | |
|
| 2 | 12 | | internal class BuildResult( |
| 2 | 13 | | string command, |
| 2 | 14 | | string content |
| 2 | 15 | | ) : ICommandResult |
| | 16 | | { |
| 1 | 17 | | private static readonly Regex Regex = new(@"-(?:>) (?<dll>.+?\.dll)", RegexOptions.Compiled); |
| | 18 | |
|
| | 19 | | private IEnumerable<string> GetDlls() |
| | 20 | | { |
| 2 | 21 | | var matchCollection = Regex.Matches(content); |
| 2 | 22 | | return matchCollection |
| 8 | 23 | | .Select(d => d.Groups["dll"].Value) |
| 8 | 24 | | .OrderBy(d => d) |
| 10 | 25 | | .Select(d => new CrossPlatformPath(d).VirtualPath); |
| | 26 | | } |
| | 27 | |
|
| | 28 | | public void Print(StringBuilder stringBuilder) |
| | 29 | | { |
| 2 | 30 | | var serializeContent = new |
| 2 | 31 | | { |
| 2 | 32 | | Command = command, |
| 2 | 33 | | Files = GetDlls(), |
| 2 | 34 | | }; |
| 2 | 35 | | var serialized = JsonSerializer.Serialize(serializeContent,new JsonSerializerOptions() |
| 2 | 36 | | { |
| 2 | 37 | | WriteIndented = true, |
| 2 | 38 | | Encoder = CustomJsonEncoder.Instance |
| 2 | 39 | | } |
| 2 | 40 | | ); |
| | 41 | |
|
| 2 | 42 | | stringBuilder.Append(TemplatingDefaults.Instance.PrintPattern("BuildResult", serialized)); |
| 2 | 43 | | } |
| | 44 | | } |