Skip to content

Commit 06e1ca2

Browse files
committed
Script -- output ports with no code files; replace !...Any with None
1 parent 2d44db4 commit 06e1ca2

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Diff for: 00_Utilities/DotnetUtils/DotnetUtils/Extensions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public static IEnumerable<TResult> SelectT<T1, T2, T3, TResult>(this IEnumerable
1010
src.Select(x => selector(x.Item1, x.Item2, x.Item3));
1111
public static IEnumerable<(T1, T2, int)> WithIndex<T1, T2>(this IEnumerable<(T1, T2)> src) => src.Select((x, index) => (x.Item1, x.Item2, index));
1212

13+
public static bool None<T>(this IEnumerable<T> src, Func<T, bool>? predicate = null) =>
14+
predicate is null ?
15+
!src.Any() :
16+
!src.Any(predicate);
17+
1318
public static bool IsNullOrWhitespace([NotNullWhen(false)] this string? s) => string.IsNullOrWhiteSpace(s);
1419

1520
[return: NotNullIfNotNull("path")]

Diff for: 00_Utilities/DotnetUtils/DotnetUtils/Program.cs

+16-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
(multipleProjs, "Output multiple project files"),
1818
(checkProjects, "Check .csproj/.vbproj files for target framework, nullability etc."),
1919
(checkExecutableProject, "Check that there is at least one executable project per port"),
20+
(noCodeFiles, "Output ports without any code files"),
2021
(printPortInfo, "Print info about a single port"),
2122

2223
(generateMissingSlns, "Generate solution files when missing"),
@@ -87,7 +88,7 @@ void printInfos() {
8788
}
8889

8990
void missingSln() {
90-
var data = infos.Where(x => !x.Slns.Any()).ToArray();
91+
var data = infos.Where(x => x.Slns.None()).ToArray();
9192
foreach (var item in data) {
9293
WriteLine(item.LangPath);
9394
}
@@ -98,7 +99,7 @@ void missingSln() {
9899
void unexpectedSlnName() {
99100
var counter = 0;
100101
foreach (var item in infos) {
101-
if (!item.Slns.Any()) { continue; }
102+
if (item.Slns.None()) { continue; }
102103

103104
var expectedSlnName = $"{item.GameName}.sln";
104105
if (item.Slns.Contains(Combine(item.LangPath, expectedSlnName), StringComparer.InvariantCultureIgnoreCase)) { continue; }
@@ -125,7 +126,7 @@ void multipleSlns() {
125126
}
126127

127128
void missingProj() {
128-
var data = infos.Where(x => !x.Projs.Any()).ToArray();
129+
var data = infos.Where(x => x.Projs.None()).ToArray();
129130
foreach (var item in data) {
130131
WriteLine(item.LangPath);
131132
}
@@ -136,7 +137,7 @@ void missingProj() {
136137
void unexpectedProjName() {
137138
var counter = 0;
138139
foreach (var item in infos) {
139-
if (!item.Projs.Any()) { continue; }
140+
if (item.Projs.None()) { continue; }
140141

141142
var expectedProjName = $"{item.GameName}.{item.ProjExt}";
142143
if (item.Projs.Contains(Combine(item.LangPath, expectedProjName))) { continue; }
@@ -164,7 +165,7 @@ void multipleProjs() {
164165
}
165166

166167
void generateMissingSlns() {
167-
foreach (var item in infos.Where(x => !x.Slns.Any())) {
168+
foreach (var item in infos.Where(x => x.Slns.None())) {
168169
var result = RunProcess("dotnet", $"new sln -n {item.GameName} -o {item.LangPath}");
169170
WriteLine(result);
170171

@@ -177,7 +178,7 @@ void generateMissingSlns() {
177178
}
178179

179180
void generateMissingProjs() {
180-
foreach (var item in infos.Where(x => !x.Projs.Any())) {
181+
foreach (var item in infos.Where(x => x.Projs.None())) {
181182
// We can't use the dotnet command to create a new project using the built-in console template, because part of that template
182183
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
183184
// if there's already such a file, it might try to overwrite it.
@@ -284,6 +285,15 @@ void checkExecutableProject() {
284285
}
285286
}
286287

288+
void noCodeFiles() {
289+
var qry = infos
290+
.Where(x => x.CodeFiles.None())
291+
.OrderBy(x => x.Lang);
292+
foreach (var item in qry) {
293+
WriteLine(item.LangPath);
294+
}
295+
}
296+
287297
void tryBuild() {
288298
// if has code files, try to build
289299
}

0 commit comments

Comments
 (0)