|
1 | 1 | #nullable enable
|
2 | 2 |
|
| 3 | +using System; |
3 | 4 | using System.IO;
|
4 | 5 |
|
5 | 6 | namespace Buildalyzer.Environment;
|
6 | 7 |
|
7 | 8 | internal static class DotNetInfoParser
|
8 | 9 | {
|
9 |
| - private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase; |
10 |
| - |
11 | 10 | [Pure]
|
12 | 11 | public static DotNetInfo Parse(IEnumerable<string> lines)
|
13 | 12 | {
|
@@ -94,20 +93,20 @@ void AddRunTime(string line)
|
94 | 93 |
|
95 | 94 | [Pure]
|
96 | 95 | private static Version? Version(string prefix, string line)
|
97 |
| - => line.StartsWith(prefix, IgnoreCase) && System.Version.TryParse(line[prefix.Length..].Trim(), out var parsed) |
| 96 | + => line.IsMatchStart(prefix) && System.Version.TryParse(line[prefix.Length..].Trim(), out var parsed) |
98 | 97 | ? parsed
|
99 | 98 | : null;
|
100 | 99 |
|
101 | 100 | [Pure]
|
102 | 101 | private static string? Label(string prefix, string line)
|
103 |
| - => line.StartsWith(prefix, IgnoreCase) && line[prefix.Length..].Trim() is { Length: > 0 } label |
| 102 | + => line.IsMatchStart(prefix) && line[prefix.Length..].Trim() is { Length: > 0 } label |
104 | 103 | ? label
|
105 | 104 | : null;
|
106 | 105 |
|
107 | 106 | [Pure]
|
108 | 107 | private static string? BasePath(string line)
|
109 | 108 | {
|
110 |
| - if (line.StartsWith("Base Path:", IgnoreCase)) |
| 109 | + if (line.IsMatchStart("Base Path:")) |
111 | 110 | {
|
112 | 111 | var path = line[10..].Trim();
|
113 | 112 |
|
@@ -142,8 +141,7 @@ void AddRunTime(string line)
|
142 | 141 | private static string UnifyPath(string path) => path.Replace('\\', '/').TrimEnd('/');
|
143 | 142 |
|
144 | 143 | [Pure]
|
145 |
| - private static string? GlobalJson(string line) |
146 |
| - => line.Equals("Not found", IgnoreCase) ? null : line; |
| 144 | + private static string? GlobalJson(string line) => line.IsMatch("Not found") ? null : line; |
147 | 145 |
|
148 | 146 | private static readonly HashSet<string> Headers = new(StringComparer.InvariantCultureIgnoreCase)
|
149 | 147 | {
|
|
0 commit comments